|
-
October 1st, 2001, 10:17 AM
#3
Re: Running only 1 instance
Here is a simple prigram that enters into a TextBox all available runnning programs.
Start a new project. Add a textbox to the form.
Add a module
paste this code into the appropriate spot.
' In the form
'
option Explicit
'Add this code to a form
private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'set the form's graphics mode to persistent
me.AutoRedraw = true
'call the Enumwindows-function
Dim x
EnumWindows AddressOf EnumWindowsProc, byval 0&
End Sub
'
'
' In the module
'
option Explicit
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
'Add this code to a module
Declare Function EnumWindows Lib "user32" (byval lpEnumFunc as Long, byval lParam as Long) as Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (byval hwnd as Long, byval lpString as string, byval cch as Long) as Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (byval hwnd as Long) as Long
public Function EnumWindowsProc(byval hwnd as Long, byval lParam as Long) as string
Dim sSave as string, Ret as Long
Ret = GetWindowTextLength(hwnd)
sSave = Space(Ret)
GetWindowText hwnd, sSave, Ret + 1
If Trim(sSave) <> "" then _
frmIsMeRunning.Text1 = frmIsMeRunning.Text1 & sSave & vbCrLf
'continue enumeration
EnumWindowsProc = true
End Function
'
Run the program. Use its output to compare against your app name.
John G
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|