Пример #1
0
        ///// <summary>
        ///// 判断进程是否已经初始化完毕
        ///// </summary>
        //public static bool MainWindowIsShow = false;

        //获取托盘指针
        private static IntPtr TrayToolbarWindow32()
        {
            IntPtr h     = IntPtr.Zero;
            IntPtr hTemp = IntPtr.Zero;

            h = Win32API.FindWindow("Shell_TrayWnd", null);                   //托盘容器
            h = Win32API.FindWindowEx(h, IntPtr.Zero, "TrayNotifyWnd", null); //找到托盘
            h = Win32API.FindWindowEx(h, IntPtr.Zero, "SysPager", null);

            hTemp = Win32API.FindWindowEx(h, IntPtr.Zero, "ToolbarWindow32", null);

            return(hTemp);
        }
Пример #2
0
        //获取MSN窗体列表
        public static List <WindowInfo> GetMSNWindowList(int Handle)
        {
            List <WindowInfo> list = new List <WindowInfo>();

            try
            {
                const string CLASS_PARENT = "IMWindowClass";
                const string CLASS_CHILD  = "IM Window Native WindowBar Class";



                StringBuilder title     = new StringBuilder(256);
                StringBuilder className = new StringBuilder(256);

                int h = Handle;// (int)Win32API.FindWindow(CLASS_PARENT, "");
                while (h != 0)
                {
                    //窗体的子窗体
                    IntPtr p = Win32API.FindWindowEx(new IntPtr(h), IntPtr.Zero, CLASS_CHILD, "");

                    if (p != IntPtr.Zero)
                    {
                        Win32API.GetWindowText(h, title, title.Capacity);//得到窗口的标题

                        if (title.ToString().Trim() != "")
                        {
                            Win32API.GetClassName(new IntPtr(h), className, className.Capacity);
                        }

                        if (className.ToString().Trim() != "" && className.ToString() == CLASS_PARENT)
                        {
                            WindowInfo wi = new WindowInfo(title.ToString(), new IntPtr(h));
                            list.Add(wi);
                        }
                    }
                    h = Win32API.GetWindow(h, Win32API.GW_HWNDNEXT);
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(WindowHide), ex);
            }
            return(list);
        }