I know I'm being lazy here and I should trawl the header files for myself, but what are the actual types for LPARAM and WPARAM parameters? Are they pointers, or four byte ints? I'm doing some C# interop code and want to be sure I get it working on x64 systems.
-
1You could just right-click on `LAPARAM` and select 'Go to declaration'... – John Dibling Mar 25 '10 at 12:34
-
5@John - I could if I had a Visual C++ IDE, but I'm doing C# dev. Finding the actual definitions of these things is annoyingly time consuming if you're not working with a C++ IDE. I just had to manually follow a trail of several typedefs to find out what was at the end of HACMDRIVERID. If the MSDN documentation was properly hyperlinked it would have saved me a lot of bother. – Mark Heath Mar 25 '10 at 14:19
-
2@Mark: Then why is this question marked C++? – John Dibling Mar 25 '10 at 15:26
-
@Mark: Or why not just create a C++ project, type in "LPARAM" and right click there? – John Dibling Mar 25 '10 at 15:26
-
1@John - because its the C++ guys who know that stuff off the top of their heads. I know I did 8 years ago, but I've been living in a managed world for a long time now! But good point, I should probably make myself a C++ project just for this purpose. – Mark Heath Mar 25 '10 at 15:30
-
34Might be a lazy question... On the other hand it's the top answer at google when searching for wparam, so your not the only one that want a fast answer, and now everyone gets just that! – Markus Feb 25 '13 at 09:03
-
11anon doesn’t understand the point of StackOverflow, and clearly realizes s/he is an ignoramus, hence not having the guts to put a name to his/her offensive comment. StackOverflow is not about "laziness" it about documenting things people may not understand. There is way more useful information below than trawling the headers could ever provide. Anyone who downvoted this question should leave this site and instead spend their time adding elitest *RTFM* answers on lame-programming forums. – mxcl May 28 '13 at 15:23
-
@JohnDibling what if you work with MASM32??!?!is there any `just right-click on LAPARAM and select 'Go to declaration'` – AminM Dec 21 '14 at 09:03
-
2@JesonPark: This question is tagged c#. – John Dibling Dec 21 '14 at 16:47
6 Answers
LPARAM
is a typedef for LONG_PTR
which is a long
(signed 32-bit) on win32 and __int64
(signed 64-bit) on x86_64.
WPARAM
is a typedef for UINT_PTR
which is an unsigned int
(unsigned 32-bit) on win32 and unsigned __int64
(unsigned 64-bit) on x86_64.

- 755,051
- 104
- 632
- 656
-
2@Charles Bailey: maybe I'm misunderstanding you but when you say: "__int64 (signed 64-bit) on x86" don't you mean "on x86-64" or win64 or something? I take x86 to be 32-bit. – User Oct 20 '11 at 19:12
-
2@User: Yes, it's supposed to say x86_64 which is how Microsoft now refer to amd64. – CB Bailey Oct 20 '11 at 20:43
-
Please notice that the description refers to `long` in C++. In C#, a `long` is a signed 64bit, also when compiling to 32bit. – Tobias Knauss Dec 04 '17 at 14:52
These typedefs go back to the 16-bit days. Originally, LPARAM
was a long
(signed 32-bit) and WPARAM
was a WORD
(unsigned 16-bit), hence the W and L. Due to the common practice of passing casted pointers as message parameters, WPARAM
was expanded to 32 bits on Win32, and both LPARAM
and WPARAM
were expanded to 64 bits on Win64.
In C#, you should use IntPtr
for LPARAM
and UIntPtr
for WPARAM.
Note that despite the LP
prefix, LPARAM
is not a far pointer to an ARAM
.

- 21,988
- 13
- 81
- 109

- 87,747
- 23
- 163
- 198
-
Note that the term "word" in the field of computer means a data size a CPU can process at a time (such as the size of the register) and it's related to the bus size. OTOH, `WORD` is Microsoft term, and it was the same size as "word" in the 16-bit days, but now their sizes are different. `DWORD`(32bit), and `QWORD`(64bit) have fixed sizes, too. From Wikipedia: *"Microsoft's Windows API maintains the programming language definition of WORD as 16 bits, despite the fact that the API may be used on a 32- or 64-bit x86 processor, where the standard word size would be 32 or 64 bits, respectively."* – starriet Jul 28 '22 at 11:26
-
`WPARAM` is 32-bit because handles in Win32 are 32-bit pointers, where they used to be 16-bit selectors. In 16-bit Windows, passing pointers was done via `LPARAM`. It didn't become significantly more prevalent in Win32, because it was already quite common. – user3840170 Jan 02 '23 at 08:30
LPARAM refers to a LONG_PTR and WPARAM refers to a UINT_PTR
On x86 they will be 4 bytes and on x64 they will be 8 bytes.

- 339,232
- 124
- 596
- 636
What you need my friend is http://www.pinvoke.net/

- 6,701
- 24
- 28
-
5yes, its a useful site, although very mixed quality interop conversions – Mark Heath Mar 25 '10 at 14:38
c++ in linux and windows 64bit tested, the most simple solution I found:
#define WPARAM long long unsigned int
#define LPARAM long long int

- 441
- 3
- 10