Click to See Complete Forum and Search --> : Finding out if a program is running
Gaming_World
Nov 30th, 2001, 09:15 PM
How do you find out if a program is running? In this case, it is another app I made.
Osiris
Nov 30th, 2001, 09:45 PM
Originally posted by Gaming_World
How do you find out if a program is running? In this case, it is another app I made.
using API
X <> Findwindow("class", vbNullString)
if X = 0 Then Call Sendmessage(X, WM_Close, 0, 0)
there was this same question b4, but i dont know how to
hyperlink threads so i just wrote it over..:p
Osiris
Nov 30th, 2001, 09:46 PM
err wrong again
X = Findwindow("class", vbNullString)
if X <> 0 Then Call Sendmessage(X, WM_Close, 0, 0)
Gaming_World
Nov 30th, 2001, 10:32 PM
How do you find out the class of the object?
TiPeRa
Dec 2nd, 2001, 09:16 AM
Err, Gaming_World didn't say anything about closing the app!
X = Findwindow("class", "title")
If X <> 0 then MsgBox "The app is running!"
Class is the class, if you wrote it in vb it is something like ThunderMain.
Title is the title of the app, such as Project1 or SpaceInvaders2
bignell
Dec 3rd, 2001, 08:05 AM
and if you want to activate that program, use this code (found on vb-world):
lngTemp = ShowWindowAsync(hWnds(1), SW_RESTORE)
SetWindowPos hWnds(1), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
sWindowText = Space(255)
lngTemp = GetWindowText(hWnds(1), sWindowText, 255)
sWindowText = Left(sWindowText, lngTemp)
AppActivate sWindowText
SetWindowPos hWnds(1), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End
hWnds(1) is the address given back by findWindow API
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.