Results 1 to 7 of 7

Thread: Find ProcessID from hWnd...?

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Find ProcessID from hWnd...?

    I have used FindWindow to get the specific handle of a form I would like to locate...once I have the forms hWnd, how do i find what the ProcessID is for this form using the retrieved hWnd?

    Woka

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    GetWindowThreadProcessId() ?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    You might want to be careful, it has a high badger index...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, _
    2.                                                                 lpdwProcessId As Long) _
    3.                                                                 As Long
    4.  
    5. Private Sub Command1_Click()
    6. Dim lProcessID As Long
    7.  
    8.     Call GetWindowThreadProcessId(hwnd, lProcessID)
    9.     MsgBox lProcessID
    10.    
    11. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  7. #7

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632
    I was doing:
    VB Code:
    1. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, _
    2.                                                                 lpdwProcessId As Long) _
    3.                                                                 As Long
    4.  
    5. Private Sub Command1_Click()
    6. Dim lProcessID As Long
    7.  
    8.     lProcessID = GetWindowThreadProcessId(hwnd, ByVal 0&)
    9.     MsgBox lProcessID
    10.  
    11. End Sub
    Whhhhhhooooops

    Cheers....

    Plenderj...I now have a fully functional Client ----via API---> Client Connection -----via TCP/IP-----> Server Application



    Woka

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