VB and VBA Users Source Code: Obtaining the Process Id from a window handle
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Obtaining the Process Id from a window handle
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, April 12, 2005
Hits:
2010
Category:
Windows API
Article:
Below is the source code which returns you the process id for a given window handle. Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long 'Purpose : Returns the process id for the given window handle. 'Inputs : lHwndWindow The handle of the window to return the process id of. 'Outputs : Returns the handle of process that owns the specified window handle. 'Author : Andrew Baker 'Date : 01/11/2000 13:17 'Notes : 'Revisions : 'Assumptions : Function GetProcessIdFromWindow(lHwndWindow As Long) As Long Dim lProcId As Long If lHwndWindow <> 0 Then 'Get the process ID from the window handle Call GetWindowThreadProcessId(lHwndWindow, lProcId) GetProcessIdFromWindow = lProcId Else 'Invalid window handle GetProcessIdFromWindow = 0 End If End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder