Results 1 to 3 of 3

Thread: Grabbing hWnd's from running programs.

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Ontario, Canada.
    Posts
    7
    The Subject says it all.
    How do I do it?
    Thanks!
    Yoinkster

  2. #2
    Guest
    Use the FindWindow API.

    The following example will get the hWnd of Calculator and Send a message to close it.

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
    
        'Get the Handle of Calculator.
        MyHwnd = FindWindow(CLng(0), "Calculator")
        SendMessage MyHwnd, WM_CLOSE, 0&, 0&
        
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Location
    Ontario, Canada.
    Posts
    7
    Thanks, Megatron.
    You seem to be quite the big Guru around here
    Yoinkster

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