编程语言

img hycapril

如何声明 findwindow 函数。

发表于2004/10/11 10:13:00  1107人阅读

分类: c#技术

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

阅读全文
0 0

相关文章推荐

img
取 消
img