开发者

Managed analogue for SendMessage API function or How to send a message to window from C#?

开发者 https://www.devze.com 2023-04-09 11:19 出处:网络
I want to send a window message from开发者_JAVA百科 one application (console) to the wondow of another application. I can use WinAPI functions SendMessage or PostMessage, but may be there is managed w

I want to send a window message from开发者_JAVA百科 one application (console) to the wondow of another application. I can use WinAPI functions SendMessage or PostMessage, but may be there is managed way to do it?


There is no managed alternative to that but you can easily P/Invoke with:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

private void button1_Click(object sender, EventArgs e)
{
    SendMessage(this.Handle, COMMAND_HERE, PARAM_HERE, 0);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消