Robert,
>According to MSDN, I should be using the 64-bit compatible SetWindowsLongPtr
>function instead of SetWindowsLong. SetWindowsLongPtr is defined as:
[quoted text clipped - 3 lines]
> LONG_PTR dwNewLong
>);
On Win32, SetWindowLongPtr is just an alias for SetWindowLong, so you
have to call the latter function.
Public Declare Function SetWindowLongPtr Lib "user32" Alias
"SetWindowLong" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal
dwNewLong As IntPtr) As IntPtr
>Specifically, MSDN defines a LONG_PTR as being a signed 64-bit integer.
Not on Win32 it isn't. The size of LONG_PTR is 32-bit on Win32, and
64-bit on Win64.
>Does this map directly to a Long (Int64) data type, or is it preferable (or
>necessary) to use an IntPtr data type instead?
Use (U)IntPtr for any pointer-sized integers.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Robert Jacobson - 01 Sep 2003 21:08 GMT
Thanks Mattias. For what it's worth, I was getting an error message with
your definition --
"Unable to find an entry point named SetWindowLong in DLL user32." It
worked after I inserted an "Auto" into the declaration:
Public Declare Auto Function SetWindowLongPtr Lib "user32" Alias
"SetWindowLong" (ByVal hWnd As IntPtr, ByVal nIndex As Integer, ByVal
dwNewLong As IntPtr) As IntPtr
(I don't know why the "Auto" should matter, since I'm not passing strings.)
However, this just brings back to using SetWindowLong. Does this mean that
I need to have two separate declarations, one for 32-bit OS's, and another
for 64-bit? (And with some sort of compiler or JIT switch to choose the
correct one?) For future compatibility, I'd like to ensure that my program
will run correctly on either platform.