Results 1 to 5 of 5

Thread: FindWindow ?

  1. #1

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Question FindWindow ?

    I would like to search threw all running programs (hidden or not) for my application named "Bob"...

    I think the function I should use is FindWindow, however, I can't get any exemples on how to use it ... Could anyone please post a sample code for this?

    The function:

    VB Code:
    1. Declare Function FindWindow Lib "user32" Alias _
    2. "FindWindowA" (ByVal lpClassName As String, _
    3. ByVal lpWindowName As String) As Long


    or

    VB Code:
    1. Declare Function FindWindowWithNull Lib "user32" -
    2. Alias "FindWindowA" (ByVal lpClassName As Long, _
    3. ByVal lpWindowName As String) As Long

    So... waiting for an answer

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    is you app called bob.exe or is the caption of the window "bob" because findwindow searches by its 2 params.. 1 is the class, and 2 (which is what you will probably use) is the windows caption name... now you can also search each process for the actual exe name if that is what you are looking for.. but that envolves some more api work to enum the processes

  3. #3

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655
    Originally posted by kleinma
    is you app called bob.exe or is the caption of the window "bob" because findwindow searches by its 2 params.. 1 is the class, and 2 (which is what you will probably use) is the windows caption name... now you can also search each process for the actual exe name if that is what you are looking for.. but that envolves some more api work to enum the processes
    App Window: "bob",
    App Exe Name "BobName.exe"
    App Exe Path "C:\BobPath"

    ...

    As you might have noticed, I just want a sample code

    ...

    The only thing I want to know: Is it running?

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2.  
    3.  
    4. Private Sub Command1_Click()
    5.     if FindWindow(vbNullString,"bob") = 0 then
    6.         msgbox "BOB NOT RUNNING"
    7.     else
    8.         msgbox "BOB IS RUNNING"
    9.     end if
    10. End Sub

  5. #5

    Thread Starter
    Fanatic Member Ruku's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    655

    Talking Now your talking!

    Originally posted by kleinma
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2.  
    3.  
    4. Private Sub Command1_Click()
    5.     if FindWindow(vbNullString,"bob") = 0 then
    6.         msgbox "BOB NOT RUNNING"
    7.     else
    8.         msgbox "BOB IS RUNNING"
    9.     end if
    10. End Sub
    Thanks!

    Using VB.NET 2005/.NET 2.0, NetBeans IDE 5, Fujitsu Cobol85,
    Website: http://DreamForgery.com

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