From cdd6eb43de172da2c330235909d8ae39388f7567 Mon Sep 17 00:00:00 2001 From: dahall Date: Fri, 17 Jul 2020 15:29:39 -0600 Subject: [PATCH] Added parameter attributes --- PInvoke/Shell32/ShObjIdl.IContextMenu.cs | 158 +++++++++++++++++++++++++++++-- 1 file changed, 152 insertions(+), 6 deletions(-) diff --git a/PInvoke/Shell32/ShObjIdl.IContextMenu.cs b/PInvoke/Shell32/ShObjIdl.IContextMenu.cs index 1018f2c7..594761f4 100644 --- a/PInvoke/Shell32/ShObjIdl.IContextMenu.cs +++ b/PInvoke/Shell32/ShObjIdl.IContextMenu.cs @@ -206,7 +206,7 @@ namespace Vanara.PInvoke /// Exposes methods that either create or merge a shortcut menu associated with a Shell object. // https://msdn.microsoft.com/en-us/library/windows/desktop/bb776095(v=vs.85).aspx [PInvokeData("Shobjidl.h", MSDNShortId = "bb776095")] - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214E4-0000-0000-c000-000000000046")] + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214e4-0000-0000-c000-000000000046")] public interface IContextMenu { /// Adds commands to a shortcut menu. @@ -242,7 +242,7 @@ namespace Vanara.PInvoke /// The reference of the buffer to receive the null-terminated string being retrieved. /// Size of the buffer, in characters, to receive the null-terminated string. /// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - void GetCommandString(IntPtr idCmd, GCS uType, IntPtr pReserved, IntPtr pszName, uint cchMax); + void GetCommandString([In] IntPtr idCmd, GCS uType, [Optional] IntPtr pReserved, [Out] IntPtr pszName, uint cchMax); } /// @@ -276,7 +276,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nn-shobjidl_core-icontextmenu2 [PInvokeData("shobjidl_core.h", MSDNShortId = "4e3331ad-4adc-4ea9-8a22-6aad15f618c8")] - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F4-0000-0000-c000-000000000046")] + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214f4-0000-0000-c000-000000000046")] public interface IContextMenu2 : IContextMenu { /// Adds commands to a shortcut menu. @@ -312,7 +312,7 @@ namespace Vanara.PInvoke /// The reference of the buffer to receive the null-terminated string being retrieved. /// Size of the buffer, in characters, to receive the null-terminated string. /// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - new void GetCommandString(IntPtr idCmd, GCS uType, IntPtr pReserved, IntPtr pszName, uint cchMax); + new void GetCommandString([In] IntPtr idCmd, GCS uType, [Optional] IntPtr pReserved, [Out] IntPtr pszName, uint cchMax); /// Enables client objects of the IContextMenu interface to handle messages associated with owner-drawn menu items. /// @@ -321,7 +321,7 @@ namespace Vanara.PInvoke /// /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. /// Additional message information. The value of this parameter depends on the value of the uMsg parameter. - void HandleMenuMsg(uint uMsg, IntPtr wParam, IntPtr lParam); + void HandleMenuMsg(uint uMsg, [In] IntPtr wParam, [In] IntPtr lParam); } /// @@ -451,20 +451,166 @@ namespace Vanara.PInvoke /* /// Contains information needed by IContextMenu::InvokeCommand to invoke a shortcut menu command. + /// + /// Although the IContextMenu::InvokeCommand declaration specifies a CMINVOKECOMMANDINFO structure for the pici parameter, it + /// can also accept a CMINVOKECOMMANDINFOEX structure. If you are implementing this method, you must inspect cbSize to + /// determine which structure has been passed. + /// + // https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ns-shobjidl_core-cminvokecommandinfo typedef struct + // _CMINVOKECOMMANDINFO { DWORD cbSize; DWORD fMask; HWND hwnd; LPCSTR lpVerb; LPCSTR lpParameters; LPCSTR lpDirectory; int nShow; + // DWORD dwHotKey; HANDLE hIcon; } CMINVOKECOMMANDINFO; + [PInvokeData("shobjidl_core.h", MSDNShortId = "NS:shobjidl_core._CMINVOKECOMMANDINFO")] [StructLayout(LayoutKind.Sequential)] public struct CMINVOKECOMMANDINFO { + /// + /// Type: DWORD + /// The size of this structure, in bytes. + /// public uint cbSize; + + /// + /// Type: DWORD + /// Zero, or one or more of the following flags. + /// CMIC_MASK_HOTKEY + /// The dwHotKey member is valid. + /// CMIC_MASK_ICON + /// The hIcon member is valid. As of Windows Vista this flag is not used. + /// CMIC_MASK_FLAG_NO_UI + /// + /// The system is prevented from displaying user interface elements (for example, error messages) while carrying out a command. + /// + /// CMIC_MASK_NO_CONSOLE + /// + /// If a shortcut menu handler needs to create a new process, it will normally create a new console. Setting the + /// CMIC_MASK_NO_CONSOLE flag suppresses the creation of a new console. + /// + /// CMIC_MASK_FLAG_SEP_VDM + /// + /// This flag is valid only when referring to a 16-bit Windows-based application. If set, the application that the shortcut + /// points to runs in a private Virtual DOS Machine (VDM). See Remarks. + /// + /// CMIC_MASK_ASYNCOK + /// Wait for the DDE conversation to terminate before returning. + /// CMIC_MASK_NOASYNC + /// + /// Windows Vista and later. The implementation of IContextMenu::InvokeCommand should be synchronous, not returning + /// before it is complete. Since this is recommended, calling applications that specify this flag cannot guarantee that this + /// request will be honored if they are not familiar with the implementation of the verb that they are invoking. + /// + /// CMIC_MASK_SHIFT_DOWN + /// + /// The SHIFT key is pressed. Use this instead of polling the current state of the keyboard that may have changed since the verb + /// was invoked. + /// + /// CMIC_MASK_CONTROL_DOWN + /// + /// The CTRL key is pressed. Use this instead of polling the current state of the keyboard that may have changed since the verb + /// was invoked. + /// + /// CMIC_MASK_FLAG_LOG_USAGE + /// + /// Indicates that the implementation of IContextMenu::InvokeCommand might want to keep track of the item being invoked for + /// features like the "Recent documents" menu. + /// + /// CMIC_MASK_NOZONECHECKS + /// Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place by IAttachmentExecute. + /// public CMIC fMask; + + /// + /// Type: HWND + /// + /// A handle to the window that is the owner of the shortcut menu. An extension can also use this handle as the owner of any + /// message boxes or dialog boxes it displays. + /// + /// public HWND hwnd; + + /// + /// Type: LPCSTR + /// + /// The address of a null-terminated string that specifies the language-independent name of the command to carry out. This + /// member is typically a string when a command is being activated by an application. The system provides predefined constant + /// values for the following command strings. + /// + /// + /// + /// Constant + /// Command string + /// + /// + /// CMDSTR_RUNAS + /// "RunAs" + /// + /// + /// CMDSTR_PRINT + /// "Print" + /// + /// + /// CMDSTR_PREVIEW + /// "Preview" + /// + /// + /// CMDSTR_OPEN + /// "Open" + /// + /// + /// + /// This is not a fixed set; new canonical verbs can be invented by context menu handlers and applications can invoke them. + /// + /// + /// If a canonical verb exists and a menu handler does not implement the canonical verb, it must return a failure code to enable + /// the next handler to be able to handle this verb. Failing to do this will break functionality in the system including ShellExecute. + /// + /// + /// Alternatively, rather than a pointer, this parameter can be MAKEINTRESOURCE(offset) where offset is the menu-identifier + /// offset of the command to carry out. Implementations can use the IS_INTRESOURCE macro to detect that this alternative is + /// being employed. The Shell uses this alternative when the user chooses a menu command. + /// + /// [MarshalAs(UnmanagedType.LPStr)] public string lpVerb; + + /// + /// Type: LPCSTR + /// + /// An optional string containing parameters that are passed to the command. The format of this string is determined by the + /// command that is to be invoked. This member is always NULL for menu items inserted by a Shell extension. + /// + /// [MarshalAs(UnmanagedType.LPStr)] public string lpParameters; + + /// + /// Type: LPCSTR + /// An optional working directory name. This member is always NULL for menu items inserted by a Shell extension. + /// [MarshalAs(UnmanagedType.LPStr)] public string lpDirectory; - public int nShow; + + /// + /// Type: int + /// A set of SW_ values to pass to the ShowWindow function if the command displays a window or starts an application. + /// + public ShowWindowCommand nShow; + + /// + /// Type: DWORD + /// + /// An optional keyboard shortcut to assign to any application activated by the command. If the fMask parameter does not + /// specify CMIC_MASK_HOTKEY, this member is ignored. + /// + /// public uint dwHotKey; + + /// + /// Type: HANDLE + /// + /// An icon to use for any application activated by the command. If the fMask member does not specify + /// CMIC_MASK_ICON, this member is ignored. + /// + /// public HICON hIcon; } */