CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 1999
    Posts
    21

    How to check for runnig application if not running restart it

    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.


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: How to check for runnig application if not running restart it

    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.



  3. #3
    Join Date
    Feb 1999
    Posts
    21

    Re: How to check for runnig application if not running restart it

    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?


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: How to check for runnig application if not running restart it

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured