Skip to content

Commit

Permalink
#56 Ignore access denied when AllowSetForegroundWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
shuffle-c committed Aug 15, 2021
1 parent 5e51115 commit 0c4d05a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Utilities/Win32Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ private static Win32Window GetOrNull(HWND hwnd)
public static void AllowAllSetForeground()
{
const int ASFW_ANY = -1;
WinAPI.AllowSetForegroundWindow(ASFW_ANY).ThrowOnError("AllowSetForegroundWindow");
WinAPI.AllowSetForegroundWindow(ASFW_ANY)
.ThrowOnError("AllowSetForegroundWindow", WinAPI.ERROR_ACCESS_DENIED);
}

public void Close()
Expand Down Expand Up @@ -211,6 +212,8 @@ static class WinAPI
{
private const string User32 = "User32.dll";

public const int ERROR_ACCESS_DENIED = 5;

[DllImport(User32, SetLastError = true)]
public static extern BOOL SetForegroundWindow(IntPtr hWnd);

Expand Down

0 comments on commit 0c4d05a

Please sign in to comment.