Get Application's Window Handles

前端 未结 3 1407
野趣味
野趣味 2020-11-28 10:14

I\'m building an app that given another app mainWindowhandle it collects information about the window state. I have no problem collecting information about child windows, bu

3条回答
  •  臣服心动
    2020-11-28 10:49

        public void GetWindowHandles()
        {
            List windowHandles = new List();
    
            foreach (Process window in Process.GetProcesses())
            {
                window.Refresh();
    
                if (window.MainWindowHandle != IntPtr.Zero) 
                {
                    windowHandles.Add(window.MainWindowHandle);
                }
            }
        }
    

    Read This as to why we call the refresh method and check if the pointer is zero

提交回复
热议问题