C# 给指定应用程序发送消息
2013-01-16 19:16
239 查看
public partial class FrmMain : Form { public FrmMain() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { var procecess = Process.GetProcessesByName("SSDS"); if (procecess.Length <= 0) { procecess = Process.GetProcessesByName("SSDS.vshost"); } if (procecess.Length <= 0) { MessageBox.Show("请打开程序SSDS"); return; } var msgId = Convert.ToInt32(textBox1.Text); var ssdProcess = procecess[0]; //发消息 PostMessage(ssdProcess.MainWindowHandle, (uint)msgId, IntPtr.Zero, IntPtr.Zero); //等待退出 ssdProcess.WaitForExit(); //读数据 MessageBox.Show(File.ReadAllText("data.txt")); } catch (Exception ex) { MessageBox.Show(ex.Message); } } [DllImport("User32.dll")] static extern IntPtr PostMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam); }
相关文章推荐
- 使用C#在应用程序间发送消息
- 用C#调用Windows API向指定窗口发送按键消息
- 使用C#在应用程序间发送消息
- 使用C#在应用程序间发送消息
- 使用C#在应用程序间发送消息
- C# 向指定线程发送消息
- [转] C#中发送消息给指定的窗口,以及接收消息
- C#实现在应用程序间发送消息的方法示例
- 使用C#在应用程序间发送消息
- C# 怎样截取系统向应用程序发送的消息
- 使用C#在应用程序间发送消息
- 使用C#在应用程序间发送消息
- C# 向指定的进程发送消息
- windows api学习笔记-给指定的应用程序发送消息
- C# 给指定应用程序发送Windows Message
- C#中发送消息给指定的窗口,以及接收消息
- 应用程序间发送消息 c# SendMessage WM_COPYDATA
- 使用C#在应用程序间发送消息
- 使用C#在应用程序间发送消息
- 使用C#在应用程序间发送消息(转)