Ejemplo n.º 1
0
 public static IntPtr GetMainWindowHandle(int processId)
 {
     return(MainWindowFinder.FindMainWindow(processId));
 }
Ejemplo n.º 2
0
 public static IntPtr GetMainWindowHandle(int processId) {
     MainWindowFinder finder = new MainWindowFinder();
     return finder.FindMainWindow(processId);
 }
Ejemplo n.º 3
0
        public static IntPtr GetMainWindowHandle(int processId)
        {
            MainWindowFinder finder = new MainWindowFinder();

            return(finder.FindMainWindow(processId));
        }
        public List<ManagedApplicationInfo> GetManagedApplications()
        {
            _validProcessIdCache.Clear();
            var managedApplications = new List<ManagedApplicationInfo>();
            var checkedProcessIds = new List<int>();

            foreach (var hWnd in EnumerateWindows())
            {
                int processId;
                NativeMethods.GetWindowThreadProcessId(hWnd, out processId);

                if (checkedProcessIds.Contains(processId))
                {
                    continue;
                }

                if (processId == _currentProcessId)
                    continue;

                //Process p = GetProcess(hWnd);)
                string runtimeVersion;
                int bitness;
                if (GetIsManagedApplication(hWnd, processId, out runtimeVersion, out bitness) )
                {
                    IntPtr mainWindowHandle = new MainWindowFinder().FindMainWindow(processId);
                    string windowText = GetWindowText(mainWindowHandle);
                    if (mainWindowHandle == hWnd)
                    {
                        var process = Process.GetProcessById(processId);
                        if (!process.ProcessName.Contains("devenv") && !process.ProcessName.Contains("PresentationHost")
                            && !process.ProcessName.ToLower().Contains("inspector"))
                        {
                            var applicationInfo = new ManagedApplicationInfo(windowText, hWnd, processId, runtimeVersion, bitness);
                            managedApplications.Add(applicationInfo);
                            checkedProcessIds.Add(processId);
                        }
                    }
                }
            }

            return managedApplications;
        }