diff --git a/Windows.Shell/ShellObjects/ShellContextMenu.cs b/Windows.Shell/ShellObjects/ShellContextMenu.cs index 1aa7e87e..c08c069f 100644 --- a/Windows.Shell/ShellObjects/ShellContextMenu.cs +++ b/Windows.Shell/ShellObjects/ShellContextMenu.cs @@ -1,6 +1,4 @@ // Credit due to Gong-Shell from which this was largely taken. -#if !NETCOREAPP3_1 - using System; using System.Collections.Generic; using System.Drawing; @@ -44,6 +42,8 @@ namespace Vanara.Windows.Shell private readonly MessageWindow m_MessageWindow; private bool disposedValue; + static ShellContextMenu() => Ole32.OleInitialize(default); // Not sure why necessary, but it fails without + /// Initialises a new instance of the class. /// The items to which the context menu should refer. public ShellContextMenu(params ShellItem[] items) @@ -218,9 +218,10 @@ namespace Vanara.Windows.Shell /// /// Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place by IAttachmentExecute. /// + /// Optional parameters. public void InvokeCommand(ResourceId verb, ShowWindowCommand show = ShowWindowCommand.SW_SHOWNORMAL, HWND parent = default, - Point? location = default, bool allowAsync = false, bool shiftDown = false, - bool ctrlDown = false, uint hotkey = 0, bool logUsage = false, bool noZoneChecks = false) + Point? location = default, bool allowAsync = false, bool shiftDown = false, bool ctrlDown = false, uint hotkey = 0, + bool logUsage = false, bool noZoneChecks = false, string parameters = null) { var invoke = new CMINVOKECOMMANDINFOEX { @@ -246,6 +247,11 @@ namespace Vanara.Windows.Shell invoke.lpVerbW = (string)verb; invoke.fMask |= CMIC.CMIC_MASK_UNICODE; } + if (parameters != null) + { + invoke.lpParameters = invoke.lpParametersW = parameters; + invoke.fMask |= CMIC.CMIC_MASK_UNICODE; + } ComInterface.InvokeCommand(invoke); } @@ -330,7 +336,7 @@ namespace Vanara.Windows.Shell return mStr.ToString(); } -#if !NET5_0 +#if !NET5_0 && !NETCOREAPP3_1 /// Populates a with the context menu items for a shell item. /// The menu to populate. /// The flags to pass to . @@ -550,6 +556,4 @@ namespace Vanara.Windows.Shell } } } -} - -#endif \ No newline at end of file +} \ No newline at end of file