码迷,mamicode.com
首页 > Windows程序 > 详细

Windows API中几个函数的总结

时间:2014-07-16 18:38:03      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   io   div   

  [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中几个函数的总结

标签:style   blog   color   os   io   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!