suhas-mahajan
13th January 2007, 13:38
Hi Friends,

Good News for Win$ows users...

We have developed a VB program, which will check BW program is running into memory, if it is this program not allow to take more than one BaaN licence on client PC's. Yes...you have to deploy it on every PC. By changing icon of this executable program to "B" (BaaN Icon).

Here is a code and VB project:

Private Const TH32CS_SNAPPROCESS As Long = 2&
Private Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type

Private Declare Function CreateToolhelpSnapshot Lib "Kernel32" Alias _
"CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessFirst Lib "Kernel32" Alias "Process32First" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "Kernel32" Alias "Process32Next" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub CloseHandle Lib "Kernel32" (ByVal hPass As Long)

Private Sub Form_Load()
Dim temp As Integer
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim r As Long
Dim aldRunning As Boolean

aldRunning = False
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = 0 Then
Exit Sub
End If
uProcess.dwSize = Len(uProcess)
r = ProcessFirst(hSnapShot, uProcess)
Do While r
Text1 = uProcess.szExeFile
temp = InStrRev(Text1, "\")
r = ProcessNext(hSnapShot, uProcess)
If LCase(Mid(Text1, temp + 1)) = "bw.exe" Then
aldRunning = True
MsgBox "BaaN is Already Running", vbInformation, "Thwart Applications"
Exit Do
End If
Loop
Call CloseHandle(hSnapShot)
If Not aldRunning Then
Dim appPath As String
appPath = regQuery_A_Key(HKEY_LOCAL_MACHINE, "Software\Baan\baan", "BSE")
Shell (appPath & "\bin\bw.exe"), vbNormalFocus
End If
Unload Me
End Sub

suhas-mahajan
13th January 2007, 13:39
Hi..

This is with reference to - http://www.baanboard.com/baanboard/showthread.php?t=14355&highlight=VB

regards,

-Suhas