Click to See Complete Forum and Search --> : How to check for runnig application if not running restart it
Aaron
November 11th, 1999, 01:24 PM
OK I am in a dilemma. I need to make or get a program that sees if a certain application is running on a system. If it is than nothing happens. If It is not then I need it to be started. It needs to run under NT. I would also like to run the program(the newly created one) in the systray "if that is possible with Visual Basic"... The program would need to be on a timer and check every so often... Any help would be most appreciated.
Lothar Haensler
November 12th, 1999, 02:07 AM
if the application you want to start has a window, you could use the FindWindow API to check if the app is running.
if it's a COM Server (like Excel), you could use GetObject to check if it is running.
To place your app into the system tray check out Aaron Young's post from today.
Aaron
November 12th, 1999, 08:20 AM
Thanks.. Now where can I find out more information about those Windows API calls?
Do you know of any good VB books that would be useful?
Lothar Haensler
November 12th, 1999, 09:30 AM
to get the Declare statements for these APIs use the Api Viewer add-in,
to get more descriptions check MSDN - platform SDK.
Dan Appleman has written several books for VB programmers that want to make use of API functions.
FindWindow is fairly easy to use:
private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (byval lpClassName as string, byval lpWindowName as string) as Long
private Sub Command1_Click()
If FindWindow(vbNullString, "Unbenannt - Editor") then
MsgBox "notepad running"
End If
End Sub
this code checks for a German version of Notepad (with no file opened).
The class name argument is more reliable, but you need to get that via a spy utility like Spy++ that comes with Visual Studio Tools.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.