|
1 | 1 | using System; |
2 | 2 | using System.Diagnostics; |
3 | 3 | using System.Linq; |
| 4 | +using System.Runtime.InteropServices; |
| 5 | +using System.Windows.Interop; |
4 | 6 | using System.Windows.Threading; |
5 | 7 | using static ModernFlyouts.Core.Interop.NativeMethods; |
6 | 8 |
|
@@ -340,11 +342,31 @@ private static bool IsShellProcess(int id) |
340 | 342 |
|
341 | 343 | private bool GetAllInfos() |
342 | 344 | { |
343 | | - IntPtr hWndHost; |
344 | | - while ((hWndHost = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "NativeHWNDHost", "")) != IntPtr.Zero) |
| 345 | + IntPtr hWndHost = IntPtr.Zero; |
| 346 | + IntPtr hWndDUI = IntPtr.Zero; |
| 347 | + |
| 348 | + String build = RuntimeInformation.OSDescription.Substring(RuntimeInformation.OSDescription.LastIndexOf('.') + 1); |
| 349 | + int buildNumber = int.Parse(build); |
| 350 | + |
| 351 | + String outerClass = ""; |
| 352 | + String outerName = ""; |
| 353 | + String innerClass = ""; |
| 354 | + String innerName = ""; |
| 355 | + if (buildNumber >= 22000) |
| 356 | + { |
| 357 | + outerClass = "XamlExplorerHostIslandWindow"; |
| 358 | + innerClass = "Windows.UI.Composition.DesktopWindowContentBridge"; |
| 359 | + innerName = "DesktopWindowXamlSource"; |
| 360 | + } |
| 361 | + else |
| 362 | + { |
| 363 | + outerClass = "NativeHWNDHost"; |
| 364 | + innerClass = "DirectUIHWND"; |
| 365 | + } |
| 366 | + |
| 367 | + while ((hWndHost = FindWindowEx(IntPtr.Zero, hWndHost, outerClass, outerName)) != IntPtr.Zero) |
345 | 368 | { |
346 | | - IntPtr hWndDUI; |
347 | | - if ((hWndDUI = FindWindowEx(hWndHost, IntPtr.Zero, "DirectUIHWND", "")) != IntPtr.Zero) |
| 369 | + if ((hWndDUI = FindWindowEx(hWndHost, IntPtr.Zero, innerClass, innerName)) != IntPtr.Zero) |
348 | 370 | { |
349 | 371 | GetWindowThreadProcessId(hWndHost, out int pid); |
350 | 372 | if (Process.GetProcessById(pid).ProcessName.ToLower() == "explorer") |
|
0 commit comments