您的位置:首页 > 其它

如何声明 findwindow 函数。

2004-10-11 10:13 190 查看
[DllImport("user32.dll")]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

//Open Up blank Notepad First !
string lpszParentClass = "Notepad";
string lpszParentWindow = "Untitled - Notepad";
string lpszClass = "Edit";

IntPtr ParenthWnd = new IntPtr(0);
IntPtr hWnd = new IntPtr(0);
ParenthWnd = FindWindow(lpszParentClass,lpszParentWindow);
if (ParenthWnd.Equals(IntPtr.Zero))
Console.WriteLine("Notepad Not Running");
else
{
hWnd = FindWindowEx(ParenthWnd,hWnd,lpszClass,"");
if (hWnd.Equals(IntPtr.Zero))
Console.WriteLine("What the F??? Notepad doesn't have an edit component ?");
else
{
Console.WriteLine("Notepad Window: " + ParenthWnd.ToString());
Console.WriteLine("Edit Control: " + hWnd.ToString());
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: