111,126
社区成员
发帖
与我相关
我的任务
分享
using System.Runtime.InteropServices;//DLLImport
using System.Diagnostics;
//查找窗体句柄
[DllImport("user32.dll ")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
//查找子窗体句柄(包括按钮、文本框等)
[DllImport("user32.dll ")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
//发送消息(把消息放入消息队列中)
[DllImport("user32.dll ", CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
//设置窗体的标题
[DllImport("User32.dll ", CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, string lpString);
//发送消息(要等处理程序处理完,发送程序才能继续执行)
[DllImport("User32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
public static extern int SendTextMessage(IntPtr hWnd, int Msg, int wParam, string lParam);
//The SetWindowText function changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.
[DLLImport("user32.dll",EntryPoint="SetWindowText")]
public static extern bool SetWindowText( HWND hWnd, LPCTSTR lpString );
Process p=new Process();
p.StartInfo.FileName = "本机.exe";
p.Start();