VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Get window handlle (hWnd) from process ID

Evripidis  (1 Submission)   Windows API Call/Explanation   Intermediate   Wed 3rd February 2021

A module for retrieving the handle number (hWnd) of a window providing only the process id number (PID). This code is seeking handles that match the given PID and returns the hanlde that refers to a visible window. But, since not all the processes running are windowed or some processes may have multiple windows, may not work for every case.

API Declarations
Private Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal Hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" _
(ByVal Hwnd As Long) As Long

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal Hwnd As Long, ByVal wIndx As Long) As Long

Private Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal Hwnd As Long, lpdwProcessId As Long) As Long

Rate Get window handlle (hWnd) from process ID (6(6 Vote))
Get window handlle (hWnd) from process ID.bas

Get window handlle (hWnd) from process ID Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters