diff --git a/PInvoke/Shell32/ShellApi.cs b/PInvoke/Shell32/ShellApi.cs index 328cee87..301558f4 100644 --- a/PInvoke/Shell32/ShellApi.cs +++ b/PInvoke/Shell32/ShellApi.cs @@ -1082,7 +1082,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-assoccreateforclasses SHSTDAPI AssocCreateForClasses( // const ASSOCIATIONELEMENT *rgClasses, ULONG cClasses, REFIID riid, void **ppv ); - [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "43257507-dd5e-4622-8445-c132187fd1e5")] public static extern HRESULT AssocCreateForClasses([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ASSOCIATIONELEMENT[] rgClasses, uint cClasses, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); @@ -2183,7 +2183,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shenumerateunreadmailaccountsw HRESULT // SHEnumerateUnreadMailAccountsW( HKEY hKeyUser, DWORD dwIndex, LPWSTR pszMailAddress, int cchMailAddress ); - [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "67ec8355-f902-4b71-972f-94e403701f96")] public static extern HRESULT SHEnumerateUnreadMailAccountsW(IntPtr hKeyUser, uint dwIndex, StringBuilder pszMailAddress, int cchMailAddress); diff --git a/PInvoke/Shell32/ShlObj.cs b/PInvoke/Shell32/ShlObj.cs index 74254265..0bd85e5b 100644 --- a/PInvoke/Shell32/ShlObj.cs +++ b/PInvoke/Shell32/ShlObj.cs @@ -27,6 +27,13 @@ namespace Vanara.PInvoke // Defined in wingdi.h private const int LF_FACESIZE = 32; + /// [LPFNDFMCALLBACK is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]Defines the prototype for the callback function that receives messages from the Shell's default context menu implementation.Type: IShellFolder*A pointer to the IShellFolder object the message applies to. This value can be NULL.Type: HWNDThe handle of the window that contains the view. This value can be NULL.Type: IDataObject*IDataObject that represents the selection the context menu is based on. This value can be NULL.Type: UINTOne of the following notifications.NotificationUsageDFM_MERGECONTEXTMENUSent by the default context menu implementation to allow LPFNDFMCALLBACK to add items to the menu.DFM_INVOKECOMMANDSent by the default context menu implementation to request LPFNDFMCALLBACK to invoke a menu command.DFM_GETDEFSTATICIDSent by the default context menu implementation when the default menu command is being created, allowing an alternate choice to be made.Type: WPARAMAdditional information. See the individual notification pages for specific requirements.Type: LPARAMAdditional information. See the individual notification pages for specific requirements.Type: HRESULTReturns S_OK if the message was handled, or an error value otherwise, including the following:Return codeDescriptionE_NOTIMPLThe message was not handled. + // typedef HRESULT ( CALLBACK *LPFNDFMCALLBACK)( _In_opt_ IShellFolder *psf, _In_opt_ HWND hwnd, _In_opt_ IDataObject *pdtobj, UINT uMsg, WPARAM wParam, LPARAM lParam); + // https://msdn.microsoft.com/en-us/library/windows/desktop/bb776770(v=vs.85).aspx + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + [PInvokeData("Shlobj_core.h", MSDNShortId = "bb776770")] + public delegate HRESULT LPFNDFMCALLBACK(IShellFolder psf, IntPtr hwnd, IDataObject pdtobj, uint uMsg, IntPtr wParam, IntPtr lParam); + /// /// /// [This interface is supported through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be unsupported in @@ -2070,6 +2077,13 @@ namespace Vanara.PInvoke [PInvokeData("shlobj_core.h", MSDNShortId = "f13af5f4-1b6a-419c-a042-e05c9ec51d02")] public static extern HRESULT AssocGetDetailsOfPropKey(IShellFolder psf, PIDL pidl, ref PROPERTYKEY pkey, ref object pv, [MarshalAs(UnmanagedType.Bool)] ref bool pfFoundPropKey); + /// Creates a context menu for a selected group of file folder objects.Type: PCIDLIST_ABSOLUTEAn ITEMIDLIST structure for the parent folder. This value can be NULL.Type: HWNDA handle to the parent window. This value can be NULL.Type: UINTThe number of ITEMIDLIST structures in the array pointed to by .Type: PCUITEMID_CHILD_ARRAY*A pointer to an array of ITEMIDLIST structures, one for each item that is selected.Type: IShellFolder*A pointer to the parent folder's IShellFolder interface. This IShellFolder must support the IDataObject interface. If it does not, CDefFolderMenu_Create2 fails and returns E_NOINTERFACE. This value can be NULL.TBDType: UINTThe number of registry keys in the array pointed to by .Note The maximum number of registry keys is 16. Callers must enforce this limit as the API does not. Failing to do so can result in memory corruption.Type: const HKEY*A pointer to an array of registry keys that specify the context menu handlers used with the menu's entries. For more information on context menu handlers, see Creating Context Menu Handlers. This array can contain a maximum of 16 registry keys.Type: IContextMenu**The address of an IContextMenu interface pointer that, when this function returns successfully, points to the IContextMenu object that represents the context menu.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-cdeffoldermenu_create2 + // SHSTDAPI CDefFolderMenu_Create2( PCIDLIST_ABSOLUTE pidlFolder, HWND hwnd, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IShellFolder *psf, LPFNDFMCALLBACK pfn, UINT nKeys, const HKEY *ahkeys, IContextMenu **ppcm ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "7b5e012d-1c8b-42c5-8181-9923fd389fc5")] + public static extern HRESULT CDefFolderMenu_Create2(PIDL pidlFolder, HandleRef hwnd, uint cidl, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] apidl, IShellFolder psf, LPFNDFMCALLBACK pfn, uint nKeys, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 6)] IntPtr[] ahkeys, out IContextMenu ppcm); + /// /// /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable @@ -2559,6 +2573,8 @@ namespace Vanara.PInvoke [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathMakeUniqueName([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszUniqueName, uint cchMax, [MarshalAs(UnmanagedType.LPWStr)] string pszTemplate, [MarshalAs(UnmanagedType.LPWStr)] string pszLongPlate, [MarshalAs(UnmanagedType.LPWStr)] string pszDir); + PathQualify + /// /// /// [PathResolve is available for use in the operating systems specified in the Requirements section. It may be altered or @@ -3345,7 +3361,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotifyderegister BOOL // SHChangeNotifyDeregister( ULONG ulID ); - [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "fad021dc-8199-4384-b623-c98bc618799f")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SHChangeNotifyDeregister(uint ulID); @@ -3448,7 +3464,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotifyregister ULONG // SHChangeNotifyRegister( HWND hwnd, int fSources, LONG fEvents, UINT wMsg, int cEntries, const SHChangeNotifyEntry *pshcne ); - [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "73143865-ca2f-4578-a7a2-2ba4833eddd8")] public static extern uint SHChangeNotifyRegister(HandleRef hwnd, SHCNRF fSources, SHCNE fEvents, uint wMsg, int cEntries, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SHChangeNotifyEntry[] pshcne); @@ -4655,7 +4671,7 @@ namespace Vanara.PInvoke // SHGetFolderPathAndSubDirA( HWND hwnd, int csidl, HANDLE hToken, DWORD dwFlags, LPCSTR pszSubDir, LPSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj_core.h", MSDNShortId = "7e92e136-1036-4c96-931f-6e0129fb839a")] - public static extern HRESULT SHGetFolderPathAndSubDirA(HandleRef hwnd, int csidl, SafeTokenHandle hToken, SHGFP dwFlags, string pszSubDir, StringBuilder pszPath); + public static extern HRESULT SHGetFolderPathAndSubDir(HandleRef hwnd, int csidl, SafeTokenHandle hToken, SHGFP dwFlags, string pszSubDir, StringBuilder pszPath); /// /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This extends SHGetKnownFolderPath by allowing