gpt4 book ai didi

c++ - GetAsyncKeyState() defn 中的 "Shouldn' t be relied upon 是什么意思

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:58:43 34 4
gpt4 key购买 nike

From MSDN :

If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; [..]

Although the least significant bit of the return value indicates whether the key has been pressed since the last query, due to the pre-emptive multitasking nature of Windows, another application can call GetAsyncKeyState and receive the "recently pressed" bit instead of your application. The behavior of the least significant bit of the return value is retained strictly for compatibility with 16-bit Windows applications (which are non-preemptive) and should not be relied upon.

在我的程序中,我只对键当前按下位置的返回值感兴趣。即,如 msdn 所定义,当最低有效位和最高有效位都已设置时 (-32767)(这就是它现在的工作方式。)。但是,我是否还必须检查 32767(没有最小信号位的值)在这种情况下,就像它说的那样,最低有效位被另一个程序截获,或者是“不可靠的”,无论这意味着什么。

最佳答案

嗯,是的,基本上。不过,只检查最高有效位而完全忽略最低有效位更容易。

must I also check for 32767 (the value without the least sig. bit)

这是不对的 - 值将为 -32768(假设二进制补码):

1000 0000 0000 0001   -32767
1000 0000 0000 0000 -32768

另见 here ;我很奇怪这个值被打包到一个 short 中,但我们开始了。

关于c++ - GetAsyncKeyState() defn 中的 "Shouldn' t be relied upon 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13547377/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com