旅途

如果想飞得高,就该把地平线忘掉

findwindow 函数

DllImport("user32.dll")]
 private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
这里再声明一下FindWindowEx 函数。

 //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());
     }
 }

posted on 2007-07-21 18:18 旅途 阅读(948) 评论(0)  编辑 收藏 引用 所属分类: 深入windows


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理