Windows 7 x64에서 C#으로 GetAsyncKeyState (i)를 사용하여 키를 가져 오려고합니다. x86에서 완벽하게 작동합니다. 내 코드는 다음과 같습니다.Windows 7 x64에서 GetAsyncKeyState
[DllImport("user32.dll")]
public static extern int GetAsyncKeyState(long vKey);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
search = false;
int key_my;
for (i = 0; i < 255; i++)
{
key_my = GetAsyncKeyState(i); // this should return -3.... but it does 46...........
if (key_my == (System.Int16.MinValue + 1))
{ search = true; break; }
}
if (search == true)
{
...//using if to keys here.
}
IDEA?
VB6 선언입니다. 올바른 것을 찾으려면 pinvoke.net을 사용하십시오. –