I need to get the 30th bit of the lParam param passed with the WM_KEYDOWN message. This bit as written here allows me to know if the key was pressed before. Is this code right to get it?
(lParam >> 30) & 1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would just use
lParam & 0x40000000. If that’s non-zero, thenb30was set (I consider that the thirty first bit of the thirty two, by the way). And there’s more likelihood that it will be a{logical-and, compare}operation rather than{shift, logical-and, compare}.Mind you, there’s a good chance that a decent compiler would generate the more efficient code anyway even if you used
(lParam >> 30) & 1but why take the risk?