@@ -146,6 +146,20 @@ enum MenuItemFtype : uint
146
146
String = 0x00000000 ,
147
147
}
148
148
149
+ enum GetCommandStringFlags : uint
150
+ {
151
+ VerbA = 0x00000000 ,
152
+ HelpTextA = 0x00000001 ,
153
+ ValidateA = 0x00000002 ,
154
+ Unicode = VerbW ,
155
+ Verb = VerbW ,
156
+ VerbW = 0x00000004 ,
157
+ HelpText = HelpTextW ,
158
+ HelpTextW = 0x00000005 ,
159
+ Validate = ValidateW ,
160
+ ValidateW = 0x00000006 ,
161
+ VerbIconW = 0x00000014
162
+
149
163
#endregion
150
164
151
165
private static IMalloc GetMalloc ( )
@@ -185,7 +199,7 @@ public static void ExecuteContextMenuItem(string fileName, uint menuItemId)
185
199
contextMenu = ( IContextMenu ) Marshal . GetTypedObjectForIUnknown ( pContextMenu , typeof ( IContextMenu ) ) ;
186
200
187
201
hMenu = CreatePopupMenu ( ) ;
188
- contextMenu . QueryContextMenu ( hMenu , 0 , ContextMenuStartId , ContextMenuEndId , ( uint ) ContextMenuFlags . Normal ) ;
202
+ contextMenu . QueryContextMenu ( hMenu , 0 , ContextMenuStartId , ContextMenuEndId , ( uint ) ContextMenuFlags . Explore ) ;
189
203
190
204
var directory = Path. GetDirectoryName( fileName ) ;
191
205
var invokeCommandInfo = new CMINVOKECOMMANDINFO
@@ -195,7 +209,7 @@ public static void ExecuteContextMenuItem(string fileName, uint menuItemId)
195
209
hwnd = IntPtr . Zero ,
196
210
lpVerb = ( IntPtr ) ( menuItemId - ContextMenuStartId ) ,
197
211
lpParameters = null ,
198
- lpDirectory = directory ?? "" ,
212
+ lpDirectory = null ,
199
213
nShow = 1 ,
200
214
hIcon = IntPtr . Zero ,
201
215
} ;
@@ -236,10 +250,10 @@ public static List<ContextMenuItem> GetContextMenuWithIcons(string filePath)
236
250
IMalloc malloc = null ;
237
251
IntPtr originalPidl = IntPtr . Zero ;
238
252
IntPtr pShellFolder = IntPtr . Zero ;
239
- IShellFolder shellFolder = null ;
240
253
IntPtr pContextMenu = IntPtr . Zero ;
241
- IContextMenu contextMenu = null ;
242
254
IntPtr hMenu = IntPtr . Zero ;
255
+ IShellFolder shellFolder = null ;
256
+ IContextMenu contextMenu = null ;
243
257
244
258
try
245
259
{
@@ -262,7 +276,7 @@ public static List<ContextMenuItem> GetContextMenuWithIcons(string filePath)
262
276
contextMenu = ( IContextMenu ) Marshal . GetTypedObjectForIUnknown ( pContextMenu , typeof ( IContextMenu ) ) ;
263
277
264
278
hMenu = CreatePopupMenu ( ) ;
265
- contextMenu . QueryContextMenu ( hMenu , 0 , ContextMenuStartId , ContextMenuEndId , ( uint ) ContextMenuFlags . Normal ) ;
279
+ contextMenu . QueryContextMenu ( hMenu , 0 , ContextMenuStartId , ContextMenuEndId , ( uint ) ContextMenuFlags . Explore ) ;
266
280
267
281
var menuItems = new List < ContextMenuItem > ( ) ;
268
282
ProcessMenuWithIcons ( hMenu , contextMenu , menuItems ) ;
0 commit comments