public static void EnumerateWindows(Dictionary <IntPtr, WindowHookEventArgs> newWindows) { EnumDelegate enumfunc = (hWnd, lParam) => EnumWindowsProc(newWindows, hWnd, lParam); var hDesktop = IntPtr.Zero; // current desktop var success = Win32Interop.EnumDesktopWindows(hDesktop, enumfunc, IntPtr.Zero); if (!success) { // Get the last Win32 error code var errorCode = Marshal.GetLastWin32Error(); var errorMessage = $"EnumDesktopWindows failed with code {errorCode}."; throw new Exception(errorMessage); } }
private void EnumerateWindows() { EnumDelegate enumfunc = EnumWindowsProc; var hDesktop = IntPtr.Zero; // current desktop var success = Win32Interop.EnumDesktopWindows(hDesktop, enumfunc, IntPtr.Zero); if (!success) { // Get the last Win32 error code var errorCode = Marshal.GetLastWin32Error(); var errorMessage = $"EnumDesktopWindows failed with code {errorCode}."; throw new Exception(errorMessage); } }