GetWindowThreadProcessId Function
GetWindowThreadProcessId Function

The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window.

Syntax

DWORD GetWindowThreadProcessId(      
    HWND hWnd,     LPDWORD lpdwProcessId );

Parameters

hWnd
[in] Handle to the window.
lpdwProcessId
[out] Pointer to a variable that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable; otherwise, it does not.

Return Value

The return value is the identifier of the thread that created the window.

Function Information

Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systems Windows 95, Windows NT 3.1

See Also

Windows Overview
Community Content

vb.net syntax
Added by:dmex
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Public Shared Function GetWindowThreadProcessId(ByVal handle As IntPtr, <Out> ByRef processId As Integer) As Integer End Function
C# syntax
Added by:dmex
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
public static extern int GetWindowThreadProcessId(HandleRef handle, out int processId);
GetWindowThreadProcessId behavior if hWnd is invalid
Added by:DDeBen
GetWindowThreadProcessId returns 0 and the variable pointed to by lpdwProcessId
is not modifed if the handle hWnd is not valid. GetLastError() returns 87 (ERROR_INVALID_PARAMETER).
© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View