When writing code that will used for both 32-bit and 64-bit Windows, there are functions that you should use so that you will not have to change any code during the switch. These functions work in both modes. One of them is the SetWindowLongPtr Function.
As described in Rules for Using Pointers, the way you should update your code is like the following:
On my system, MSVC++ .NET 2003 (version 7.1) compiling for 32-bit mode with the /Wp64 (Detect 64-Bit Portability Issues) switch on, the new code does not compile smoothly. I get the following warning:Code:For example, the following code does not compile: SetWindowLong(hWnd, GWL_WNDPROC, (LONG)MyWndProc); It should be changed as follows: SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)MyWndProc);
The code compiles fine when I turn the /Wp64 switch off.Code:warning C4244: 'argument' : conversion from 'LONG_PTR' to 'LONG', possible loss of data




Reply With Quote