WPARAM and LPARAM parameters

前端 未结 5 1325
野趣味
野趣味 2020-12-29 07:49

When passing a value to a function that takes both a WPARAM and a LPARAM parameter, does it matter on which of them I pass it? Someone told me that if I use Windows x64 I sh

5条回答
  •  北海茫月
    2020-12-29 08:19

                     | for handles     | for pointers  |
                     | and numbers     |               |
    | OS             | WPARAM          | LPARAM        |
    |----------------|-----------------|---------------|
    | 16-bit Windows | 16-bit unsigned | 32-bit signed |
    | 32-bit Windows | 32-bit unsigned | 32-bit signed |
    | 64-bit Windows | 64-bit unsigned | 64-bit signed |
    

    The history of its definition has changed over the years.

    WINDOWS.H (Windows 2.03 SDK, c. 1988)

    /* Message structure */
    typedef struct tagMSG {
        HWND hwnd;
        WORD message;
        WORD wParam;
        LONG lParam;
        DWORD time;
        POINT pt;
    } MSG;
    

    WinDefs.h (c. 1999)

    /* Types use for passing & returning polymorphic values */
    typedef UINT WPARAM;
    typedef LONG LPARAM;
    typedef LONG LRESULT;
    

    WinDef.h (c. 2005)

    /* Types use for passing & returning polymorphic values */
    typedef UINT_PTR            WPARAM;
    typedef LONG_PTR            LPARAM;
    typedef LONG_PTR            LRESULT;
    

    Bonus Reading

    • What do the letters W and L stand for in WPARAM and LPARAM? archive (W is for unsigned 16-bit WORD, and L is for signed 32-bit LONG)
    • What happens to WPARAM, LPARAM, and LRESULT when they travel between 32-bit and 64-bit windows? archive (the unsigned is zero-extended, the signed is sign-extended)

提交回复
热议问题