关于ToAscii的简单问题!!C/C++ codeBYTE KS[256]memset(KS,0,256)int aGetKeyboardState(KS)//这个
关于ToAscii的简单问题!!
- C/C++ code
BYTE KS[256]; memset(KS,'0',256); int a=GetKeyboardState(KS);//这个倒是不为0 可是我发现这个ks数组好多被置1 WORD w; UINT scan; int i=ToAscii(wParam,scan,KS,&w,1);//发现这个老是返回0 最后一个参数为0也不行 我看 //了下 当我按8的时候wParam是38 貌似就是asc码不过小写的 //全都显示不了 只能大写
[解决办法]
给数组一个结束符吧。
[解决办法]
GetKeyboardState
The GetKeyboardState function copies the status of the 256 virtual keys to the specified buffer.
-------------------------------------------------
ToAscii
The ToAscii function translates the specified virtual-key code and keyboard state to the corresponding character or characters. The function translates the code using the input language and physical keyboard layout identified by the given keyboard layout handle.
int ToAscii(
UINT uVirtKey, // virtual-key code
UINT uScanCode, // scan code
PBYTE lpKeyState, // key-state array
LPWORD lpChar, // buffer for translated key
UINT uFlags // active-menu flag
);
Return Values
If the specified key is a dead key, the return value is negative. Otherwise, it is one of the following values.
Value Meaning
0 The specified virtual key has no translation for the current state of the keyboard.
-------------------------------------------------
ToAscii传参不正确吧,也许想要的东西在w里面。
LZ需要的是MSDN。
