苏飞论坛

标题: C#如何获取本应用程序的窗口句柄 [打印本页]

作者: mengzhisuoliu    时间: 2014-4-28 17:22
标题: C#如何获取本应用程序的窗口句柄
假设我的工程做了一个winform 有一个窗体类是集成于Window 的,叫MainWindow现在我需要获取HWND 这个窗口句柄,请问怎么获取呢?C#新手
作者: LinnMM    时间: 2014-4-28 20:36
用api呗,自己去查资料
作者: sandy1231    时间: 2014-4-29 08:53
[C#] 纯文本查看 复制代码
[DllImport("User32.dll", EntryPoint = "FindWindow")]            private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);


IntPtr hWnd = FindWindow(null, "窗口标题");




欢迎光临 苏飞论坛 (http://www.sufeinet.com/) Powered by Discuz! X3.4