Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要通过 WM_KEYDOWN 消息获取 lParam 参数的第 30 位。写在这里的这一位让我知道之前是否按下了该键。这段代码正确吗?
(lParam >> 30) & 1
我只会使用lParam & 0x40000000. 如果那不是零,则b30设置(顺便说一下,我认为是三十二的第三十位)。而且它更有可能是一次{logical-and, compare}手术,而不是{shift, logical-and, compare}.
lParam & 0x40000000
b30
{logical-and, compare}
{shift, logical-and, compare}
请注意,即使您使用了体面的编译器,也很有可能生成更高效的代码,(lParam >> 30) & 1但为什么要冒险呢?