{
	"id": "16bef971-fdba-48e9-ac40-50bbd5803a8e",
	"created_at": "2026-04-06T00:10:14.923909Z",
	"updated_at": "2026-04-10T03:20:23.619866Z",
	"deleted_at": null,
	"sha1_hash": "650b6a852efa4d54c5efe7af5eaa897d01585f32",
	"title": "SetWindowLongA function (winuser.h) - Win32 apps",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 61046,
	"plain_text": "SetWindowLongA function (winuser.h) - Win32 apps\r\nBy jwmsft\r\nArchived: 2026-04-05 22:27:55 UTC\r\nChanges an attribute of the specified window. The function also sets the 32-bit (long) value at the specified offset\r\ninto the extra window memory.\r\nNote  This function has been superseded by the SetWindowLongPtr function. To write code that is compatible\r\nwith both 32-bit and 64-bit versions of Windows, use the SetWindowLongPtr function.\r\nLONG SetWindowLongA(\r\n [in] HWND hWnd,\r\n [in] int nIndex,\r\n [in] LONG dwNewLong\r\n);\r\n[in] hWnd\r\nType: HWND\r\nA handle to the window and, indirectly, the class to which the window belongs.\r\n[in] nIndex\r\nType: int\r\nThe zero-based offset to the value to be set. Valid values are in the range zero through the number of bytes of extra\r\nwindow memory, minus the size of an integer. To set any other value, specify one of the following values.\r\nValue Meaning\r\nGWL_EXSTYLE\r\n-20\r\nSets a new extended window style.\r\nGWL_HINSTANCE\r\n-6\r\nSets a new application instance handle.\r\nGWL_HWNDPARENT\r\n-8\r\nSets a new owner for a top-level window.\r\nhttps://msdn.microsoft.com/library/windows/desktop/ms633591.aspx\r\nPage 1 of 4\n\nGWL_ID\r\n-12\r\nSets a new identifier of the child window. The window cannot be a top-level\r\nwindow.\r\nGWL_STYLE\r\n-16\r\nSets a new window style.\r\nGWL_USERDATA\r\n-21\r\nSets the user data associated with the window. This data is intended for use by\r\nthe application that created the window. Its value is initially zero.\r\nGWL_WNDPROC\r\n-4\r\nSets a new address for the window procedure.\r\nYou cannot change this attribute if the window does not belong to the same\r\nprocess as the calling thread.\r\n \r\nThe following values are also available when the hWnd parameter identifies a dialog box.\r\nValue Meaning\r\nDWL_DLGPROC\r\nDWLP_MSGRESULT +\r\nsizeof(LRESULT)\r\nSets the new address of the dialog box procedure.\r\nDWL_MSGRESULT\r\n0\r\nSets the return value of a message processed in the dialog box\r\nprocedure.\r\nDWL_USER\r\nDWLP_DLGPROC +\r\nsizeof(DLGPROC)\r\nSets new extra information that is private to the application, such as\r\nhandles or pointers.\r\n[in] dwNewLong\r\nType: LONG\r\nThe replacement value.\r\nType: LONG\r\nhttps://msdn.microsoft.com/library/windows/desktop/ms633591.aspx\r\nPage 2 of 4\n\nIf the function succeeds, the return value is the previous value of the specified 32-bit integer.\r\nIf the function fails, the return value is zero. To get extended error information, call GetLastError.\r\nIf the previous value of the specified 32-bit integer is zero, and the function succeeds, the return value is zero, but\r\nthe function does not clear the last error information. This makes it difficult to determine success or failure. To\r\ndeal with this, you should clear the last error information by calling SetLastError with 0 before calling\r\nSetWindowLong. Then, function failure will be indicated by a return value of zero and a GetLastError result that\r\nis nonzero.\r\nCertain window data is cached, so changes you make using SetWindowLong will not take effect until you call the\r\nSetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with\r\nthe SWP_FRAMECHANGED flag for the cache to be updated properly.\r\nIf you use SetWindowLong with the GWL_WNDPROC index to replace the window procedure, the window\r\nprocedure must conform to the guidelines specified in the description of the WindowProc callback function.\r\nIf you use SetWindowLong with the DWL_MSGRESULT index to set the return value for a message processed\r\nby a dialog procedure, you should return TRUE directly afterward. Otherwise, if you call any function that results\r\nin your dialog procedure receiving a window message, the nested window message could overwrite the return\r\nvalue you set using DWL_MSGRESULT.\r\nCalling SetWindowLong with the GWL_WNDPROC index creates a subclass of the window class used to\r\ncreate the window. An application can subclass a system class, but should not subclass a window class created by\r\nanother process. The SetWindowLong function creates the window subclass by changing the window procedure\r\nassociated with a particular window class, causing the system to call the new window procedure instead of the\r\nprevious one. An application must pass any messages not processed by the new window procedure to the previous\r\nwindow procedure by calling CallWindowProc. This allows the application to create a chain of window\r\nprocedures.\r\nReserve extra window memory by specifying a nonzero value in the cbWndExtra member of the\r\nWNDCLASSEX structure used with the RegisterClassEx function.\r\nDo not call SetWindowLong with the GWL_HWNDPARENT index to change the parent of a child window.\r\nInstead, use the SetParent function.\r\nGWL_HWNDPARENT is used to change the owner of a top-level window, not the parent of a child window.\r\nA window can have either a parent or an owner, or neither, but never both simultaneously.\r\nIf the window has a class style of CS_CLASSDC or CS_OWNDC, do not set the extended window styles\r\nWS_EX_COMPOSITED or WS_EX_LAYERED.\r\nCalling SetWindowLong to set the style on a progressbar will reset its position.\r\nFor an example, see Subclassing a Window.\r\nhttps://msdn.microsoft.com/library/windows/desktop/ms633591.aspx\r\nPage 3 of 4\n\nNote\r\nThe winuser.h header defines SetWindowLong as an alias that automatically selects the ANSI or Unicode version\r\nof this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that is not encoding-neutral can lead to mismatches that result in compilation or runtime\r\nerrors. For more information, see Conventions for Function Prototypes.\r\nRequirement Value\r\nMinimum supported client Windows 2000 Professional [desktop apps only]\r\nMinimum supported server Windows 2000 Server [desktop apps only]\r\nTarget Platform Windows\r\nHeader winuser.h (include Windows.h)\r\nLibrary User32.lib\r\nDLL User32.dll\r\nAPI set ext-ms-win-ntuser-windowclass-l1-1-0 (introduced in Windows 8)\r\nCallWindowProc\r\nConceptual\r\nGetWindowLong\r\nReference\r\nRegisterClassEx\r\nSetParent\r\nSetWindowLongPtr\r\nWNDCLASSEX\r\nWindow Classes\r\nWindowProc\r\nSource: https://msdn.microsoft.com/library/windows/desktop/ms633591.aspx\r\nhttps://msdn.microsoft.com/library/windows/desktop/ms633591.aspx\r\nPage 4 of 4",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"references": [
		"https://msdn.microsoft.com/library/windows/desktop/ms633591.aspx"
	],
	"report_names": [
		"ms633591.aspx"
	],
	"threat_actors": [],
	"ts_created_at": 1775434214,
	"ts_updated_at": 1775791223,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/650b6a852efa4d54c5efe7af5eaa897d01585f32.pdf",
		"text": "https://archive.orkl.eu/650b6a852efa4d54c5efe7af5eaa897d01585f32.txt",
		"img": "https://archive.orkl.eu/650b6a852efa4d54c5efe7af5eaa897d01585f32.jpg"
	}
}