我正在使用User32 SendMessage
函数将原始键盘输入发送到我的API。
拦截SendMessage
调用的函数是WndProc
函数。我需要从调用SendMessage
的地方接收此数据。我曾尝试设置message.Result
并将SendMessage
函数保存为一个int,但是每次它等于0时,如何获得此返回数据?
调用函数
[DllImport("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, int wParam, ref Rawkeyboard lParam);
public void SomeFunction(...){
int result = SendMessage(Hook, 0x1230FF, 0, ref lParamKeyboard).ToInt32(); // Send data
Console.WriteLine(result);
}
回复通话
protected override void WndProc(ref Message message){
switch (message.Msg){
case 0x1230FF: {
message.Result = (IntPtr)6; // Set result as 6 (just for testing)
}
break;
}
base.WndProc(ref message);
}