Ejemplo n.º 1
0
        private void button7_Click_1(object sender, EventArgs e)
        {
            the_pid = (uint)Process.GetCurrentProcess().Id;
            WndEnumCallBack my_call_back = new WndEnumCallBack(find_main_window_handle);

            win32api.EnumWindows(my_call_back, 0);
            RECT rect = new RECT();

            rect          = get_window_rect(the_mainWindHandle);
            textBox1.Text = string.Format("left:{0,-5},right:{1,-5},top:{2,-5},bottom:{3,-5}", rect.Left, rect.Right, rect.Top, rect.Bottom);
        }
Ejemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            the_pid = 10800;
            the_pid = (uint)Process.GetCurrentProcess().Id;
            WndEnumCallBack my_call_back = new WndEnumCallBack(find_main_window_handle);

            win32api.EnumWindows(my_call_back, 0);

            //以下这句是没有错误,可以使用的。
            //IntPtr intptr = win32api.FindWindow(null, "Q-Dir 6.71");

            win32api.MoveWindow(the_mainWindHandle, 20, 20, 400, 400, true);
        }
Ejemplo n.º 3
0
        //获得所有的顶级窗口的全路径
        public List <wininfo> get_top_win_info_way_1()
        {
            List <wininfo> path_list = new List <wininfo>();

            hWnd_list.Clear();
            WndEnumCallBack my_call_back = new WndEnumCallBack(my_call_back_function);

            win32api.EnumWindows(my_call_back, 0);

            foreach (IntPtr i in hWnd_list)
            {
                uint num = 0;
                win32api.GetWindowThreadProcessId(i, ref num);
                string a = string.Format("{0}", get_fullpath(num));
                bool   path_list_have_it = false;
                foreach (wininfo j in path_list)
                {
                    if (j.fullname == a)
                    {
                        path_list_have_it = true;
                        break;
                    }
                }
                path_list_have_it = false;
                if (!path_list_have_it)
                {
                    wininfo t = new wininfo();
                    t.fullname    = a;
                    t.wndhandle   = i;
                    t.pid         = (IntPtr)num;
                    t.rect.Top    = 0;
                    t.rect.Bottom = 0;
                    t.rect.Left   = 0;
                    t.rect.Right  = 0;
                    path_list.Add(t);
                }
            }
            return(path_list);
        }
Ejemplo n.º 4
0
        private void button4_Click(object sender, EventArgs e)
        {
            WndEnumCallBack my_call_back = new WndEnumCallBack(my_call_back_function);

            win32api.EnumWindows(my_call_back, 0);
        }
Ejemplo n.º 5
0
 public static extern int EnumWindows(WndEnumCallBack lpEnumFunc, int lParam);