首页 > 代码库 > Windows API中几个函数的总结
Windows API中几个函数的总结
[DllImport("User32.dll", EntryPoint = "FindWindow")] public static extern IntPtr FindWindow(String className, String captionName); [DllImport("User32.dll", EntryPoint = "FindWindowEx")] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("User32.dll", EntryPoint = "SendMessage")] public static extern string SendMessage(IntPtr hWnd, int Msg, int wParm, int lParm); [DllImport("User32.dll", EntryPoint = "GetWindowText")] public static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int cch); public IntPtr getHandleParent(string classname, string captionname) { IntPtr handle = FindWindow(classname, captionname); return handle; } public IntPtr getHandleChild(IntPtr hwndparent, string lpszclass, string lpszwindow) { IntPtr handle = IntPtr.Zero; if (hwndparent != IntPtr.Zero) { handle = FindWindowEx(hwndparent,handle,lpszclass, lpszwindow); } else { MessageBox.Show("没有找到子窗口"); } return handle; } public string getTxt(IntPtr ChildHandle) { StringBuilder s = new StringBuilder(512); if (ChildHandle != IntPtr.Zero) { int i = GetWindowText(ChildHandle, s, s.Capacity); } else { MessageBox.Show("子窗口中没有内容"); } return s.ToString(); }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。