首页 > Windows开发 > 详细

Windows API中几个函数的总结

时间:2014-07-16 18:37:42      阅读:307      评论:0      收藏:0      [点我收藏+]
  [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();
            
           
        }

 

Windows API中几个函数的总结,布布扣,bubuko.com

Windows API中几个函数的总结

原文:http://www.cnblogs.com/sjfsjf/p/3845172.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!