Are the words "low word" and "high word" WParam changed in 64-bit code?

I am trying to process a WM_XBUTTONUP message that is associated with additional mouse buttons on some mice. The SDK documentation states that the low word wParam contains virtual key information and that the high word holds the button down. I understand how this works in 32-bit code, but in 64-bit code wParam is a 64-bit unsigned integer. I saw code that uses Lo (msg.wparam) and Hi (msg.wparam). Does this code still work in 64 bit or something needs to be changed? In other words, does the definition of a “high word” change from 32 to 64 bits?

+4
source share
2 answers

Any code that uses Lo()and Hi()incorrect, because these functions return the bytes of low and high-order a Word.


The MSDN documentation reports the following:

Use the following code to get information in the wParam parameter:

fwKeys = GET_KEYSTATE_WPARAM (wParam); 
fwButton = GET_XBUTTON_WPARAM (wParam);

These macros are defined in the header files as:

#define GET_KEYSTATE_WPARAM(wParam)     (LOWORD(wParam))
#define GET_XBUTTON_WPARAM(wParam)      (HIWORD(wParam))

In turn, LOWORDthey are HIWORDdefined as follows:

#define LOWORD(_dw)     ((WORD)(((DWORD_PTR)(_dw)) & 0xffff))
#define HIWORD(_dw)     ((WORD)((((DWORD_PTR)(_dw)) >> 16) & 0xffff))

These macros are designed to perform the correct task when compiling into 32-bit and 64-bit code.

In Delphi, a block Windowscontains translations LOWORDand HIWORDthat perform the same tasks, although they are implemented somewhat differently. Therefore, I would perform the following functions:

function GET_KEYSTATE_WPARAM(wParam: WPARAM): Word; inline;
function GET_XBUTTON_WPARAM(wParam: WPARAM): Word; inline;

....

function GET_KEYSTATE_WPARAM(wParam: WPARAM): Word;
begin
  Result := LoWord(wParam);
end;

function GET_XBUTTON_WPARAM(wParam: WPARAM): Word;
begin
  Result := HiWord(wParam);
end;
+3
source

. Lo Hi 16- , 32- . , LoWord HiWord.

64- 64- Int64Rec:

case Int64Rec(Msg.WParam).Lo of...

+4

Source: https://habr.com/ru/post/1544764/


All Articles