Skip to content

Commit e739f4e

Browse files
authored
Merge pull request #58 from lanfeust69/fix-unhandled-exception
Do not throw from Win32Helper.GetFocusedWindowHandle()
2 parents 9f8ca01 + bbe8a32 commit e739f4e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Source/ExcelDna.IntelliSense/Win32Helper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static IntPtr GetFocusedWindowHandle()
133133
var info = new GUITHREADINFO();
134134
info.cbSize = Marshal.SizeOf(info);
135135
if (!GetGUIThreadInfo(0, ref info))
136-
throw new Win32Exception();
136+
return IntPtr.Zero;
137137

138138
var focusedWindow = info.hwndFocus;
139139
if (focusedWindow == IntPtr.Zero)
@@ -142,7 +142,7 @@ public static IntPtr GetFocusedWindowHandle()
142142
uint processId;
143143
uint threadId = GetWindowThreadProcessId(focusedWindow, out processId);
144144
if (threadId == 0)
145-
throw new Win32Exception();
145+
return IntPtr.Zero;
146146

147147
uint currentProcessId = GetCurrentProcessId();
148148
if (processId == currentProcessId)

0 commit comments

Comments
 (0)