私は、Windows 7 x64でGetAsyncKeyState(i)をC#で使用しようとしています。それは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を使います。 –