WPARAM 和 LPARAM是windows消息响应机制中提供的两个用来传递消息的形参。
类型定义如下:
typedef UINT WPARAM;
typedef LONG LPARAM;
其中:
(1)wparam是一个UINT/word类型的变量,lparam是一个long类型的变量。在win32 API中二者长度一样。
(2)由于系统中地址的长度与lparam长度相同,因此在传递地址时通常使用lparam。例如需要在其他窗口过程中调用的函数指针。
(3)但是由于并没有强制规定这两个参数具体用来传递什么信息,所以不同的函数调用中意义可能不同需要具体去查参考文档。
下附MSDN中windows 数据类型:
Type | Definition |
Atom. For more information, see Atoms. | |
Boolean variable (should be TRUE or FALSE). | |
Boolean variable (should be TRUE or FALSE). | |
Byte (8 bits). | |
Calling convention for callback functions. | |
8-bit Windows (ANSI) character. For more information, see Character Sets Used By Fonts. | |
Red, green, blue (RGB) color value (32 bits). See COLORREF for information on this type. | |
Variable whose value is to remain constant during execution. | |
Critical-section object. For more information, see Critical Section Objects. | |
32-bit unsigned integer. | |
Unsigned long type for pointer precision. Use when casting a pointer to a long type to perform pointer arithmetic. | |
32-bit unsigned integer. | |
64-bit unsigned integer. | |
Floating-point variable. | |
Handle to an accelerator table. | |
Handle to an object. | |
Handle to a bitmap. | |
Handle to a brush. | |
Handle to a dynamic data exchange (DDE) conversation. | |
Handle to a DDE conversation list. | |
Handle to a cursor. | |
Handle to a device context (DC). | |
Handle to DDE data. | |
Handle to a desktop. | |
Handle to an internal drop structure. | |
Handle to a deferred window position structure. | |
Handle to an enhanced metafile. | |
Handle to a file opened by OpenFile, not CreateFile. | |
Handle to a font. | |
Handle to a GDI object. | |
Handle to a global memory block. | |
Handle to a hook. | |
Handle to an icon. | |
Handle to an image list. | |
Handle to input context. | |
Handle to an instance. | |
Handle to a registry key. | |
Input locale identifier. | |
Handle to a local memory block. | |
Handle to a menu. | |
Handle to a metafile. | |
Handle to a module. | |
Handle to a display monitor. | |
Handle to a palette. | |
Handle to a pen. | |
Handle to a region. | |
Handle to a resource. | |
Handle to a DDE string. | |
Handle to a window station. | |
Handle to a window. | |
32-bit signed integer. | |
Signed integral type for pointer precision. Use when casting a pointer to an integer to perform pointer arithmetic. | |
32-bit signed integer. | |
64-bit signed integer. | |
Language identifier. For more information, see Locales. | |
Locale identifier. For more information, see Locales. | |
Locale information type. For a list, see Locale and Language Information | |
32-bit signed integer. | |
Signed long type for pointer precision. Use when casting a pointer to a long to perform pointer arithmetic. | |
32-bit signed integer. | |
64-bit signed integer. | |
64-bit signed integer. | |
Message parameter. | |
Pointer to a BOOL. | |
Pointer to a BYTE. | |
Pointer to a COLORREF value. | |
Pointer to a CRITICAL_SECTION. | |
Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. | |
Pointer to a constant of any type. | |
Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. | |
Pointer to a DWORD. | |
Pointer to a HANDLE. | |
Pointer to an INT. | |
Pointer to a LONG. | |
Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. | |
Pointer to any type. | |
Pointer to a WORD. | |
Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. | |
Signed result of message processing. | |
Locally unique identifier. | |
Pointer to a BOOL. | |
Pointer to a BOOL. | |
Pointer to a BYTE. | |
Pointer to a CHAR. | |
Pointer to a CRITICAL_SECTION. | |
Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. | |
Pointer to a constant WCHAR. | |
Pointer to a constant null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. | |
Pointer to a DWORD. | |
Pointer to a FLOAT. | |
Pointer to a HANDLE. | |
Pointer to an HKEY. | |
Pointer to an INT. | |
Pointer to an LCID. | |
Pointer to a LONG. | |
Pointer to a LUID. | |
32-bit pointer. On a 32-bit system, this is a native pointer. On a 64-bit system, this is a truncated 64-bit pointer. | |
64-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer. | |
Pointer to a SHORT. | |
Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts. | |
Pointer to a TBYTE. | |
Pointer to a TCHAR. | |
Pointer to a UCHAR. | |
Pointer to a UINT. | |
Pointer to a ULONG. | |
Pointer to a USHORT. | |
Pointer to any type. | |
Pointer to a WCHAR. | |
Pointer to a WORD. | |
Pointer to a null-terminated string of 16-bit Unicode characters. For more information, see Character Sets Used By Fonts. | |
Security access mask for registry key. | |
Handle to a service control manager database. For more information, see SCM Handles. | |
Handle to a service control manager database lock. For more information, see SCM Handles. | |
Handle to a service status value. For more information, see SCM Handles. | |
Short integer (16 bits). | |
The maximum number of bytes to which a pointer can point. Use for a count that must span the full range of a pointer. | |
Signed SIZE_T. | |
Unsigned CHAR. | |
Unsigned INT. | |
Unsigned INT_PTR. | |
Unsigned INT32. | |
Unsigned INT64. | |
Unsigned LONG. | |
Unsigned LONG_PTR. | |
Unsigned LONG32. | |
Unsigned LONG64. | |
64-bit unsigned integer. | |
Unsigned attribute. | |
Unsigned SHORT. | |
Any type. | |
16-bit Unicode character. For more information, see Character Sets Used By Fonts. | |
Calling convention for system functions. | |
16-bit unsigned integer. | |
Message parameter. |