-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix Environment.UserInteractive on Windows #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c5db003
6bfe1f8
d250a1f
85b403b
ebaf64c
e6ea75b
6883f08
2b0e0f4
fcc553b
b0e6f89
1136d92
7a7d8ff
f52a075
65f5813
960cbc7
444554b
ef583c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| <!-- Not a bug, these APIs are in the allowed list but under kernel32 and we need it under normaliz.dll --> | ||
| normaliz.dll!IsNormalizedString | ||
| normaliz.dll!NormalizeString | ||
|
|
||
| <!-- On Nano these are stubs that return failure --> | ||
| user32.dll!GetProcessWindowStation | ||
| user32.dll!GetUserObjectInformationW |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,5 +225,7 @@ internal partial class User32 | |
|
|
||
| public const int UOI_FLAGS = 1; | ||
|
|
||
| public const int HWND_BROADCAST = 0xffff; | ||
|
|
||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,6 +122,28 @@ public static string SystemDirectory | |
| } | ||
| } | ||
|
|
||
| public static unsafe bool UserInteractive | ||
| { | ||
| get | ||
| { | ||
| // Per documentation of GetProcessWindowStation, this handle should not be closed | ||
| IntPtr handle = Interop.User32.GetProcessWindowStation(); | ||
| if (handle != IntPtr.Zero) | ||
| { | ||
| Interop.User32.USEROBJECTFLAGS flags = default; | ||
| uint dummy = 0; | ||
| if (Interop.User32.GetUserObjectInformationW(handle, Interop.User32.UOI_FLAGS, &flags, (uint)sizeof(Interop.User32.USEROBJECTFLAGS), ref dummy)) | ||
| { | ||
| return ((flags.dwFlags & Interop.User32.WSF_VISIBLE) == 0); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like you forgot to invert this logic. Also, should we add back the static property like we had in desktop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack - thank you @ericstj ! Re the static, @jkotas pointed out that there may be a way to change a process to/from interactive - although I didn't do it successfully myself. See mention here #770 (comment) I saw no reason to cache the value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll make the simple fix for now. FWIW I'm now able to reproduce the test failure, so I can confirm fail/then-fix. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comments crossed. Great, I was about to do it, but apparently you've already got those tests working so you can verify it as well. thanks |
||
| } | ||
| } | ||
|
|
||
| // If we can't determine, return true optimistically | ||
| // This will include cases like Windows Nano which do not expose WindowStations | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| public static unsafe long WorkingSet | ||
| { | ||
| get | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.