1 History of these two functions
Setwindowlongptr () and getwindowlongptr () are used to access specific blocks of data in the Window object, which is also used to replace SetWindowLong () and GetWindowLong (), which are obsolete APIs. The reason why the API is obsolete without the PTR end is that it cannot accommodate 64-bit platforms, and the problem with MSDN that this article points out is that it is not updated to accommodate the 64 platform.
2 where the error is
The following is an excerpt from the official MSDN website (January 13, 2015).
long_ptr WINAPI setwindowlongptr (_in_ hwnd HWND, _in_ int
NIndex, _in_ long_ptr dwnewlong);
nIndex [in]
Type: int
The zero-based offset to the value to is set. Valid values is in the range zero through the number of bytes of extra window memory, minus the size of a integer. To set any other value, specify one of the following values.
To access the extra data for the Window object, the two functions must request additional bytes at registerclass () by Wndclass.cbwndextra. Parameter nindex refers to the reading and writing of sizeof (long_ptr) bytes from the nindex byte of an additional block of data when the function is used to read and write to the Window object. So whether it is legal depends on whether sizeof (LONG_PTR) bytes starting with nindex are all in the additional chunks of the form object. That is, 0 to (extra window memory)-sizeof (LONG_PTR). MSDN, however, simply writes it as a 0 to (extra window memory)-sizeof (int).
For 32-bit programs, sizeof (long_ptr) = = sizeof (int), the MSDN description is no problem. However, for a 64-bit program, sizeof (LONG_PTR) = 8, and sizeof (int) = 4, the two are no longer equal.
Perhaps the word integer in MSDN here refers to a platform-dependent integer, but most programmers will match the integer in this and the C + + language with Int. In this way, it will still cause a little trouble.
??
Description Error in MSDN about SETWINDOWLONGPTR and GETWINDOWLONGPTR functions