GetWindowLongPtr Function
Retrieves the value at a specified offset into the extra window memory of a window. This function is identical to GetWindowLong, except that it is designed for use with 32-bit and 64-bit applications.
Syntax
LONG_PTR GetWindowLongPtr(
HWND hWnd,
int nIndex
);
Parameters
| Parameter | Type | Description |
|---|---|---|
hWnd |
HWND |
A handle to the window. A value of NULL is invalid. |
nIndex |
int |
The zero-based offset to the value to be retrieved. Valid values are in the range zero to the number of extra bytes the application needed when creating the window. Other possible values for this parameter are:
|
Return Value
| Type | Description |
|---|---|
LONG_PTR |
If the function succeeds, the return value is the value of the 32-bit or 64-bit integer at the specified offset. If the function fails, the return value is zero. To get extended error information, call GetLastError. |
Remarks
If you are retrieving the window procedure, use the GetWindowLongPtr function with the GWLP_WNDPROC index. If you are setting the window procedure, use the SetWindowLongPtr function.
The number of extra bytes per window in the application profile is specified by the cbWndExtra member of the WNDCLASSEX structure when the window class is registered with the RegisterClassEx function.
The GWLP_HWNDNEXT, GWLP_HWNDPREV, GWLP_CHILD, GWLP_NEXTSESSION, GWLP_PREVSESSION, GWLP_ASSISTANTACTIONBARPOS, and GWLP_UNREADMESSAGECOUNT flags are not supported for use with this function.
Important
This function is used to retrieve information about a window. Be careful when modifying window data as it can lead to unexpected behavior if not handled correctly.
Requirements
| Value | |
|---|---|
| Minimum supported client | Windows Vista |
| Minimum supported server | Windows Server 2008 |
| Target Platform | Windows |
| Header | winuser.h (include windows.h) |
| Library | User32.lib |
| DLL | User32.dll |