public IntPtr FindMainWindow(int processId) { this.bestHandle = IntPtr.Zero; this.processId = processId; Microsoft.Win32.NativeMethods.EnumThreadWindowsCallback callback = new Microsoft.Win32.NativeMethods.EnumThreadWindowsCallback(this.EnumWindowsCallback); Microsoft.Win32.NativeMethods.EnumWindows(callback, IntPtr.Zero); GC.KeepAlive(callback); return this.bestHandle; }
public IntPtr FindMainWindow(int processId) { this.bestHandle = IntPtr.Zero; this.processId = processId; Microsoft.Win32.NativeMethods.EnumThreadWindowsCallback callback = new Microsoft.Win32.NativeMethods.EnumThreadWindowsCallback(this.EnumWindowsCallback); Microsoft.Win32.NativeMethods.EnumWindows(callback, IntPtr.Zero); GC.KeepAlive(callback); return(this.bestHandle); }