Skip to content

Commit 6ba6058

Browse files
committed
Replace Interop.Shell32 with PInovke
1 parent fb87411 commit 6ba6058

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

Flow.Launcher.Infrastructure/Flow.Launcher.Infrastructure.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@
8181
<Reference Include="Interop.SHDocVw, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null">
8282
<HintPath>QuickSwitch\Interop.SHDocVw.dll</HintPath>
8383
</Reference>
84-
<Reference Include="Interop.Shell32, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
85-
<HintPath>QuickSwitch\Interop.Shell32.dll</HintPath>
86-
</Reference>
8784
</ItemGroup>
8885

8986
</Project>

Flow.Launcher.Infrastructure/NativeMethods.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ SendMessage
6060
EVENT_SYSTEM_FOREGROUND
6161
WINEVENT_OUTOFCONTEXT
6262
WM_KEYDOWN
63-
WM_SETTEXT
63+
WM_SETTEXT
64+
IShellFolderViewDual2

Flow.Launcher.Infrastructure/QuickSwitch/QuickSwitch.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
using Interop.UIAutomationClient;
88
using NHotkey;
99
using SHDocVw;
10-
using Shell32;
1110
using Windows.Win32;
1211
using Windows.Win32.Foundation;
1312
using Windows.Win32.UI.Accessibility;
13+
using Windows.Win32.UI.Shell;
1414
using WindowsInput;
1515

1616
namespace Flow.Launcher.Infrastructure.QuickSwitch
@@ -78,15 +78,32 @@ private static void NavigateDialogPath()
7878
return;
7979
}
8080

81-
if (document is not IShellFolderViewDual2 folder)
81+
if (document is not IShellFolderViewDual2 folderView)
8282
{
8383
return;
8484
}
8585

8686
string path;
8787
try
8888
{
89-
path = folder.Folder.Items().Item().Path;
89+
// CSWin32 Folder does not have Self, so we need to use dynamic type here
90+
// Use dynamic to bypass static typing
91+
dynamic folder = folderView.Folder;
92+
93+
// Access the Self property via dynamic binding
94+
dynamic folderItem = folder.Self;
95+
96+
// Check if the item is part of the file system
97+
if (folderItem != null && folderItem.IsFileSystem)
98+
{
99+
path = folderItem.Path;
100+
}
101+
else
102+
{
103+
// Handle non-file system paths (e.g., virtual folders)
104+
path = string.Empty;
105+
}
106+
90107
if (!Path.IsPathRooted(path))
91108
{
92109
return;

0 commit comments

Comments
 (0)