File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Files.App/ViewModels/UserControls/Widgets Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -223,3 +223,4 @@ GdipCreateBitmapFromScan0
223223BITMAP
224224GetObject
225225_SICHINTF
226+ RoGetAgileReference
Original file line number Diff line number Diff line change 77using Windows . Storage ;
88using Windows . System ;
99using Windows . UI . Core ;
10+ using Windows . Win32 ;
1011using Windows . Win32 . Foundation ;
12+ using Windows . Win32 . System . Com ;
13+ using Windows . Win32 . System . WinRT ;
1114using Windows . Win32 . UI . Shell ;
1215
1316namespace Files . App . ViewModels . UserControls . Widgets
@@ -183,8 +186,31 @@ public override async Task ExecutePinToSidebarCommand(WidgetCardItem? item)
183186 if ( item is not WidgetFolderCardItem folderCardItem || folderCardItem . Path is null )
184187 return ;
185188
189+ HRESULT hr = default ;
190+ using ComPtr < IAgileReference > pAgileReference = default ;
191+
192+ unsafe
193+ {
194+ hr = PInvoke . RoGetAgileReference (
195+ AgileReferenceOptions . AGILEREFERENCE_DEFAULT ,
196+ IID . IID_IShellItem ,
197+ ( IUnknown * ) folderCardItem . Item . ThisPtr . Get ( ) ,
198+ pAgileReference . GetAddressOf ( ) ) ;
199+ }
200+
186201 // Pin to Quick Access on Windows
187- HRESULT hr = await STATask . Run ( ( ) => folderCardItem . Item . TryInvokeContextMenuVerb ( "pintohome" ) ) ;
202+ hr = await STATask . Run ( ( ) =>
203+ {
204+ unsafe
205+ {
206+ using ComPtr < IShellItem > pShellItem = default ;
207+ hr = pAgileReference . Get ( ) ->Resolve ( IID . IID_IShellItem , ( void * * ) pShellItem . GetAddressOf ( ) ) ;
208+ var windowsFile = new WindowsFile ( pShellItem ) ;
209+
210+ return windowsFile . TryInvokeContextMenuVerb ( "pintohome" ) ;
211+ }
212+ } ) ;
213+
188214 if ( hr . ThrowIfFailedOnDebug ( ) . Failed )
189215 return ;
190216
You can’t perform that action at this time.
0 commit comments