public static extern int FindWindow (string lpClassName,string lpWindowName);
//找到一个窗口的进程ID,第一个参数为进程的类名,第二个为进程的窗口标题。
[DllImport("user32.dll", EntryPoint="GetWindowThreadProcessId")]
public static extern int GetWindowThreadProcessId (int hWnd,ref int lpWindowName);
//第一个参数为进程的ID,第二个参数为返回的线程ID.
[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
//将一个窗口设为另一个窗口的孩子
[DllImport("user32", EntryPoint="FindWindow")]
public static extern int FindWindowA(string lpClassName, string lpWindowName);
[DllImport("user32")]
public static extern int SetParent(int hWndChild, int hWndNewParent);
[DllImport("user32.dll",CharSet=CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hwnd,int wMsg,IntPtr wParam,IntPtr lParam);
BOOL PostMessage(
UINT message,
WPARAM wParam = 0,
LPARAM lParam = 0
);
Parameters
message
Specifies the message to be posted.
wParam
Specifies additional message information. The content of this parameter depends on the message being posted.
lParam
Specifies additional message information. The content of this parameter depends on the message being posted.
Return Value
Nonzero if the message is posted; otherwise 0.
Remarks
Messages in a message queue are retrieved by calls to the GetMessage or PeekMessage Windows function.
The Windows PostMessage function can be used to access another application.
一个窗口截获Window的消息,可以实现IMessageFilter接口,并实现public bool PreFilterMessage(ref Message m)函数。
浙公网安备 33010602011771号