mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:05:59 +08:00
[Peek]Fix crashes on File Explorer alternatives (#31211)
* [Peek] Add check to ensure window class name matches File Explorer * [Peek] Safe casting for IShellFolderViewDual2 compatibility.
This commit is contained in:
parent
3f837f8c90
commit
356db99bca
@ -63,21 +63,23 @@ namespace Peek.UI.Helpers
|
|||||||
|
|
||||||
var shell = new Shell32.Shell();
|
var shell = new Shell32.Shell();
|
||||||
ShellWindows shellWindows = shell.Windows();
|
ShellWindows shellWindows = shell.Windows();
|
||||||
foreach (IWebBrowserApp webBrowserApp in shell.Windows())
|
foreach (IWebBrowserApp webBrowserApp in shellWindows)
|
||||||
{
|
{
|
||||||
var shellFolderView = (Shell32.IShellFolderViewDual2)webBrowserApp.Document;
|
if (webBrowserApp.Document is Shell32.IShellFolderViewDual2 shellFolderView)
|
||||||
var folderTitle = shellFolderView.Folder.Title;
|
|
||||||
|
|
||||||
if (webBrowserApp.HWND == foregroundWindowHandle)
|
|
||||||
{
|
{
|
||||||
var serviceProvider = (IServiceProvider)webBrowserApp;
|
var folderTitle = shellFolderView.Folder.Title;
|
||||||
var shellBrowser = (IShellBrowser)serviceProvider.QueryService(PInvoke.SID_STopLevelBrowser, typeof(IShellBrowser).GUID);
|
|
||||||
shellBrowser.GetWindow(out IntPtr shellBrowserHandle);
|
|
||||||
|
|
||||||
if (activeTab == shellBrowserHandle)
|
if (webBrowserApp.HWND == foregroundWindowHandle)
|
||||||
{
|
{
|
||||||
shellItemArray = GetShellItemArray(shellBrowser, onlySelectedFiles);
|
var serviceProvider = (IServiceProvider)webBrowserApp;
|
||||||
return shellItemArray;
|
var shellBrowser = (IShellBrowser)serviceProvider.QueryService(PInvoke.SID_STopLevelBrowser, typeof(IShellBrowser).GUID);
|
||||||
|
shellBrowser.GetWindow(out IntPtr shellBrowserHandle);
|
||||||
|
|
||||||
|
if (activeTab == shellBrowserHandle)
|
||||||
|
{
|
||||||
|
shellItemArray = GetShellItemArray(shellBrowser, onlySelectedFiles);
|
||||||
|
return shellItemArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user