From 4c7d9fc8dbd93c5ed3a1decb1c1dac2cb905bcd0 Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 26 Jul 2018 16:49:45 -0600 Subject: [PATCH] More additions on Shell32 --- PInvoke/Shell32/ShObjIdl.cs | 1003 ++++++++++--- PInvoke/Shell32/ShellApi.cs | 2675 ++++++++++++++++++++++++++++++++--- PInvoke/Shell32/ShlObj.cs | 3276 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 6231 insertions(+), 723 deletions(-) diff --git a/PInvoke/Shell32/ShObjIdl.cs b/PInvoke/Shell32/ShObjIdl.cs index 874da062..e54ab0e4 100644 --- a/PInvoke/Shell32/ShObjIdl.cs +++ b/PInvoke/Shell32/ShObjIdl.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices.ComTypes; using System.Security; using Vanara.Extensions; using Vanara.InteropServices; +using static Vanara.PInvoke.Ole32; using static Vanara.PInvoke.PropSys; // ReSharper disable MemberCanBePrivate.Global @@ -20,117 +21,343 @@ namespace Vanara.PInvoke { /// The bind interruptable public const uint BIND_INTERRUPTABLE = 0xFFFFFFFF; - /// Introduced in Windows XP SP2. Specify this bind context to permit clients of the data source to override the hidden drive letter policy and enable access to the view objects for data sources on the drives that are blocked. + + /// + /// Introduced in Windows XP SP2. Specify this bind context to permit clients of the data source to override the hidden drive letter + /// policy and enable access to the view objects for data sources on the drives that are blocked. /// Used with IShellFolder::BindToObject or IShellItem::BindToHandler. - /// The system supports administrator-controlled policies that hide specified drive letters to block users from accessing those drives through Windows Explorer.When this policy is active, the result is that view objects and other handlers created with the IShellFolder::CreateViewObject method will fail when called on drives that are blocked by policy. + /// + /// The system supports administrator-controlled policies that hide specified drive letters to block users from accessing those + /// drives through Windows Explorer.When this policy is active, the result is that view objects and other handlers created with the + /// IShellFolder::CreateViewObject method will fail when called on drives that are blocked by policy. + /// + /// public const string STR_AVOID_DRIVE_RESTRICTION_POLICY = "Avoid Drive Restriction Policy"; - /// Introduced in Windows Vista. Specify this bind context to cause the IShellFolder::BindToObject method to use the object specified by the pbc parameter to create the target object; in this case, the object specified by the punk parameter in the IBindCtx::RegisterObjectParam call must implement the ICreateObject interface. - /// Used with IShellFolder::BindToObject or IShellItem::BindToHandler. + + /// + /// Introduced in Windows Vista. Specify this bind context to cause the IShellFolder::BindToObject method to use the object specified + /// by the pbc parameter to create the target object; in this case, the object specified by the punk parameter in the + /// IBindCtx::RegisterObjectParam call must implement the ICreateObject interface. + /// Used with IShellFolder::BindToObject or IShellItem::BindToHandler. + /// public const string STR_BIND_DELEGATE_CREATE_OBJECT = "Delegate Object Creation"; - /// Introduced in Windows 7. Passed to IShellFolder::ParseDisplayName with an FOLDER_ENUM_MODE value to control the enumeration mode of the parsed item. The FOLDER_ENUM_MODE value is passed in the bind context through an object that implements IObjectWithFolderEnumMode. - /// Items with different enumeration modes compare canonically(SHCIDS_CANONICALONLY) different because they enumerate different sets of items. - /// If an item doesn't support the enumeration mode (because it isn't a folder or it doesn't provide the enumeration mode) then it is created in the default enumeration mode. + + /// + /// Introduced in Windows 7. Passed to IShellFolder::ParseDisplayName with an FOLDER_ENUM_MODE value to control the enumeration mode + /// of the parsed item. The FOLDER_ENUM_MODE value is passed in the bind context through an object that implements IObjectWithFolderEnumMode. + /// + /// Items with different enumeration modes compare canonically(SHCIDS_CANONICALONLY) different because they enumerate different sets + /// of items. + /// + /// + /// If an item doesn't support the enumeration mode (because it isn't a folder or it doesn't provide the enumeration mode) then it is + /// created in the default enumeration mode. + /// + /// public const string STR_BIND_FOLDER_ENUM_MODE = "Folder Enum Mode"; - /// Introduced in Windows 7. Passed to IShellFolder::ParseDisplayName along with STR_FILE_SYS_BIND_DATA. This forces simple parsing while also probing for Desktop.ini files along the path from which to get a localized name string. This avoids probing for folders along the path, which, in a case of a folder that represents a server or a share, could take extensive time and resources. Desktop.ini files are cached in some locations, so it will be at least as efficient as probing for folders attributes and then probing for the Desktop.ini if that folder should turn ou tot be read-only. + /// + /// Introduced in Windows 7. Passed to IShellFolder::ParseDisplayName along with STR_FILE_SYS_BIND_DATA. This forces simple parsing + /// while also probing for Desktop.ini files along the path from which to get a localized name string. This avoids probing for + /// folders along the path, which, in a case of a folder that represents a server or a share, could take extensive time and + /// resources. Desktop.ini files are cached in some locations, so it will be at least as efficient as probing for folders attributes + /// and then probing for the Desktop.ini if that folder should turn ou tot be read-only. + /// public const string STR_BIND_FOLDERS_READ_ONLY = "Folders As Read Only"; - /// Introduced in Windows XP SP2. Specify this bind context to force a folder shortcut to resolve the link that points to its target. - /// A folder shortcut is a folder item that points to another folder item in the same namespace, using a link(shortcut) to hold the IDList of the target.The link is resolved to track the target in case it is moved or renamed.For example, the Windows XP My Network Places folder and the Windows Vista Computer folder can contain folder shortcuts created with the Add Network Location wizard.To improve performance, the IShellFolder::BindToObject method does not resolve links to network folder by default. - /// Used with IShellFolder::BindToObject or IShellItem::BindToHandler. + + /// + /// Introduced in Windows XP SP2. Specify this bind context to force a folder shortcut to resolve the link that points to its target. + /// + /// A folder shortcut is a folder item that points to another folder item in the same namespace, using a link(shortcut) to hold the + /// IDList of the target.The link is resolved to track the target in case it is moved or renamed.For example, the Windows XP My + /// Network Places folder and the Windows Vista Computer folder can contain folder shortcuts created with the Add Network Location + /// wizard.To improve performance, the IShellFolder::BindToObject method does not resolve links to network folder by default. + /// + /// Used with IShellFolder::BindToObject or IShellItem::BindToHandler. + /// public const string STR_BIND_FORCE_FOLDER_SHORTCUT_RESOLVE = "Force Folder Shortcut Resolve"; - /// Introduced in Windows XP. Specify this bind context to prevent a call to the IShellFolder::ParseDisplayName method on the Desktop folder from treating relative paths as relative to the desktop; in such a case, parsing fails when this bind context is specified. + + /// + /// Introduced in Windows XP. Specify this bind context to prevent a call to the IShellFolder::ParseDisplayName method on the Desktop + /// folder from treating relative paths as relative to the desktop; in such a case, parsing fails when this bind context is specified. + /// public const string STR_DONT_PARSE_RELATIVE = "Don't Parse Relative"; - /// Introduced in Windows Vista. Specify this bind context to instruct an IShellItem not to resolve the link target obtained when using the BHID_LinkTargetItem GUID in IShellItem::BindToHandler. + + /// + /// Introduced in Windows Vista. Specify this bind context to instruct an IShellItem not to resolve the link target obtained when + /// using the BHID_LinkTargetItem GUID in IShellItem::BindToHandler. + /// public const string STR_DONT_RESOLVE_LINK = "Don't Resolve Link"; - /// Introduced in Windows 8. Specifies a SHCONTF value to be passed to IShellFolder::EnumObjects when you call IShellItem::BindToHandler with BHID_EnumItems. + + /// + /// Introduced in Windows 8. Specifies a SHCONTF value to be passed to IShellFolder::EnumObjects when you call + /// IShellItem::BindToHandler with BHID_EnumItems. + /// public const string STR_ENUM_ITEMS_FLAGS = "SHCONTF"; - /// Introduced in Windows XP. Specify this bind context to provide file metadata to the IShellFolder::ParseDisplayName method, which is used instead of attempting to retrieve the actual file metadata. The associated object must implement IFileSystemBindData and can optionally also implement IFileSystemBindData2. By default, the IShellFolder::ParseDisplayName method verifies that the file exists and uses the file's actual metadata to populate the ID list. + + /// + /// Introduced in Windows XP. Specify this bind context to provide file metadata to the IShellFolder::ParseDisplayName method, which + /// is used instead of attempting to retrieve the actual file metadata. The associated object must implement IFileSystemBindData and + /// can optionally also implement IFileSystemBindData2. By default, the IShellFolder::ParseDisplayName method verifies that the file + /// exists and uses the file's actual metadata to populate the ID list. + /// public const string STR_FILE_SYS_BIND_DATA = "File System Bind Data"; - /// Introduced in Windows 8.1. Specify this bind context to indicate that the data provided in the STR_FILE_SYS_FIND_DATA bind context should be used to create an ItemID list in the Windows 7 format. + + /// + /// Introduced in Windows 8.1. Specify this bind context to indicate that the data provided in the STR_FILE_SYS_FIND_DATA bind + /// context should be used to create an ItemID list in the Windows 7 format. + /// public const string STR_FILE_SYS_BIND_DATA_WIN7_FORMAT = "Win7FileSystemIdList"; - /// Introduced in Windows 7. Specify this bind context when the handler is being retrieved on the same thread as the UI. Any memory-intensive activities such as those that involve disk or network access should be avoided. + + /// + /// Introduced in Windows 7. Specify this bind context when the handler is being retrieved on the same thread as the UI. Any + /// memory-intensive activities such as those that involve disk or network access should be avoided. + /// public const string STR_GET_ASYNC_HANDLER = "GetAsyncHandler"; - /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_BESTEFFORT flag for more information. + + /// + /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This + /// value is used with IShellFolder::BindToObject. See the GPS_BESTEFFORT flag for more information. + /// public const string STR_GPS_BESTEFFORT = "GPS_BESTEFFORT"; - /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_DELAYCREATION flag for more information. + + /// + /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This + /// value is used with IShellFolder::BindToObject. See the GPS_DELAYCREATION flag for more information. + /// public const string STR_GPS_DELAYCREATION = "GPS_DELAYCREATION"; - /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_FASTPROPERTIESONLY flag for more information. + + /// + /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This + /// value is used with IShellFolder::BindToObject. See the GPS_FASTPROPERTIESONLY flag for more information. + /// public const string STR_GPS_FASTPROPERTIESONLY = "GPS_FASTPROPERTIESONLY"; - /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_HANDLERPROPERTIESONLY flag for more information. + + /// + /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This + /// value is used with IShellFolder::BindToObject. See the GPS_HANDLERPROPERTIESONLY flag for more information. + /// public const string STR_GPS_HANDLERPROPERTIESONLY = "GPS_HANDLERPROPERTIESONLY"; - /// Introduced in Windows 7. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_NO_OPLOCK flag for more information. + + /// + /// Introduced in Windows 7. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value + /// is used with IShellFolder::BindToObject. See the GPS_NO_OPLOCK flag for more information. + /// public const string STR_GPS_NO_OPLOCK = "GPS_NO_OPLOCK"; - /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This value is used with IShellFolder::BindToObject. See the GPS_OPENSLOWITEM flag for more information. + + /// + /// Introduced in Windows Vista. Specify this bind context when requesting an IPropertySetStorage or IPropertyStore handler. This + /// value is used with IShellFolder::BindToObject. See the GPS_OPENSLOWITEM flag for more information. + /// public const string STR_GPS_OPENSLOWITEM = "GPS_OPENSLOWITEM"; - /// Windows Vista only. Specify this bind context to cause a call to the IShellFolder::BindToObject method that requests the IFilter interface for a file system object to return a text filter if no other filter is available. This value is not defined as of Windows 7. + + /// + /// Windows Vista only. Specify this bind context to cause a call to the IShellFolder::BindToObject method that requests the IFilter + /// interface for a file system object to return a text filter if no other filter is available. This value is not defined as of + /// Windows 7. + /// public const string STR_IFILTER_FORCE_TEXT_FILTER_FALLBACK = "Always bind persistent handlers"; - /// Windows Vista only. Specify this bind context to cause a call to the IShellFolder::BindToObject method that requests the IFilter interface for a file system object to not return a fallback filter if no registered filter could be found. + + /// + /// Windows Vista only. Specify this bind context to cause a call to the IShellFolder::BindToObject method that requests the IFilter + /// interface for a file system object to not return a fallback filter if no registered filter could be found. + /// public const string STR_IFILTER_LOAD_DEFINED_FILTER = "Only bind registered persistent handlers"; - /// Introduced in Windows Vista. Specify this bind context to enable loading of the history from a stream for an internal navigation when the IPersistHistory::LoadHistory method is called. An internal navigation is a navigation within the same view. + + /// + /// Introduced in Windows Vista. Specify this bind context to enable loading of the history from a stream for an internal navigation + /// when the IPersistHistory::LoadHistory method is called. An internal navigation is a navigation within the same view. + /// public const string STR_INTERNAL_NAVIGATE = "Internal Navigation"; - /// Introduced in Windows 7. Specify this bind context with STR_PARSE_PREFER_FOLDER_BROWSING when the client wants the Internet Shell folder handlers to generate an IDList for any valid URL if a DAV-type folder cannot be created for that URL. The URL is not verified to exist; only its syntax is checked and that it has a registered protocol handler. + + /// + /// Introduced in Windows 7. Specify this bind context with STR_PARSE_PREFER_FOLDER_BROWSING when the client wants the Internet Shell + /// folder handlers to generate an IDList for any valid URL if a DAV-type folder cannot be created for that URL. The URL is not + /// verified to exist; only its syntax is checked and that it has a registered protocol handler. + /// public const string STR_INTERNETFOLDER_PARSE_ONLY_URLMON_BINDABLE = "Validate URL"; - /// Introduced in Windows 7. Specify this bind context to instruct implementations of IShellFolder::ParseDisplayName and IPersistFolder3::InitializeEx to cache memory-intensive helper objects that can exist across instantiations of Shell items instead of recreating these objects each time that a Shell item is created. The associated object is another bind context object, initially empty. This should result in a separate bind context object, which is accessed through IBindCtx::GetObjectParam or IBindCtx::Register.ObjectParam. - /// A caller must opt into this behavior by providing this bind context parameter when calling SHCreateItemFromParsingName. By doing so, you optimize the behavior of binding to multiple parsing names in succession.The lifetime of the bind context object should span multiple instances of Shell items and their individual bind contexts. + + /// + /// Introduced in Windows 7. Specify this bind context to instruct implementations of IShellFolder::ParseDisplayName and + /// IPersistFolder3::InitializeEx to cache memory-intensive helper objects that can exist across instantiations of Shell items + /// instead of recreating these objects each time that a Shell item is created. The associated object is another bind context object, + /// initially empty. This should result in a separate bind context object, which is accessed through IBindCtx::GetObjectParam or IBindCtx::Register.ObjectParam. + /// + /// A caller must opt into this behavior by providing this bind context parameter when calling SHCreateItemFromParsingName. By doing + /// so, you optimize the behavior of binding to multiple parsing names in succession.The lifetime of the bind context object should + /// span multiple instances of Shell items and their individual bind contexts. + /// + /// public const string STR_ITEM_CACHE_CONTEXT = "ItemCacheContext"; - /// Introduced in Windows Vista. Specify this bind context to allow invalid file name characters to appear in file names. By default, a call to the IShellFolder::ParseDisplayName method rejects characters that are illegal in file names. This bind context is meaningful only in conjunction with the STR_FILE_SYS_FIND_DATA bind context. + + /// + /// Introduced in Windows Vista. Specify this bind context to allow invalid file name characters to appear in file names. By default, + /// a call to the IShellFolder::ParseDisplayName method rejects characters that are illegal in file names. This bind context is + /// meaningful only in conjunction with the STR_FILE_SYS_FIND_DATA bind context. + /// public const string STR_NO_VALIDATE_FILENAME_CHARS = "NoValidateFilenameChars"; - /// Introduced in Windows Vista. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the Desktop folder to parse URLs. If this bind context is specified, it overrides STR_PARSE_PREFER_WEB_BROWSING. + + /// + /// Introduced in Windows Vista. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the + /// Desktop folder to parse URLs. If this bind context is specified, it overrides STR_PARSE_PREFER_WEB_BROWSING. + /// public const string STR_PARSE_ALLOW_INTERNET_SHELL_FOLDERS = "Allow binding to Internet shell folder handlers and negate STR_PARSE_PREFER_WEB_BROWSING"; - /// Introduced in Windows 7. Specify this bind context to instruct a data source's implementation of IShellFolder::ParseDisplayName to optimize the behavior of SHCreateItemFromParsingName. - /// Normally, SHCreateItemFromParsingName performs two binding operations on the name to be parsed: one through and one to IShellFolder::ParseDisplayName and one to create the Shell item.When the STR_PARSE_AND_CREATE_ITEM bind context is supported, the second bind is avoided by creating the Shell item during the IShellFolder::ParseDisplayName bind and storing the Shell item through IParseAndCreateItem::SetItem.SHCreateItemFromParsingName then uses the stored Shell item rather than creating one. - /// This parameter applies to the last element of the name that is parsed. For instance, in the name "C:\Folder1\File.txt, the data applies to File.txt. + + /// + /// Introduced in Windows 7. Specify this bind context to instruct a data source's implementation of IShellFolder::ParseDisplayName + /// to optimize the behavior of SHCreateItemFromParsingName. + /// + /// Normally, SHCreateItemFromParsingName performs two binding operations on the name to be parsed: one through and one to + /// IShellFolder::ParseDisplayName and one to create the Shell item.When the STR_PARSE_AND_CREATE_ITEM bind context is supported, the + /// second bind is avoided by creating the Shell item during the IShellFolder::ParseDisplayName bind and storing the Shell item + /// through IParseAndCreateItem::SetItem.SHCreateItemFromParsingName then uses the stored Shell item rather than creating one. + /// + /// + /// This parameter applies to the last element of the name that is parsed. For instance, in the name "C:\Folder1\File.txt, the data + /// applies to File.txt. + /// + /// public const string STR_PARSE_AND_CREATE_ITEM = "ParseAndCreateItem"; - /// Windows Vista only. Specify that, when parsing a URL, this bind context should not require the URL to exist before generating an IDList for it. Specify this bind context along with STR_PARSE_PREFER_FOLDER_BROWSING when the client desires that the Internet Shell folder handlers generate an IDList for the URL if a DAV folder cannot be created for the given URL. + + /// + /// Windows Vista only. Specify that, when parsing a URL, this bind context should not require the URL to exist before generating an + /// IDList for it. Specify this bind context along with STR_PARSE_PREFER_FOLDER_BROWSING when the client desires that the Internet + /// Shell folder handlers generate an IDList for the URL if a DAV folder cannot be created for the given URL. + /// public const string STR_PARSE_DONT_REQUIRE_VALIDATED_URLS = "Do not require validated URLs"; - /// Introduced in Windows 7. The IShellFolder::ParseDisplayName method sets this property to tell the caller that the returned IDList was bound to the ProgID specified with STR_PARSE_WITH_EXPLICIT_PROGID or the application specified with STR_PARSE_WITH_EXPLICIT_ASSOCAPP. When STR_PARSE_EXPLICIT_ASSOCIATION_SUCCESSFUL is absent, the ProgID or application was not bound into the IDList. + + /// + /// Introduced in Windows 7. The IShellFolder::ParseDisplayName method sets this property to tell the caller that the returned IDList + /// was bound to the ProgID specified with STR_PARSE_WITH_EXPLICIT_PROGID or the application specified with + /// STR_PARSE_WITH_EXPLICIT_ASSOCAPP. When STR_PARSE_EXPLICIT_ASSOCIATION_SUCCESSFUL is absent, the ProgID or application was not + /// bound into the IDList. + /// public const string STR_PARSE_EXPLICIT_ASSOCIATION_SUCCESSFUL = "ExplicitAssociationSuccessful"; - /// Introduced in Windows Vista. Specify this bind context to pass the original item that is being re-parsed when that item is stored as a IShellItem object that also implements the IParentAndItem interface. Before Windows 7 this value was not defined in a header file. It could be defined by the caller or passed as its string value of L"ParseOriginalItem". As of Windows 7, the value is defined in Shlobj.h. Note that this is a different header than the other STR constants. + + /// + /// Introduced in Windows Vista. Specify this bind context to pass the original item that is being re-parsed when that item is stored + /// as a IShellItem object that also implements the IParentAndItem interface. Before Windows 7 this value was not defined in a header + /// file. It could be defined by the caller or passed as its string value of L"ParseOriginalItem". As of Windows 7, the value is + /// defined in Shlobj.h. Note that this is a different header than the other STR constants. + /// public const string STR_PARSE_PARTIAL_IDLIST = "ParseOriginalItem"; - /// Introduced in Windows XP. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the Desktop folder to parse URLs as if they were folders. Use this bind context to bind to a WebDAV server. + + /// + /// Introduced in Windows XP. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the Desktop + /// folder to parse URLs as if they were folders. Use this bind context to bind to a WebDAV server. + /// public const string STR_PARSE_PREFER_FOLDER_BROWSING = "Parse Prefer Folder Browsing"; - /// Introduced in Windows Vista. Specify this bind context to prevent a call to the IShellFolder::ParseDisplayName method on the Desktop folder form parsing URLs. This bind context can be overridden by STR_PARSE_ALLOW_INTERNET_SHELL_FOLDERS. + + /// + /// Introduced in Windows Vista. Specify this bind context to prevent a call to the IShellFolder::ParseDisplayName method on the + /// Desktop folder form parsing URLs. This bind context can be overridden by STR_PARSE_ALLOW_INTERNET_SHELL_FOLDERS. + /// public const string STR_PARSE_PREFER_WEB_BROWSING = "Do not bind to Internet shell folder handlers"; - /// Introduced in Windows Vista. Specify this bind context to override the default property store used by the IShellFolder::ParseDisplayName method, and use the property store specified as the bind parameter instead. Applies to delegate folders. + + /// + /// Introduced in Windows Vista. Specify this bind context to override the default property store used by the + /// IShellFolder::ParseDisplayName method, and use the property store specified as the bind parameter instead. Applies to delegate folders. + /// public const string STR_PARSE_PROPERTYSTORE = "DelegateNamedProperties"; - /// Introduced in Windows XP SP2. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the Desktop folder to use the "shell:" prefix notation to access files. + + /// + /// Introduced in Windows XP SP2. Specify this bind context to enable a call to the IShellFolder::ParseDisplayName method on the + /// Desktop folder to use the "shell:" prefix notation to access files. + /// public const string STR_PARSE_SHELL_PROTOCOL_TO_FILE_OBJECTS = "Parse Shell Protocol To File Objects"; - /// Introduced in Windows Vista. Specify this bind context to cause a call to the IShellFolder::ParseDisplayName method to display the network diagnostics dialog if the parsing of a network path fails. + + /// + /// Introduced in Windows Vista. Specify this bind context to cause a call to the IShellFolder::ParseDisplayName method to display + /// the network diagnostics dialog if the parsing of a network path fails. + /// public const string STR_PARSE_SHOW_NET_DIAGNOSTICS_UI = "Show network diagnostics UI"; - /// Introduced in Windows Vista. Specify this bind context to cause a call to the IShellFolder::ParseDisplayName method to skip checking the network shares cache and contact the network server directly. Information about network shares is cached to improve performance, and IShellFolder::ParseDisplayName checks this cache by default. + + /// + /// Introduced in Windows Vista. Specify this bind context to cause a call to the IShellFolder::ParseDisplayName method to skip + /// checking the network shares cache and contact the network server directly. Information about network shares is cached to improve + /// performance, and IShellFolder::ParseDisplayName checks this cache by default. + /// public const string STR_PARSE_SKIP_NET_CACHE = "Skip Net Resource Cache"; - /// Introduced in Windows XP. Specify this bind context to pass parsed properties to the IShellFolder::ParseDisplayName method for a delegate namespace. The namespace can use the passed properties instead of attempting to parse the name itself. + + /// + /// Introduced in Windows XP. Specify this bind context to pass parsed properties to the IShellFolder::ParseDisplayName method for a + /// delegate namespace. The namespace can use the passed properties instead of attempting to parse the name itself. + /// public const string STR_PARSE_TRANSLATE_ALIASES = "Parse Translate Aliases"; - /// Introduced in Windows 7. Specify this property to cause a call to the IShellFolder::ParseDisplayName method to return an IDList bound to the file type association handler for the application. + + /// + /// Introduced in Windows 7. Specify this property to cause a call to the IShellFolder::ParseDisplayName method to return an IDList + /// bound to the file type association handler for the application. + /// public const string STR_PARSE_WITH_EXPLICIT_ASSOCAPP = "ExplicitAssociationApp"; - /// Introduced in Windows 7. Specify this property to cause a call to the IShellFolder::ParseDisplayName method to return an IDList bound to the file association handler of the provided ProgID. + /// + /// Introduced in Windows 7. Specify this property to cause a call to the IShellFolder::ParseDisplayName method to return an IDList + /// bound to the file association handler of the provided ProgID. + /// public const string STR_PARSE_WITH_EXPLICIT_PROGID = "ExplicitProgid"; - /// Windows Vista only. A parsing bind context that is used to pass a set of properties and the item's name when calling IShellFolder::ParseDisplayName. The object in the bind context implements IPropertyStore and is retrieved by calling IBindCtx::GetObjectParam. - /// DBFolder is a Shell data source that represents items in search results and query-based views.DBFolder retrieves these items by querying the Windows Search system.Items in the search results are identified through a protocol scheme, for example "file:" or "mapi:". DBFolder provides the behavior for these items by delegating to Shell data sources that are created for these protocols. See Developing Protocol Handler Add-ins for more information. - /// When DBFolder delegates its parsing operation to the Shell data sources that support Windows Search protocols, this bind context provides access to values that were returned in the query result for that item. This includes the following: + /// + /// Windows Vista only. A parsing bind context that is used to pass a set of properties and the item's name when calling + /// IShellFolder::ParseDisplayName. The object in the bind context implements IPropertyStore and is retrieved by calling IBindCtx::GetObjectParam. + /// + /// DBFolder is a Shell data source that represents items in search results and query-based views.DBFolder retrieves these items by + /// querying the Windows Search system.Items in the search results are identified through a protocol scheme, for example "file:" or + /// "mapi:". DBFolder provides the behavior for these items by delegating to Shell data sources that are created for these protocols. + /// See Developing Protocol Handler Add-ins for more information. + /// + /// + /// When DBFolder delegates its parsing operation to the Shell data sources that support Windows Search protocols, this bind context + /// provides access to values that were returned in the query result for that item. This includes the following: + /// /// - /// System.ItemType (PKEY_ItemType) - /// System.ParsingPath (PKEY_ParsingPath) - /// System.ItemPathDisplay (PKEY_ItemPathDisplay) - /// System.ItemNameDisplay (PKEY_ItemNameDisplay) + /// + /// System.ItemType (PKEY_ItemType) + /// + /// + /// System.ParsingPath (PKEY_ParsingPath) + /// + /// + /// System.ItemPathDisplay (PKEY_ItemPathDisplay) + /// + /// + /// System.ItemNameDisplay (PKEY_ItemNameDisplay) + /// /// - /// This bind context can also be used to parse a DBFolder item if a client has a set of properties that define the item.In this case an empty name should be passed to IShellFolder::ParseDisplayName. - /// Before Windows 7, this value was not defined in a header file.It could be defined by the caller or passed as its string value: L"ParseWithProperties". As of Windows 7, the value is defined in Shlobj.h.Note that this is a different header than where the other STR constants are defined. + /// + /// This bind context can also be used to parse a DBFolder item if a client has a set of properties that define the item.In this case + /// an empty name should be passed to IShellFolder::ParseDisplayName. + /// + /// + /// Before Windows 7, this value was not defined in a header file.It could be defined by the caller or passed as its string value: + /// L"ParseWithProperties". As of Windows 7, the value is defined in Shlobj.h.Note that this is a different header than where the + /// other STR constants are defined. + /// + /// public const string STR_PARSE_WITH_PROPERTIES = "ParseWithProperties"; - /// Introduced in Windows 8. Specify this bind context to indicate that the bind context parameter is a property bag (IPropertyBag) used to pass VARIANT values in the bind context. See the Remarks section for further details. + + /// + /// Introduced in Windows 8. Specify this bind context to indicate that the bind context parameter is a property bag (IPropertyBag) + /// used to pass VARIANT values in the bind context. See the Remarks section for further details. + /// public const string STR_PROPERTYBAG_PARAM = "SHBindCtxPropertyBag"; + /// The string referrer identifier public const string STR_REFERRER_IDENTIFIER = "Referrer Identifier"; - /// Introduced in Windows XP. Specify this bind context to cause calls to the IShellFolder::ParseDisplayName or IShellFolder::BindToObject methods to ignore a particular Shell namespace extension when parsing or binding. The CLSID of the namespace to ignore is provided by the IPersist::GetClassID method of the bind parameter. + /// + /// Introduced in Windows XP. Specify this bind context to cause calls to the IShellFolder::ParseDisplayName or + /// IShellFolder::BindToObject methods to ignore a particular Shell namespace extension when parsing or binding. The CLSID of the + /// namespace to ignore is provided by the IPersist::GetClassID method of the bind parameter. + /// public const string STR_SKIP_BINDING_CLSID = "Skip Binding CLSID"; + /// The string tab reuse identifier public const string STR_TAB_REUSE_IDENTIFIER = "Tab Reuse Identifier"; /// Not used. public const string STR_TRACK_CLSID = "Track the CLSID"; + /// Values that specify from which category the list of destinations should be retrieved. [PInvokeData("Shobjidl.h", MSDNShortId = "dd378410")] public enum APPDOCLISTTYPE @@ -142,12 +369,102 @@ namespace Vanara.PInvoke FREQUENT } + /// The type of media in a given drive. + [PInvokeData("shobjidl.h", MSDNShortId = "ebc826a2-d7ea-413a-836b-c7e51f13692a")] + [Flags] + public enum ARCONTENT + { + /// Use the Autorun.inf file. This is the traditional AutoRun behavior. + ARCONTENT_AUTORUNINF = 0x00000002, + + /// AutoRun audio CDs. + ARCONTENT_AUDIOCD = 0x00000004, + + /// AutoRun DVDs. + ARCONTENT_DVDMOVIE = 0x00000008, + + /// AutoPlay blank CD-Rs and CD-RWs. + ARCONTENT_BLANKCD = 0x00000010, + + /// AutoPlay blank DVD-Rs and DVD-RAMs. + ARCONTENT_BLANKDVD = 0x00000020, + + /// AutoRun if the media is formatted and the content does not fall under a type covered by one of the other flags. + ARCONTENT_UNKNOWNCONTENT = 0x00000040, + + /// AutoPlay if the content consists of file types defined as pictures, such as .bmp and .jpg files. + ARCONTENT_AUTOPLAYPIX = 0x00000080, + + /// AutoPlay if the content consists of file types defined as music, such as MP3 files. + ARCONTENT_AUTOPLAYMUSIC = 0x00000100, + + /// AutoPlay if the content consists of file types defined as video files. + ARCONTENT_AUTOPLAYVIDEO = 0x00000200, + + /// Introduced in Windows Vista. AutoPlay video CDs (VCDs). + ARCONTENT_VCD = 0x00000400, + + /// Introduced in Windows Vista. AutoPlay Super Video CD (SVCD) media. + ARCONTENT_SVCD = 0x00000800, + + /// Introduced in Windows Vista. AutoPlay DVD-Audio media. + ARCONTENT_DVDAUDIO = 0x00001000, + + /// + /// AutoPlay blank recordable high definition DVD media in the Blu-ray Disc™ format (BD-R or BD-RW). Note: Prior to Windows 7, + /// this value was defined to specify non-recordable media in the HD DVD format. + /// + ARCONTENT_BLANKBD = 0x00002000, + + /// Introduced in Windows Vista. AutoPlay high definition DVD media in the Blu-ray Disc™ format. + ARCONTENT_BLURAY = 0x00004000, + + /// Introduced in Windows 8. + ARCONTENT_CAMERASTORAGE = 0x00008000, + + /// Introduced in Windows 8. + ARCONTENT_CUSTOMEVENT = 0x00010000, + + /// Introduced in Windows Vista. AutoPlay empty but formatted media. + ARCONTENT_NONE = 0x00000000, + + /// + /// Introduced in Windows Vista. A mask that denotes valid ARCONTENT flag values for media types. This mask does not include + /// ARCONTENT_PHASE values. + /// + ARCONTENT_MASK = 0x0001FFFE, + + /// + /// Introduced in Windows Vista. AutoPlay is searching the media. The phase of the search (presniff, sniffing, or final) is unknown. + /// + ARCONTENT_PHASE_UNKNOWN = 0x00000000, + + /// + /// Introduced in Windows Vista. The contents of the media are known before the media is searched, due to the media type; for + /// instance, audio CDs and DVD movies. + /// + ARCONTENT_PHASE_PRESNIFF = 0x10000000, + + /// + /// Introduced in Windows Vista. AutoPlay is currently searching the media. Any results reported during this phase should be + /// considered a partial list as more content types might still be found. + /// + ARCONTENT_PHASE_SNIFFING = 0x20000000, + + /// Introduced in Windows Vista. AutoPlay has finished searching the media. Results reported are final. + ARCONTENT_PHASE_FINAL = 0x40000000, + + /// Introduced in Windows Vista. A mask that denotes valid ARCONTENT_PHASE values. + ARCONTENT_PHASE_MASK = 0x70000000, + } + /// Specifies the enumeration handler filter applied to the full list of handlers in SHAssocEnumHandlers. [PInvokeData("shobjidl_core.h", MSDNShortId = "83db466b-e00c-4015-879f-c5c222f45b8c")] public enum ASSOC_FILTER { /// Return all handlers. ASSOC_FILTER_NONE = 0x0, + /// /// Return only recommended handlers. A handler sets its recommended status in the registry when it is installed. An initial /// status of non-recommended can later be promoted to recommended as a result of user action. @@ -155,17 +472,27 @@ namespace Vanara.PInvoke ASSOC_FILTER_RECOMMENDED = 0x1, } - /// Specifies the source of the default association for a file name extension. Used by methods of the IApplicationAssociationRegistration interface. - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-associationlevel - // typedef enum ASSOCIATIONLEVEL { AL_MACHINE , AL_EFFECTIVE , AL_USER } ; + /// + /// + /// Specifies the source of the default association for a file name extension. Used by methods of the + /// IApplicationAssociationRegistration interface. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-associationlevel typedef enum ASSOCIATIONLEVEL + // { AL_MACHINE , AL_EFFECTIVE , AL_USER } ; [PInvokeData("shobjidl_core.h", MSDNShortId = "846ce9f4-092a-420d-be73-0951efc4368f")] public enum ASSOCIATIONLEVEL { /// The machine-level default application association. AL_MACHINE, + /// The effective default for the current user. This value should be used by most applications. AL_EFFECTIVE, - /// The per-user default application association. If this value is used and no per-user default is declared, the calling method fails with a value of . + + /// + /// The per-user default application association. If this value is used and no per-user default is declared, the calling method + /// fails with a value of . + /// AL_USER, } @@ -178,17 +505,51 @@ namespace Vanara.PInvoke { /// Indicates a file name extension, such as .htm or .mp3. AT_FILEEXTENSION, + /// Indicates a protocol, such as http or mailto. AT_URLPROTOCOL, + /// /// Indicates the owner of the startmenu client for a mail or Internet hyperlink. As of Windows 7, this value is used only for /// the MAPI sendmail client. /// AT_STARTMENUCLIENT, + /// Indicates the MIME type, such as audio/mp3. AT_MIMETYPE, } + /// + /// Values used by the SHGetItemFromDataObject function to specify options concerning the processing of the source object. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/ne-shobjidl_core-dataobj_get_item_flags typedef enum + // DATAOBJ_GET_ITEM_FLAGS { DOGIF_DEFAULT , DOGIF_TRAVERSE_LINK , DOGIF_NO_HDROP , DOGIF_NO_URL , DOGIF_ONLY_IF_ONE } ; + [PInvokeData("shobjidl_core.h", MSDNShortId = "7a5ee490-cf30-452a-ade2-22d875ce0358")] + [Flags] + public enum DATAOBJ_GET_ITEM_FLAGS + { + /// No special options. + DOGIF_DEFAULT = 0x0000, + + /// If the source object is a link, base the IShellItem on the link's target rather than the link file itself. + DOGIF_TRAVERSE_LINK = 0x0001, + + /// + /// If the source data object does not contain data in the CFSTR_SHELLIDLIST format, which identifies the object through an + /// IDList, do not revert to the CF_HDROP format, which uses a file path, as an alternative in the transfer. + /// + DOGIF_NO_HDROP = 0x0002, + + /// + /// If the source data object does not contain data in the CFSTR_SHELLIDLIST format, which identifies the object through an + /// IDList, do not revert to the CFSTR_INETURL clipboard format, which uses a URL, as an alternative in the transfer. + /// + DOGIF_NO_URL = 0x0004, + + /// If the source object is an array of items, use it only if the array contains just one item. + DOGIF_ONLY_IF_ONE = 0x0008, + } + /// One of the following values that indicate which known category to add to the list [PInvokeData("Shobjidl.h", MSDNShortId = "dd378397")] public enum KNOWNDESTCATEGORY @@ -200,7 +561,9 @@ namespace Vanara.PInvoke KDC_RECENT = 2 } - /// Flags that specify the type of path information to retrieve. This parameter can be a combination of the following values. + /// + /// Flags that specify the type of path information to retrieve. This parameter can be a combination of the following values. + /// [PInvokeData("Shobjidl.h", MSDNShortId = "bb774944")] [Flags] public enum SLGP @@ -212,32 +575,50 @@ namespace Vanara.PInvoke SLGP_UNCPRIORITY = 2, /// - /// Retrieves the raw path name. A raw path is something that might not exist and may include environment variables that need to be expanded. + /// Retrieves the raw path name. A raw path is something that might not exist and may include environment variables that need to + /// be expanded. /// SLGP_RAWPATH = 4, /// - /// Windows Vista and later. Retrieves the path, if possible, of the shortcut's target relative to the path set by a previous call to IShellLink::SetRelativePath. + /// Windows Vista and later. Retrieves the path, if possible, of the shortcut's target relative to the path set by a previous + /// call to IShellLink::SetRelativePath. /// SLGP_RELATIVEPRIORITY = 8 } /// - /// Used with the IFolderView::Items, IFolderView::ItemCount, and IShellView::GetItemObject methods to restrict or control the items in their collections. + /// Used with the IFolderView::Items, IFolderView::ItemCount, and IShellView::GetItemObject methods to restrict or control the items + /// in their collections. /// public enum SVGIO : uint { - /// Refers to the background of the view. It is used with IID_IContextMenu to get a shortcut menu for the view background and with IID_IDispatch to get a dispatch interface that represents the ShellFolderView object for the view. + /// + /// Refers to the background of the view. It is used with IID_IContextMenu to get a shortcut menu for the view background and + /// with IID_IDispatch to get a dispatch interface that represents the ShellFolderView object for the view. + /// SVGIO_BACKGROUND = 0, - /// Refers to the currently selected items. Used with IID_IDataObject to retrieve a data object that represents the selected items. + + /// + /// Refers to the currently selected items. Used with IID_IDataObject to retrieve a data object that represents the selected items. + /// SVGIO_SELECTION = 0x1, + /// Used in the same way as SVGIO_SELECTION but refers to all items in the view. SVGIO_ALLVIEW = 0x2, - /// Used in the same way as SVGIO_SELECTION but refers to checked items in views where checked mode is supported. For more details on checked mode, see FOLDERFLAGS. + + /// + /// Used in the same way as SVGIO_SELECTION but refers to checked items in views where checked mode is supported. For more + /// details on checked mode, see FOLDERFLAGS. + /// SVGIO_CHECKED = 0x3, + /// Masks all bits but those corresponding to the _SVGIO flags. SVGIO_TYPE_MASK = 0xf, - /// Returns the items in the order they appear in the view. If this flag is not set, the selected item will be listed first. + + /// + /// Returns the items in the order they appear in the view. If this flag is not set, the selected item will be listed first. + /// SVGIO_FLAG_VIEWORDER = 0x80000000, } @@ -261,24 +642,33 @@ namespace Vanara.PInvoke public interface IApplicationAssociationRegistration { void QueryCurrentDefault([MarshalAs(UnmanagedType.LPWStr)] string pszQuery, ASSOCIATIONTYPE atQueryType, ASSOCIATIONLEVEL alQueryLevel, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszAssociation); + void QueryAppIsDefault([MarshalAs(UnmanagedType.LPWStr)] string pszQuery, ASSOCIATIONTYPE atQueryType, ASSOCIATIONLEVEL alQueryLevel, [MarshalAs(UnmanagedType.LPWStr)] string pszAppRegistryName, [MarshalAs(UnmanagedType.Bool)] out bool pfDefault); + void QueryAppIsDefaultAll(ASSOCIATIONLEVEL alQueryLevel, [MarshalAs(UnmanagedType.LPWStr)] string pszAppRegistryName, [MarshalAs(UnmanagedType.Bool)] out bool pfDefault); + void SetAppAsDefault([MarshalAs(UnmanagedType.LPWStr)] string pszAppRegistryName, [MarshalAs(UnmanagedType.LPWStr)] string pszSet, ASSOCIATIONTYPE atSetType); + void SetAppAsDefaultAll([MarshalAs(UnmanagedType.LPWStr)] string pszAppRegistryName); + void ClearUserAssociations(); } - /// Exposes methods that allow an application to remove one or all destinations from the Recent or Frequent categories in a Jump List. + /// + /// Exposes methods that allow an application to remove one or all destinations from the Recent or Frequent categories in a Jump List. + /// [SuppressUnmanagedCodeSecurity] [ComImport, Guid("12337d35-94c6-48a0-bce7-6a9c69d4d600"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("Shobjidl.h", MSDNShortId = "dd378413")] public interface IApplicationDestinations { /// - /// Specifies a unique AppUserModelID for the application from whose taskbar button's Jump List the methods of this interface will remove - /// destinations. This method is optional. + /// Specifies a unique AppUserModelID for the application from whose taskbar button's Jump List the methods of this interface + /// will remove destinations. This method is optional. /// - /// Pointer to the AppUserModelID of the process whose taskbar button representation receives the Jump List. + /// + /// Pointer to the AppUserModelID of the process whose taskbar button representation receives the Jump List. + /// void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID); /// Removes a single destination from the Recent and Frequent categories in a Jump List. @@ -297,13 +687,15 @@ namespace Vanara.PInvoke public interface IApplicationDocumentLists { /// - /// Set the App User Model ID for the application retrieving this list. If an AppID is not provided via this method, the system will use a - /// heuristically determined ID. This method must be called before GetList. + /// Set the App User Model ID for the application retrieving this list. If an AppID is not provided via this method, the system + /// will use a heuristically determined ID. This method must be called before GetList. /// /// App Id. void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID); - /// Retrieve an IEnumObjects or IObjectArray for IShellItems and/or IShellLinks. Items may appear in both the frequent and recent lists. + /// + /// Retrieve an IEnumObjects or IObjectArray for IShellItems and/or IShellLinks. Items may appear in both the frequent and recent lists. + /// /// Which of the known list types to retrieve /// The number of items desired. /// The interface Id that the return value should be queried for. @@ -357,7 +749,7 @@ namespace Vanara.PInvoke /// The Shell icon ID. void SetDefaultIcon([In, MarshalAs(UnmanagedType.LPWStr)] string pszFile, int iIcon); } - + /// Exposes a method that allows enumeration of a collection of handlers associated with particular file name extensions. [ComImport, Guid("973810ae-9599-4b88-9e4d-6ee98c9552da"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("shobjidl_core.h", MSDNShortId = "9e173cb3-bd73-437c-8853-c13c8b6f216f")] @@ -375,9 +767,9 @@ namespace Vanara.PInvoke } /// - /// Exposes a standard set of methods used to enumerate the pointers to item identifier lists (PIDLs) of the items in a Shell folder. When a folder's - /// IShellFolder::EnumObjects method is called, it creates an enumeration object and passes a pointer to the object's IEnumIDList interface back to the - /// calling application. + /// Exposes a standard set of methods used to enumerate the pointers to item identifier lists (PIDLs) of the items in a Shell folder. + /// When a folder's IShellFolder::EnumObjects method is called, it creates an enumeration object and passes a pointer to the object's + /// IEnumIDList interface back to the calling application. /// [SuppressUnmanagedCodeSecurity] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F2-0000-0000-C000-000000000046")] @@ -385,22 +777,25 @@ namespace Vanara.PInvoke public interface IEnumIDList { /// - /// Retrieves the specified number of item identifiers in the enumeration sequence and advances the current position by the number of items retrieved. + /// Retrieves the specified number of item identifiers in the enumeration sequence and advances the current position by the + /// number of items retrieved. /// /// The number of elements in the array referenced by the rgelt parameter. /// - /// The address of a pointer to an array of ITEMIDLIST pointers that receive the item identifiers. The implementation must allocate these item - /// identifiers using CoTaskMemAlloc. The calling application is responsible for freeing the item identifiers using CoTaskMemFree. + /// The address of a pointer to an array of ITEMIDLIST pointers that receive the item identifiers. The implementation must + /// allocate these item identifiers using CoTaskMemAlloc. The calling application is responsible for freeing the item identifiers + /// using CoTaskMemFree. /// /// - /// A pointer to a value that receives a count of the item identifiers actually returned in rgelt. The count can be smaller than the value specified - /// in the celt parameter. This parameter can be NULL on entry only if celt = 1, because in that case the method can only retrieve one (S_OK) or zero - /// (S_FALSE) items. + /// A pointer to a value that receives a count of the item identifiers actually returned in rgelt. The count can be smaller than + /// the value specified in the celt parameter. This parameter can be NULL on entry only if celt = 1, because in that case the + /// method can only retrieve one (S_OK) or zero (S_FALSE) items. /// /// - /// Returns S_OK if the method successfully retrieved the requested celt elements. This method only returns S_OK if the full count of requested items - /// are successfully retrieved. S_FALSE indicates that more items were requested than remained in the enumeration.The value pointed to by the - /// pceltFetched parameter specifies the actual number of items retrieved. Note that the value will be 0 if there are no more items to retrieve. + /// Returns S_OK if the method successfully retrieved the requested celt elements. This method only returns S_OK if the full + /// count of requested items are successfully retrieved. S_FALSE indicates that more items were requested than remained in the + /// enumeration.The value pointed to by the pceltFetched parameter specifies the actual number of items retrieved. Note that the + /// value will be 0 if there are no more items to retrieve. /// [PreserveSig] HRESULT Next(uint celt, out IntPtr rgelt, out uint pceltFetched); @@ -414,7 +809,8 @@ namespace Vanara.PInvoke /// Creates a new item enumeration object with the same contents and state as the current one. /// - /// The address of a pointer to the new enumeration object. The calling application must eventually free the new object by calling its Release member function. + /// The address of a pointer to the new enumeration object. The calling application must eventually free the new object by + /// calling its Release member function. /// [return: MarshalAs(UnmanagedType.Interface)] IEnumIDList Clone(); @@ -428,14 +824,15 @@ namespace Vanara.PInvoke /// Stores file system information in a WIN32_FIND_DATA structure. This information is used by IShellFolder::ParseDisplayName. /// A pointer to the WIN32_FIND_DATA structure that specifies the data you want to store. void SetFindData([In] ref WIN32_FIND_DATA pfd); + /// Gets the file system information stored in the WIN32_FIND_DATA structure. /// A pointer to the WIN32_FIND_DATA structure that receives the data. void GetFindData(out WIN32_FIND_DATA pfd); } /// - /// Extends IFileSystemBindData, which stores file system information for optimizing calls to IShellFolder::ParseDisplayName. This interface adds the - /// ability set or get file ID or junction class identifier (CLSID). + /// Extends IFileSystemBindData, which stores file system information for optimizing calls to IShellFolder::ParseDisplayName. This + /// interface adds the ability set or get file ID or junction class identifier (CLSID). /// /// [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("3acf075f-71db-4afa-81f0-3fc4fdf2a5b8")] @@ -445,20 +842,38 @@ namespace Vanara.PInvoke /// Stores file system information in a WIN32_FIND_DATA structure. This information is used by IShellFolder::ParseDisplayName. /// A pointer to the WIN32_FIND_DATA structure that specifies the data you want to store. new void SetFindData([In] ref WIN32_FIND_DATA pfd); + /// Gets the file system information stored in the WIN32_FIND_DATA structure. /// A pointer to the WIN32_FIND_DATA structure that receives the data. new void GetFindData(out WIN32_FIND_DATA pfd); + /// Sets the unique file identifier for the current file. - /// A unique file identifier for the current file. liFileID is a value that is a concatenation of the values nFileIndexHigh and nFileIndexlow, noted in structure _by_handle_file_information. + /// + /// A unique file identifier for the current file. liFileID is a value that is a concatenation of the values nFileIndexHigh and + /// nFileIndexlow, noted in structure _by_handle_file_information. + /// void SetFileID(long liFileID); + /// Gets the unique file identifier for the current file. - /// When this method returns successfully, receives a pointer to the unique file identifier for the current file. pliFileID is a pointer to a value that is a concatenation of the values nFileIndexHigh and nFileIndexlow, noted in structure _by_handle_file_information. + /// + /// When this method returns successfully, receives a pointer to the unique file identifier for the current file. pliFileID is a + /// pointer to a value that is a concatenation of the values nFileIndexHigh and nFileIndexlow, noted in structure _by_handle_file_information. + /// long GetFileID(); - /// Sets the class identifier (CLSID) of the object that implements IShellFolder, if the current item is a junction point. + + /// + /// Sets the class identifier (CLSID) of the object that implements IShellFolder, if the current item is a junction point. + /// /// The CLSID for the object that implements IShellFolder with a junction point as its current item. void SetJunctionCLSID([In, MarshalAs(UnmanagedType.LPStruct)] Guid clsid); - /// Gets the class identifier (CLSID) of the object that implements IShellFolder for the item, if the item is a junction point. - /// When this method returns successfully, receives a pointer to the CLSID of the object that implements IShellFolder for the current item, if the item is a junction point. + + /// + /// Gets the class identifier (CLSID) of the object that implements IShellFolder for the item, if the item is a junction point. + /// + /// + /// When this method returns successfully, receives a pointer to the CLSID of the object that implements IShellFolder for the + /// current item, if the item is a junction point. + /// [return: MarshalAs(UnmanagedType.LPStruct)] Guid GetJunctionCLSID(); } @@ -473,7 +888,9 @@ namespace Vanara.PInvoke /// The number of objects in the collection. uint GetCount(); - /// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID. + /// + /// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID. + /// /// The index of the object /// Reference to the desired interface ID. /// Receives the interface pointer requested in riid. @@ -481,7 +898,9 @@ namespace Vanara.PInvoke object GetAt([In] uint uiIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); } - /// Extends the IObjectArray interface by providing methods that enable clients to add and remove objects that support IUnknown in a collection. + /// + /// Extends the IObjectArray interface by providing methods that enable clients to add and remove objects that support IUnknown in a collection. + /// [SuppressUnmanagedCodeSecurity] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("5632b1a4-e38a-400a-928a-d4cd63230295"), CoClass(typeof(CEnumerableObjectCollection))] [PInvokeData("Shobjidl.h", MSDNShortId = "dd378307")] @@ -491,7 +910,9 @@ namespace Vanara.PInvoke /// The number of objects in the collection. uint GetCount(); - /// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID. + /// + /// Provides a pointer to a specified object's interface. The object and interface are specified by index and interface ID. + /// /// The index of the object /// Reference to the desired interface ID. /// Receives the interface pointer requested in riid. @@ -515,8 +936,8 @@ namespace Vanara.PInvoke } /// - /// Exposes methods that allow implementers of a custom IAssocHandler object to provide access to its explicit Application User Model ID - /// (AppUserModelID). This information is used to determine whether a particular file type can be added to an application's Jump List. + /// Exposes methods that allow implementers of a custom IAssocHandler object to provide access to its explicit Application User Model + /// ID (AppUserModelID). This information is used to determine whether a particular file type can be added to an application's Jump List. /// [SuppressUnmanagedCodeSecurity] [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("36db0196-9665-46d1-9ba7-d3709eecf9ed")] @@ -571,6 +992,7 @@ namespace Vanara.PInvoke /// existing site at which point the object no longer knows its site. /// void SetSite([In, MarshalAs(UnmanagedType.IUnknown)] object pUnkSite); + /// Retrieves the latest site passed using SetSite. /// The IID of the interface pointer that should be returned in ppvSite. /// @@ -585,8 +1007,8 @@ namespace Vanara.PInvoke } /// - /// Exposes methods that the Shell uses to retrieve flags and info tip information for an item that resides in an IShellFolder implementation. Info tips - /// are usually displayed inside a tooltip control. + /// Exposes methods that the Shell uses to retrieve flags and info tip information for an item that resides in an IShellFolder + /// implementation. Info tips are usually displayed inside a tooltip control. /// [ComImport, Guid("00021500-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb761359")] @@ -596,14 +1018,18 @@ namespace Vanara.PInvoke /// /// Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero (QITIPF_DEFAULT). /// - /// The address of a Unicode string pointer that, when this method returns successfully, receives the tip string pointer. Applications that implement - /// this method must allocate memory for ppwszTip by calling CoTaskMemAlloc. Calling applications must call CoTaskMemFree to free the memory when it - /// is no longer needed. - /// > + /// + /// The address of a Unicode string pointer that, when this method returns successfully, receives the tip string pointer. + /// Applications that implement this method must allocate memory for ppwszTip by calling CoTaskMemAlloc. Calling applications + /// must call CoTaskMemFree to free the memory when it is no longer needed. + /// + /// > void GetInfoTip(QITIP dwFlags, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppwszTip); /// Gets the information flags for an item. This method is not currently used. - /// A pointer to a value that receives the flags for the item. If no flags are to be returned, this value should be set to zero. + /// + /// A pointer to a value that receives the flags for the item. If no flags are to be returned, this value should be set to zero. + /// uint GetInfoFlags(); } @@ -624,7 +1050,8 @@ namespace Vanara.PInvoke /// Clones the first SHITEMID structure in an ITEMIDLIST structure. /// A pointer to the ITEMIDLIST structure to be cloned. /// - /// A pointer to an ITEMIDLIST structure that contains the first SHITEMID structure from the ITEMIDLIST structure specified by pidl. Returns NULL on failure. + /// A pointer to an ITEMIDLIST structure that contains the first SHITEMID structure from the ITEMIDLIST structure specified by pidl. + /// Returns NULL on failure. /// [DllImport(Lib.Shell32, ExactSpelling = true, SetLastError = false)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb776435")] @@ -632,10 +1059,12 @@ namespace Vanara.PInvoke /// Combines two ITEMIDLIST structures. /// A pointer to the first ITEMIDLIST structure. - /// A pointer to the second ITEMIDLIST structure. This structure is appended to the structure pointed to by pidl1. + /// + /// A pointer to the second ITEMIDLIST structure. This structure is appended to the structure pointed to by pidl1. + /// /// - /// Returns an ITEMIDLIST containing the combined structures. If you set either pidl1 or pidl2 to NULL, the returned ITEMIDLIST structure is a clone of - /// the non-NULL parameter. Returns NULL if pidl1 and pidl2 are both set to NULL. + /// Returns an ITEMIDLIST containing the combined structures. If you set either pidl1 or pidl2 to NULL, the returned ITEMIDLIST + /// structure is a clone of the non-NULL parameter. Returns NULL if pidl1 and pidl2 are both set to NULL. /// [DllImport(Lib.Shell32, ExactSpelling = true, SetLastError = false)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb776437")] @@ -643,8 +1072,8 @@ namespace Vanara.PInvoke /// Returns the ITEMIDLIST structure associated with a specified file path. /// - /// A pointer to a null-terminated Unicode string that contains the path. This string should be no more than MAX_PATH characters in length, including the - /// terminating null character. + /// A pointer to a null-terminated Unicode string that contains the path. This string should be no more than MAX_PATH characters in + /// length, including the terminating null character. /// /// Returns a pointer to an ITEMIDLIST structure that corresponds to the path. [DllImport(Lib.Shell32, CharSet = CharSet.Auto, SetLastError = false)] @@ -673,7 +1102,8 @@ namespace Vanara.PInvoke /// Retrieves the next SHITEMID structure in an ITEMIDLIST structure. /// A pointer to a particular SHITEMID structure in a larger ITEMIDLIST structure. /// - /// Returns a pointer to the SHITEMID structure that follows the one specified by pidl. Returns NULL if pidl points to the last SHITEMID structure. + /// Returns a pointer to the SHITEMID structure that follows the one specified by pidl. Returns NULL if pidl points to the last + /// SHITEMID structure. /// [DllImport(Lib.Shell32, ExactSpelling = true, SetLastError = false)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb776442")] @@ -710,10 +1140,12 @@ namespace Vanara.PInvoke /// Tests whether an ITEMIDLIST structure is the parent of another ITEMIDLIST structure. /// A pointer to an ITEMIDLIST (PIDL) structure that specifies the parent. This must be an absolute PIDL. /// A pointer to an ITEMIDLIST (PIDL) structure that specifies the child. This must be an absolute PIDL. - /// A Boolean value that is set to TRUE to test for immediate parents of pidl2, or FALSE to test for any parents of pidl2. + /// + /// A Boolean value that is set to TRUE to test for immediate parents of pidl2, or FALSE to test for any parents of pidl2. + /// /// - /// Returns TRUE if pidl1 is a parent of pidl2. If fImmediate is set to TRUE, the function only returns TRUE if pidl1 is the immediate parent of pidl2. - /// Otherwise, the function returns FALSE. + /// Returns TRUE if pidl1 is a parent of pidl2. If fImmediate is set to TRUE, the function only returns TRUE if pidl1 is the + /// immediate parent of pidl2. Otherwise, the function returns FALSE. /// [DllImport(Lib.Shell32, ExactSpelling = true, SetLastError = false)] [return: MarshalAs(UnmanagedType.Bool)] @@ -723,9 +1155,9 @@ namespace Vanara.PInvoke /// Retrieves the next SHITEMID structure in an ITEMIDLIST structure. /// A constant, unaligned, relative PIDL for which the next SHITEMID structure is being retrieved. /// - /// When this function returns, contains one of three results: If pidl is valid and not the last SHITEMID in the ITEMIDLIST, then it contains a pointer - /// to the next ITEMIDLIST structure. If the last ITEMIDLIST structure is passed, it contains NULL, which signals the end of the PIDL. For other values - /// of pidl, the return value is meaningless. + /// When this function returns, contains one of three results: If pidl is valid and not the last SHITEMID in the ITEMIDLIST, then it + /// contains a pointer to the next ITEMIDLIST structure. If the last ITEMIDLIST structure is passed, it contains NULL, which signals + /// the end of the PIDL. For other values of pidl, the return value is meaningless. /// [PInvokeData("Shobjidl.h", MSDNShortId = "bb776454")] public static IntPtr ILNext(IntPtr pidl) @@ -735,7 +1167,9 @@ namespace Vanara.PInvoke } /// Removes the last SHITEMID structure from an ITEMIDLIST structure. - /// A pointer to the ITEMIDLIST structure to be shortened. When the function returns, this variable points to the shortened structure. + /// + /// A pointer to the ITEMIDLIST structure to be shortened. When the function returns, this variable points to the shortened structure. + /// /// Returns TRUE if successful, FALSE otherwise. [DllImport(Lib.Shell32, ExactSpelling = true, SetLastError = false)] [return: MarshalAs(UnmanagedType.Bool)] @@ -744,8 +1178,8 @@ namespace Vanara.PInvoke /// Returns the ITEMIDLIST structure associated with a specified file path. /// - /// A pointer to a null-terminated Unicode string that contains the path. This string should be no more than MAX_PATH characters in length, including the - /// terminating null character. + /// A pointer to a null-terminated Unicode string that contains the path. This string should be no more than MAX_PATH characters in + /// length, including the terminating null character. /// /// Returns a pointer to an ITEMIDLIST structure that corresponds to the path. [DllImport(Lib.Shell32, EntryPoint = "ILCreateFromPathW", SetLastError = true)] @@ -753,8 +1187,8 @@ namespace Vanara.PInvoke public static extern IntPtr IntILCreateFromPath([MarshalAs(UnmanagedType.LPWStr)] string pszPath); /// - /// Specifies a unique application-defined Application User Model ID (AppUserModelID) that identifies the current process to the taskbar. This identifier - /// allows an application to group its associated processes and windows under a single taskbar button. + /// Specifies a unique application-defined Application User Model ID (AppUserModelID) that identifies the current process to the + /// taskbar. This identifier allows an application to group its associated processes and windows under a single taskbar button. /// /// Pointer to the AppUserModelID to assign to the current process. [DllImport(Lib.Shell32, ExactSpelling = true)] @@ -793,11 +1227,12 @@ namespace Vanara.PInvoke /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shassocenumhandlers - // SHSTDAPI SHAssocEnumHandlers( PCWSTR pszExtra, ASSOC_FILTER afFilter, IEnumAssocHandlers **ppEnumHandler ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shassocenumhandlers SHSTDAPI + // SHAssocEnumHandlers( PCWSTR pszExtra, ASSOC_FILTER afFilter, IEnumAssocHandlers **ppEnumHandler ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shobjidl_core.h", MSDNShortId = "83db466b-e00c-4015-879f-c5c222f45b8c")] public static extern HRESULT SHAssocEnumHandlers([MarshalAs(UnmanagedType.LPWStr)] string pszExtra, ASSOC_FILTER afFilter, out IEnumAssocHandlers ppEnumHandler); + /// /// Gets an enumeration interface that provides access to handlers associated with a given protocol. /// @@ -844,11 +1279,12 @@ namespace Vanara.PInvoke /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreateassociationregistration - // SHSTDAPI SHCreateAssociationRegistration( REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreateassociationregistration SHSTDAPI + // SHCreateAssociationRegistration( REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shobjidl_core.h", MSDNShortId = "7998f49d-2515-4c77-991e-62c0fefa43df")] public static extern HRESULT SHCreateAssociationRegistration([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IApplicationAssociationRegistration ppv); + /// /// Creates a standard icon extractor, whose defaults can be further configured via the IDefaultExtractIconInit interface. /// @@ -867,8 +1303,8 @@ namespace Vanara.PInvoke /// /// The intended usage for this function is as follows: /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreatedefaultextracticon - // HRESULT SHCreateDefaultExtractIcon( REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreatedefaultextracticon HRESULT + // SHCreateDefaultExtractIcon( REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shobjidl_core.h", MSDNShortId = "483dc9ae-4820-47f1-888e-ad7a6bdf3d29")] public static extern HRESULT SHCreateDefaultExtractIcon([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IDefaultExtractIconInit ppv); @@ -897,18 +1333,21 @@ namespace Vanara.PInvoke /// entry of HKEY_CLASSES_ROOT<b>*. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl/nf-shobjidl-shcreatedefaultpropertiesop - // SHSTDAPI SHCreateDefaultPropertiesOp( IShellItem *psi, IFileOperation **ppFileOp ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl/nf-shobjidl-shcreatedefaultpropertiesop SHSTDAPI + // SHCreateDefaultPropertiesOp( IShellItem *psi, IFileOperation **ppFileOp ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shobjidl.h", MSDNShortId = "5202ac48-16e7-4d64-8a69-2493036e1e11")] public static extern HRESULT SHCreateDefaultPropertiesOp(IShellItem psi, out IFileOperation ppFileOp); /// - /// Creates and initializes a Shell item object from a pointer to an item identifier list (PIDL). The resulting shell item object supports the IShellItem interface. + /// Creates and initializes a Shell item object from a pointer to an item identifier list (PIDL). The resulting shell item object + /// supports the IShellItem interface. /// /// The source PIDL. /// A reference to the IID of the requested interface. - /// When this function returns, contains the interface pointer requested in riid. This will typically be IShellItem or IShellItem2. + /// + /// When this function returns, contains the interface pointer requested in riid. This will typically be IShellItem or IShellItem2. + /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762133")] @@ -916,11 +1355,21 @@ namespace Vanara.PInvoke /// Creates and initializes a Shell item object from a parsing name. /// A pointer to a display name. - /// Optional. A pointer to a bind context used to pass parameters as inputs and outputs to the parsing function. These passed parameters are often specific to the data source and are documented by the data source owners. For example, the file system data source accepts the name being parsed (as a WIN32_FIND_DATA structure), using the STR_FILE_SYS_BIND_DATA bind context parameter. - /// STR_PARSE_PREFER_FOLDER_BROWSING can be passed to indicate that URLs are parsed using the file system data source when possible.Construct a bind context object using CreateBindCtx and populate the values using IBindCtx::RegisterObjectParam. See Bind Context String Keys for a complete list of these.See the Parsing With Parameters Sample for an example of the use of this parameter. - /// If no data is being passed to or received from the parsing function, this value can be NULL. + /// + /// Optional. A pointer to a bind context used to pass parameters as inputs and outputs to the parsing function. These passed + /// parameters are often specific to the data source and are documented by the data source owners. For example, the file system data + /// source accepts the name being parsed (as a WIN32_FIND_DATA structure), using the STR_FILE_SYS_BIND_DATA bind context parameter. + /// + /// STR_PARSE_PREFER_FOLDER_BROWSING can be passed to indicate that URLs are parsed using the file system data source when + /// possible.Construct a bind context object using CreateBindCtx and populate the values using IBindCtx::RegisterObjectParam. See + /// Bind Context String Keys for a complete list of these.See the Parsing With Parameters Sample for an example of the use of this parameter. + /// + /// If no data is being passed to or received from the parsing function, this value can be NULL. + /// /// A reference to the IID of the interface to retrieve through ppv, typically IID_IShellItem or IID_IShellItem2. - /// When this method returns successfully, contains the interface pointer requested in riid. This is typically IShellItem or IShellItem2. + /// + /// When this method returns successfully, contains the interface pointer requested in riid. This is typically IShellItem or IShellItem2. + /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobjidl.h", MSDNShortId = "bb762134")] @@ -932,65 +1381,123 @@ namespace Vanara.PInvoke /// Creates and initializes a Shell item object from a relative parsing name. /// A pointer to the parent Shell item. - /// A pointer to a null-terminated, Unicode string that specifies a display name that is relative to the psiParent. + /// + /// A pointer to a null-terminated, Unicode string that specifies a display name that is relative to the psiParent. + /// /// A pointer to a bind context that controls the parsing operation. This parameter can be NULL. /// A reference to an interface ID. - /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// + /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762135")] public static extern HRESULT SHCreateItemFromRelativeName([In, MarshalAs(UnmanagedType.Interface)] IShellItem psiParent, [In, MarshalAs(UnmanagedType.LPWStr)] string pszName, [In, MarshalAs(UnmanagedType.Interface)] IBindCtx pbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); - /// - /// Creates a Shell item object for a single file that exists inside a known folder. - /// + /// Creates a Shell item object for a single file that exists inside a known folder. /// A reference to the KNOWNFOLDERID, a GUID that identifies the folder that contains the item. - /// Flags that specify special options in the object retrieval. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. - /// A pointer to a null-terminated buffer that contains the file name of the new item as a Unicode string. This parameter can also be NULL. In this case, an IShellItem that represents the known folder itself is created. + /// + /// Flags that specify special options in the object retrieval. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// + /// + /// A pointer to a null-terminated buffer that contains the file name of the new item as a Unicode string. This parameter can also be + /// NULL. In this case, an IShellItem that represents the known folder itself is created. + /// /// A reference to an interface ID. - /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// + /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762136")] public static extern HRESULT SHCreateItemInKnownFolder([In, MarshalAs(UnmanagedType.LPStruct)] Guid kfid, [In] KNOWN_FOLDER_FLAG dwKFFlags, [In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pszItem, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); - /// - /// Create a Shell item, given a parent folder and a child item ID. - /// - /// The IDList of the parent folder of the item being created; the IDList of psfParent. This parameter can be NULL, if psfParent is specified. - /// A pointer to IShellFolder interface that specifies the shell data source of the child item specified by the pidl.This parameter can be NULL, if pidlParent is specified. + /// Create a Shell item, given a parent folder and a child item ID. + /// + /// The IDList of the parent folder of the item being created; the IDList of psfParent. This parameter can be NULL, if psfParent is specified. + /// + /// + /// A pointer to IShellFolder interface that specifies the shell data source of the child item specified by the pidl.This parameter + /// can be NULL, if pidlParent is specified. + /// /// A child item ID relative to its parent folder specified by psfParent or pidlParent. /// A reference to an interface ID. - /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// + /// When this function returns, contains the interface pointer requested in riid. This will usually be IShellItem or IShellItem2. + /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762137")] public static extern HRESULT SHCreateItemWithParent([In] PIDL pidlParent, [In, MarshalAs(UnmanagedType.Interface)] IShellFolder psfParent, [In] PIDL pidl, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppvItem); - /// - /// Creates a Shell item array object. - /// - /// The ID list of the parent folder of the items specified in ppidl. If psf is specified, this parameter can be NULL. If this pidlParent is not specified, it is computed from the psf parameter using IPersistFolder2. - /// The Shell data source object that is the parent of the child items specified in ppidl. If pidlParent is specified, this parameter can be NULL. + /// Creates a Shell item array object. + /// + /// The ID list of the parent folder of the items specified in ppidl. If psf is specified, this parameter can be NULL. If this + /// pidlParent is not specified, it is computed from the psf parameter using IPersistFolder2. + /// + /// + /// The Shell data source object that is the parent of the child items specified in ppidl. If pidlParent is specified, this parameter + /// can be NULL. + /// /// The number of elements in the array specified by ppidl. /// The list of child item IDs for which the array is being created. This value can be NULL. - /// When this function returns, contains the address of an interface pointer. + /// + /// When this function returns, contains the address of an interface pointer. + /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762144")] public static extern HRESULT SHCreateShellItemArray([In] PIDL pidlParent, [In, MarshalAs(UnmanagedType.Interface)] IShellFolder psf, uint cidl, [In] PIDL ppidl, out IShellItemArray ppsiItemArray); - // [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] - // [SecurityCritical, SuppressUnmanagedCodeSecurity] - // [PInvokeData("Shlobj.h", MSDNShortId = "bb762141")] - // public static extern HRESULT SHCreateShellFolderView([In] ref SFV_CREATE pcsfv, [MarshalAs(UnmanagedType.Interface)] out object ppvItem); /// - /// Creates a Shell item array object from a list of ITEMIDLIST structures. + /// Creates a Shell item array object from a data object. /// + /// + /// Type: IDataObject* + /// A pointer to IDataObject interface. + /// + /// + /// Type: REFIID + /// A reference to the desired interface ID. + /// + /// + /// Type: void** + /// When this method returns, contains the interface pointer requested in . This is typically IShellItemArray. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// This function is useful for Shell extensions that implement IShellExtInit and are passed a data object to the + /// IShellExtInit::Initialize method; for example, context menu handlers. + /// + /// + /// This API lets you convert the data object into a Shell item that the handler can consume. It is recommend that handlers use a + /// Shell item array rather than clipboard formats like CF_HDROP and CFSTR_SHELLIDLIST (also known as HIDA) as it leads + /// to simpler code and allows some performance improvements. + /// + /// + /// The resulting shell item array holds a reference to the source data object. Therefore, that data object must remain valid for the + /// lifetime of the shell item array. Notably, the data objects passed to IDropTarget methods are no longer valid after the drop + /// operation completes. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreateshellitemarrayfromdataobject SHSTDAPI + // SHCreateShellItemArrayFromDataObject( IDataObject *pdo, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "91e65c9a-0600-42e3-97f5-2a5960e1ec89")] + public static extern HRESULT SHCreateShellItemArrayFromDataObject(IDataObject pdo, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IShellItemArray ppv); + + // [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] + // [PInvokeData("Shlobj.h", MSDNShortId = "bb762141")] public static extern HRESULT SHCreateShellFolderView([In] ref SFV_CREATE + // pcsfv, [MarshalAs(UnmanagedType.Interface)] out object ppvItem); + /// Creates a Shell item array object from a list of ITEMIDLIST structures. /// The number of elements in the array. /// A list of cidl constant pointers to ITEMIDLIST structures. /// When this function returns, contains an IShellItemArray interface pointer. @@ -1000,16 +1507,131 @@ namespace Vanara.PInvoke public static extern HRESULT SHCreateShellItemArrayFromIDLists(uint cidl, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] rgpidl, out IShellItemArray ppsiItemArray); /// - /// Creates an array of one element from a single Shell item. + /// Creates an array of one element from a single Shell item. /// - /// Pointer to IShellItem object that represents the item. - /// A reference to the IID of the interface to retrieve through ppv, typically IID_IShellItemArray. - /// When this method returns, contains the interface pointer requested in riid. This is typically a pointer to an IShellItemArray. - [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] - [SecurityCritical, SuppressUnmanagedCodeSecurity] - [PInvokeData("Shobjidl.h", MSDNShortId = "bb762147")] + /// + /// Type: IShellItem* + /// Pointer to IShellItem object that represents the item. + /// + /// + /// Type: REFIID + /// A reference to the IID of the interface to retrieve through , typically IID_IShellItemArray. + /// + /// + /// Type: void** + /// When this method returns, contains the interface pointer requested in . This is typically a pointer to an IShellItemArray. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// This function creates a one-element array from a single item. To create an array from the contents of a folder, use SHCreateShellItemArray. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shcreateshellitemarrayfromshellitem SHSTDAPI + // SHCreateShellItemArrayFromShellItem( IShellItem *psi, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "93401708-6f11-474d-8009-24554f316e79")] public static extern HRESULT SHCreateShellItemArrayFromShellItem([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IShellItemArray ppv); + /// + /// Creates an IShellItem or related object based on an item specified by an IDataObject. + /// + /// + /// Type: IDataObject* + /// A pointer to the source IDataObject instance. + /// + /// + /// Type: DATAOBJ_GET_ITEM_FLAGS + /// + /// One or more values from the DATAOBJ_GET_ITEM_FLAGS enumeration to specify options regarding the target object. This value can be 0. + /// + /// + /// + /// Type: REFIID + /// A reference to the IID of the interface to retrieve through , typically IID_IShellItem. + /// + /// + /// Type: void** + /// When this method returns, contains the interface pointer requested in . This is typically IShellItem. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// It is recommended that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the and parameters. This macro + /// provides the correct IID based on the interface pointed to by the value in , which eliminates the possibility of a coding error. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shgetitemfromdataobject HRESULT + // SHGetItemFromDataObject( IDataObject *pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "1d7b9ffa-9980-4d68-85e4-7bab667be168")] + public static extern HRESULT SHGetItemFromDataObject(IDataObject pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); + + /// + /// Retrieves an IShellItem for an object. + /// + /// + /// Type: IUnknown* + /// A pointer to the IUnknown of the object. + /// + /// + /// Type: REFIID + /// Reference to the desired IID. + /// + /// + /// Type: void** + /// When this method returns, contains the interface pointer requested in . This is typically IShellItem or a related interface. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// From the standpoint of performance, this method is preferred to SHGetIDListFromObject in those cases where the IDList is already + /// bound to a folder. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shgetitemfromobject SHSTDAPI + // SHGetItemFromObject( IUnknown *punk, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "0ef494c0-81c7-4fbd-9c37-78861d8ac63b")] + public static extern HRESULT SHGetItemFromObject([MarshalAs(UnmanagedType.IUnknown)] object punk, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); + + /// + /// Retrieves an object that supports IPropertyStore or related interfaces from a pointer to an item identifier list (PIDL). + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// A pointer to an item ID list. + /// + /// + /// Type: GETPROPERTYSTOREFLAGS + /// One or more values from the GETPROPERTYSTOREFLAGS constants. This parameter can also be NULL. + /// + /// + /// Type: REFIID + /// A reference to the desired interface ID. + /// + /// + /// Type: void** + /// + /// When this function returns, contains the interface pointer requested in . This is typically IPropertyStore or a related interface. + /// + /// + /// + /// None + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shgetpropertystorefromidlist SHSTDAPI + // SHGetPropertyStoreFromIDList( PCIDLIST_ABSOLUTE pidl, GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "2a3c3c80-1bfc-4da0-ba6e-ac9e9a5c3e5b")] + public static extern HRESULT SHGetPropertyStoreFromIDList(PIDL pidl, GETPROPERTYSTOREFLAGS flags, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); + /// Returns a property store for an item, given a path or parsing name. /// A pointer to a null-terminated Unicode string that specifies the item path. /// A pointer to a IBindCtx object, which provides access to a bind context. This value can be NULL. @@ -1028,6 +1650,32 @@ namespace Vanara.PInvoke [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [Out] out IPropertyStore propertyStore); + /// + /// + /// Retrieves the temporary property for the given item. A temporary property is a read/write store that holds properties only for + /// the lifetime of the IShellItem object, rather than being persisted back into the item. + /// + /// + /// + /// Type: IShellItem* + /// A pointer to the item for which the temporary property is to be retrieved. + /// + /// + /// TBD + /// + /// + /// TBD + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-shgettemporarypropertyforitem SHSTDAPI + // SHGetTemporaryPropertyForItem( IShellItem *psi, REFPROPERTYKEY propkey, PROPVARIANT *ppropvar ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shobjidl_core.h", MSDNShortId = "53953a5a-04a2-4749-a03b-8cbd5ac889f1")] + public static extern HRESULT SHGetTemporaryPropertyForItem(IShellItem psi, ref PROPERTYKEY propkey, PROPVARIANT ppropvar); + /// Clones an ITEMIDLIST structure. /// A pointer to the ITEMIDLIST structure to be cloned. /// Returns a pointer to a copy of the ITEMIDLIST structure pointed to by pidl. @@ -1037,10 +1685,12 @@ namespace Vanara.PInvoke /// Combines two ITEMIDLIST structures. /// A pointer to the first ITEMIDLIST structure. - /// A pointer to the second ITEMIDLIST structure. This structure is appended to the structure pointed to by pidl1. + /// + /// A pointer to the second ITEMIDLIST structure. This structure is appended to the structure pointed to by pidl1. + /// /// - /// Returns an ITEMIDLIST containing the combined structures. If you set either pidl1 or pidl2 to NULL, the returned ITEMIDLIST structure is a clone of - /// the non-NULL parameter. Returns NULL if pidl1 and pidl2 are both set to NULL. + /// Returns an ITEMIDLIST containing the combined structures. If you set either pidl1 or pidl2 to NULL, the returned ITEMIDLIST + /// structure is a clone of the non-NULL parameter. Returns NULL if pidl1 and pidl2 are both set to NULL. /// [DllImport(Lib.Shell32, EntryPoint = "ILCombine", SetLastError = false)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb776437")] @@ -1050,6 +1700,7 @@ namespace Vanara.PInvoke [PInvokeData("shobjidl_core.h")] [ComImport, Guid("591209c7-767b-42b2-9fba-44ee4615f2c7"), ClassInterface(ClassInterfaceType.None)] public class ApplicationAssociationRegistration { } + /// Class interface for IEnumerableObjectCollection. [ComImport, Guid("2d3468c1-36a7-43b6-ac24-d3f02fd9607a"), ClassInterface(ClassInterfaceType.None)] public class CEnumerableObjectCollection { } diff --git a/PInvoke/Shell32/ShellApi.cs b/PInvoke/Shell32/ShellApi.cs index 0ff5f2cf..ec22ce72 100644 --- a/PInvoke/Shell32/ShellApi.cs +++ b/PInvoke/Shell32/ShellApi.cs @@ -1,13 +1,10 @@ using System; using System.IO; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; using System.Text; using Vanara.InteropServices; using static Vanara.PInvoke.Kernel32; -using static Vanara.PInvoke.Ole32; using static Vanara.PInvoke.PropSys; -using static Vanara.PInvoke.ShlwApi; namespace Vanara.PInvoke { @@ -20,10 +17,13 @@ namespace Vanara.PInvoke { /// Left edge. ABE_LEFT = 0, + /// Top edge. ABE_TOP = 1, + /// Right edge. ABE_RIGHT = 2, + /// Bottom edge. ABE_BOTTOM = 3, } @@ -32,7 +32,9 @@ namespace Vanara.PInvoke [PInvokeData("shellapi.h", MSDNShortId = "173d6eff-b33b-4d7d-bedd-5ebfb1e45954")] public enum ABM { - /// Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar. + /// + /// Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar. + /// ABM_NEW = 0x00000000, /// Unregisters an appbar, removing the bar from the system's internal list. @@ -47,10 +49,18 @@ namespace Vanara.PInvoke /// Retrieves the autohide and always-on-top states of the Windows taskbar. ABM_GETSTATE = 0x00000004, - /// Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the taskbar and other app bars—the working area available to your application—, use the GetMonitorInfo function. + /// + /// Retrieves the bounding rectangle of the Windows taskbar. Note that this applies only to the system taskbar. Other objects, + /// particularly toolbars supplied with third-party software, also can be present. As a result, some of the screen area not + /// covered by the Windows taskbar might not be visible to the user. To retrieve the area of the screen not covered by both the + /// taskbar and other app bars—the working area available to your application—, use the GetMonitorInfo function. + /// ABM_GETTASKBARPOS = 0x00000005, - /// Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to TRUE to activate or FALSE to deactivate. + /// + /// Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by pData is set to + /// TRUE to activate or FALSE to deactivate. + /// ABM_ACTIVATE = 0x00000006, /// Retrieves the handle to the autohide appbar associated with a particular edge of the screen. @@ -65,7 +75,9 @@ namespace Vanara.PInvoke /// Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes. ABM_SETSTATE = 0x0000000A, - /// Windows XP and later: Retrieves the handle to the autohide appbar associated with a particular edge of a particular monitor. + /// + /// Windows XP and later: Retrieves the handle to the autohide appbar associated with a particular edge of a particular monitor. + /// ABM_GETAUTOHIDEBAREX = 0x0000000B, /// Windows XP and later: Registers or unregisters an autohide appbar for an edge of a particular monitor. @@ -78,37 +90,48 @@ namespace Vanara.PInvoke { /// The hkClass member names a key found as HKEY_CLASSES_ROOT\ SystemFileAssociations\ hkClass. ASSOCCLASS_SHELL_KEY = 0, + /// The hkClass member provides the full registry path of a ProgID. ASSOCCLASS_PROGID_KEY, + /// The pszClass member names a ProgID found as HKEY_CLASSES_ROOT\ pszClass. ASSOCCLASS_PROGID_STR, + /// The hkClass member provides the full registry path of a CLSID. ASSOCCLASS_CLSID_KEY, + /// The hkClass member names a CLSID found as HKEY_CLASSES_ROOT\ CLSID\ pszClass. ASSOCCLASS_CLSID_STR, + /// The hkClass member provides the full registry path of an application identifier (APPID). ASSOCCLASS_APP_KEY, + /// /// The APPID storing the application information is found at HKEY_CLASSES_ROOT\ Applications\ FileName /// where FileName is obtained by sending pszClass to PathFindFileName. /// ASSOCCLASS_APP_STR, + /// The pszClass member names a key found as HKEY_CLASSES_ROOT\ SystemFileAssociations\ pszClass. ASSOCCLASS_SYSTEM_STR, + /// /// Use the association information for folders stored under HKEY_CLASSES_ROOT\ Folder. When this flag is set, /// hkClass and pszClass are ignored. /// ASSOCCLASS_FOLDER, + /// /// Use the association information stored under the HKEY_CLASSES_ROOT\ * subkey. When this flag is set, /// hkClass and pszClass are ignored. /// ASSOCCLASS_STAR, + /// /// Introduced in Windows 8. Do not use the user defaults to apply the mapping of the class specified by the pszClass member. /// ASSOCCLASS_FIXED_PROGID_STR, + /// /// Introduced in Windows 8. Use the user defaults to apply the mapping of the class specified by the pszClass member; the class /// is a protocol. @@ -116,6 +139,195 @@ namespace Vanara.PInvoke ASSOCCLASS_PROTOCOL_STR, } + /// Flags for NOTIFYICONDATA. + [PInvokeData("shellapi.h", MSDNShortId = "fdcc42c1-b3e5-4b04-8d79-7b6c29699d53")] + [Flags] + public enum NIF + { + /// The uCallbackMessage member is valid. + NIF_MESSAGE = 0x00000001, + + /// The hIcon member is valid. + NIF_ICON = 0x00000002, + + /// The szTip member is valid. + NIF_TIP = 0x00000004, + + /// The dwState and dwStateMask members are valid. + NIF_STATE = 0x00000008, + + /// + /// Display a balloon notification. The szInfo, szInfoTitle, dwInfoFlags, and uTimeout members are valid. Note that uTimeout is + /// valid only in Windows 2000 and Windows XP. + /// + /// + /// To display the balloon notification, specify NIF_INFO and provide text in szInfo. + /// + /// + /// To remove a balloon notification, specify NIF_INFO and provide an empty string through szInfo. + /// + /// + /// To add a notification area icon without displaying a notification, do not set the NIF_INFO flag. + /// + /// + /// + NIF_INFO = 0x00000010, + + /// Windows 7 and later: The guidItem is valid. + NIF_GUID = 0x00000020, + + /// + /// Windows Vista and later. If the balloon notification cannot be displayed immediately, discard it. Use this flag for + /// notifications that represent real-time information which would be meaningless or misleading if displayed at a later time. For + /// example, a message that states "Your telephone is ringing." NIF_REALTIME is meaningful only when combined with the NIF_INFO flag. + /// + NIF_REALTIME = 0x00000040, + + /// + /// Windows Vista and later. Use the standard tooltip. Normally, when uVersion is set to NOTIFYICON_VERSION_4, the standard + /// tooltip is suppressed and can be replaced by the application-drawn, pop-up UI. If the application wants to show the standard + /// tooltip with NOTIFYICON_VERSION_4, it can specify NIF_SHOWTIP to indicate the standard tooltip should still be shown. + /// + NIF_SHOWTIP = 0x00000080, + } + + /// Info flags for NOTIFYICONDATA. + [PInvokeData("shellapi.h", MSDNShortId = "fdcc42c1-b3e5-4b04-8d79-7b6c29699d53")] + [Flags] + public enum NIIF + { + /// No icon. + NIIF_NONE = 0x00000000, + + /// An information icon. + NIIF_INFO = 0x00000001, + + /// A warning icon. + NIIF_WARNING = 0x00000002, + + /// An error icon. + NIIF_ERROR = 0x00000003, + + /// + /// Windows XP SP2 and later. + /// + /// + /// Windows XP: Use the icon identified in hIcon as the notification balloon's title icon. + /// + /// + /// + /// Windows Vista and later: Use the icon identified in hBalloonIcon as the notification balloon's title icon. + /// + /// + /// + /// + NIIF_USER = 0x00000004, + + /// Windows XP and later. Reserved. + NIIF_ICON_MASK = 0x0000000F, + + /// Windows XP and later. Do not play the associated sound. Applies only to notifications. + NIIF_NOSOUND = 0x00000010, + + /// + /// Windows Vista and later. The large version of the icon should be used as the notification icon. This corresponds to the icon + /// with dimensions SM_CXICON x SM_CYICON. If this flag is not set, the icon with dimensions XM_CXSMICON x SM_CYSMICON is used. + /// + /// + /// This flag can be used with all stock icons. + /// + /// + /// + /// Applications that use older customized icons (NIIF_USER with hIcon) must provide a new SM_CXICON x SM_CYICON version in the + /// tray icon(hIcon). These icons are scaled down when they are displayed in the System Tray or System Control Area(SCA). + /// + /// + /// + /// + /// New customized icons(NIIF_USER with hBalloonIcon) must supply an SM_CXICON x SM_CYICON version in the supplied icon(hBalloonIcon). + /// + /// + /// + /// + NIIF_LARGE_ICON = 0x00000020, + + /// Windows 7 and later. Do not display the balloon notification if the current user is in "quiet time", which is the + /// first hour after a new user logs into his or her account for the first time. During this time, most notifications should not + /// be sent or shown. This lets a user become accustomed to a new computer system without those distractions. Quiet time also + /// occurs for each user after an operating system upgrade or clean installation. A notification sent with this flag during quiet + /// time is not queued; it is simply dismissed unshown. The application can resend the notification later if it is still valid at + /// that time. During quiet + /// time, certain notifications should still be sent because they are expected by the user as feedback in response to a user + /// action, for instance when he or she plugs in a USB device or prints a document. If the current user is not in + /// quiet time, this flag has no effect. + NIIF_RESPECT_QUIET_TIME = 0x00000080 + } + + /// State flags for NOTIFYICONDATA. + [PInvokeData("shellapi.h", MSDNShortId = "fdcc42c1-b3e5-4b04-8d79-7b6c29699d53")] + [Flags] + public enum NIS + { + /// The icon is hidden. + NIS_HIDDEN = 0x00000001, + + /// The icon resource is shared between multiple icons. + NIS_SHAREDICON = 0x00000002 + } + + /// Flags for SHIsFileAvailableOffline. + [PInvokeData("shellapi.h", MSDNShortId = "9acf212d-9309-42b0-ba96-faa0ecf0b865")] + [Flags] + public enum OFFLINE_STATUS + { + /// If the file is open, it is open in the cache. + OFFLINE_STATUS_LOCAL = 0x0001, + + /// If the file is open, it is open on the server. + OFFLINE_STATUS_REMOTE = 0x0002, + + /// The local copy is currently incomplete. The file cannot be opened in offline mode until it has been synchronized. + OFFLINE_STATUS_INCOMPLETE = 0x0004, + } + + /// Flags for SHInvokePrinterCommand. + [PInvokeData("shellapi.h", MSDNShortId = "32a5802f-cef7-4dbd-affd-82285fe97a8c")] + public enum PRINTACTION + { + /// 0x0. Open the printer specified by . The parameter is ignored. + PRINTACTION_OPEN = 0, + + /// + /// 0x1. Display the property pages for the printer specified by . The parameter can be NULL or can name a specific + /// property sheet to display, either by name or number. If the high WORD of is nonzero, it is assumed that this parameter + /// is a pointer to a buffer that contains the name of the sheet to open. Otherwise, is seen as the zero-based index of the + /// property sheet to open. + /// + PRINTACTION_PROPERTIES = 1, + + /// 0x2. Install the network printer specified by . The parameter is ignored. + PRINTACTION_NETINSTALL = 2, + + /// + /// 0x3. Create a shortcut to the network printer specified by . The parameter specifies the drive and path of the folder in + /// which to create the shortcut. The network printer must already have been installed on the local computer. + /// + PRINTACTION_NETINSTALLLINK = 3, + + /// 0x4. Print a test page on the printer specified by . The parameter is ignored. + PRINTACTION_TESTPAGE = 4, + + /// 0x5. Open the network printer specified by . The parameter is ignored. + PRINTACTION_OPENNETPRN = 5, + + /// 0x6. Display the default document properties for the printer specified by . The parameter is ignored. + PRINTACTION_DOCUMENTDEFAULTS = 6, + + /// 0x7. Display the properties for the printer server specified by . The parameter is ignored. + PRINTACTION_SERVERPROPERTIES = 7, + } + /// Flags that indicate the content and validity of the other structure members in . [PInvokeData("Shellapi.h", MSDNShortId = "bb759784")] [Flags] @@ -124,25 +336,30 @@ namespace Vanara.PInvoke /// Use default values. SEE_MASK_DEFAULT = 0x00000000, - /// Use the class name given by the lpClass member. If both SEE_MASK_CLASSKEY and SEE_MASK_CLASSNAME are set, the class key is used. + /// + /// Use the class name given by the lpClass member. If both SEE_MASK_CLASSKEY and SEE_MASK_CLASSNAME are set, the class key is used. + /// SEE_MASK_CLASSNAME = 0x00000001, - /// Use the class key given by the hkeyClass member. If both SEE_MASK_CLASSKEY and SEE_MASK_CLASSNAME are set, the class key is used. + /// + /// Use the class key given by the hkeyClass member. If both SEE_MASK_CLASSKEY and SEE_MASK_CLASSNAME are set, the class key is used. + /// SEE_MASK_CLASSKEY = 0x00000003, /// Use the item identifier list given by the lpIDList member. The lpIDList member must point to an ITEMIDLIST structure. SEE_MASK_IDLIST = 0x00000004, /// - /// Use the IContextMenu interface of the selected item's shortcut menu handler. Use either lpFile to identify the item by its file system path or - /// lpIDList to identify the item by its PIDL. This flag allows applications to use ShellExecuteEx to invoke verbs from shortcut menu extensions - /// instead of the static verbs listed in the registry. SEE_MASK_INVOKEIDLIST overrides and implies SEE_MASK_IDLIST. + /// Use the IContextMenu interface of the selected item's shortcut menu handler. Use either lpFile to identify the item by its + /// file system path or lpIDList to identify the item by its PIDL. This flag allows applications to use ShellExecuteEx to invoke + /// verbs from shortcut menu extensions instead of the static verbs listed in the registry. SEE_MASK_INVOKEIDLIST overrides + /// and implies SEE_MASK_IDLIST. /// SEE_MASK_INVOKEIDLIST = 0x0000000c, /// - /// Use the icon given by the hIcon member. This flag cannot be combined with SEE_MASK_HMONITOR. This flag is used only in Windows XP and - /// earlier. It is ignored as of Windows Vista. + /// Use the icon given by the hIcon member. This flag cannot be combined with SEE_MASK_HMONITOR. This flag is used only in + /// Windows XP and earlier. It is ignored as of Windows Vista. /// SEE_MASK_ICON = 0x00000010, @@ -150,28 +367,31 @@ namespace Vanara.PInvoke SEE_MASK_HOTKEY = 0x00000020, /// - /// Use to indicate that the hProcess member receives the process handle. This handle is typically used to allow an application to find out when a - /// process created with ShellExecuteEx terminates. In some cases, such as when execution is satisfied through a DDE conversation, no handle will be - /// returned. The calling application is responsible for closing the handle when it is no longer needed. + /// Use to indicate that the hProcess member receives the process handle. This handle is typically used to allow an application + /// to find out when a process created with ShellExecuteEx terminates. In some cases, such as when execution is satisfied through + /// a DDE conversation, no handle will be returned. The calling application is responsible for closing the handle when it is no + /// longer needed. /// SEE_MASK_NOCLOSEPROCESS = 0x00000040, /// - /// Validate the share and connect to a drive letter. This enables reconnection of disconnected network drives. The lpFile member is a UNC path of a - /// file on a network. + /// Validate the share and connect to a drive letter. This enables reconnection of disconnected network drives. The lpFile member + /// is a UNC path of a file on a network. /// SEE_MASK_CONNECTNETDRV = 0x00000080, /// - /// Wait for the execute operation to complete before returning. This flag should be used by callers that are using ShellExecute forms that might - /// result in an async activation, for example DDE, and create a process that might be run on a background thread. (Note: ShellExecuteEx runs on a - /// background thread by default if the caller's threading model is not Apartment.) Calls to ShellExecuteEx from processes already running on - /// background threads should always pass this flag. Also, applications that exit immediately after calling ShellExecuteEx should specify this flag. + /// Wait for the execute operation to complete before returning. This flag should be used by callers that are using ShellExecute + /// forms that might result in an async activation, for example DDE, and create a process that might be run on a background + /// thread. (Note: ShellExecuteEx runs on a background thread by default if the caller's threading model is not Apartment.) Calls + /// to ShellExecuteEx from processes already running on background threads should always pass this flag. Also, applications that + /// exit immediately after calling ShellExecuteEx should specify this flag. /// - /// If the execute operation is performed on a background thread and the caller did not specify the SEE_MASK_ASYNCOK flag, then the calling thread - /// waits until the new process has started before returning. This typically means that either CreateProcess has been called, the DDE communication - /// has completed, or that the custom execution delegate has notified ShellExecuteEx that it is done. If the SEE_MASK_WAITFORINPUTIDLE flag is - /// specified, then ShellExecuteEx calls WaitForInputIdle and waits for the new process to idle before returning, with a maximum timeout of 1 minute. + /// If the execute operation is performed on a background thread and the caller did not specify the SEE_MASK_ASYNCOK flag, then + /// the calling thread waits until the new process has started before returning. This typically means that either CreateProcess + /// has been called, the DDE communication has completed, or that the custom execution delegate has notified ShellExecuteEx that + /// it is done. If the SEE_MASK_WAITFORINPUTIDLE flag is specified, then ShellExecuteEx calls WaitForInputIdle and waits for the + /// new process to idle before returning, with a maximum timeout of 1 minute. /// /// For further discussion on when this flag is necessary, see the Remarks section. /// @@ -190,25 +410,27 @@ namespace Vanara.PInvoke SEE_MASK_UNICODE = 0x00004000, /// - /// Use to inherit the parent's console for the new process instead of having it create a new console. It is the opposite of using a - /// CREATE_NEW_CONSOLE flag with CreateProcess. + /// Use to inherit the parent's console for the new process instead of having it create a new console. It is the opposite of + /// using a CREATE_NEW_CONSOLE flag with CreateProcess. /// SEE_MASK_NO_CONSOLE = 0x00008000, /// - /// The execution can be performed on a background thread and the call should return immediately without waiting for the background thread to finish. - /// Note that in certain cases ShellExecuteEx ignores this flag and waits for the process to finish before returning. + /// The execution can be performed on a background thread and the call should return immediately without waiting for the + /// background thread to finish. Note that in certain cases ShellExecuteEx ignores this flag and waits for the process to finish + /// before returning. /// SEE_MASK_ASYNCOK = 0x00100000, /// - /// Use this flag when specifying a monitor on multi-monitor systems. The monitor is specified in the hMonitor member. This flag cannot be combined - /// with SEE_MASK_ICON. + /// Use this flag when specifying a monitor on multi-monitor systems. The monitor is specified in the hMonitor member. This flag + /// cannot be combined with SEE_MASK_ICON. /// SEE_MASK_HMONITOR = 0x00200000, /// - /// Introduced in Windows XP. Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place by IAttachmentExecute. + /// Introduced in Windows XP. Do not perform a zone check. This flag allows ShellExecuteEx to bypass zone checking put into place + /// by IAttachmentExecute. /// SEE_MASK_NOZONECHECKS = 0x00800000, @@ -216,19 +438,21 @@ namespace Vanara.PInvoke SEE_MASK_NOQUERYCLASSSTORE = 0x01000000, /// - /// After the new process is created, wait for the process to become idle before returning, with a one minute timeout. See WaitForInputIdle for more details. + /// After the new process is created, wait for the process to become idle before returning, with a one minute timeout. See + /// WaitForInputIdle for more details. /// SEE_MASK_WAITFORINPUTIDLE = 0x02000000, /// - /// Introduced in Windows XP. Keep track of the number of times this application has been launched. Applications with sufficiently high counts appear - /// in the Start Menu's list of most frequently used programs. + /// Introduced in Windows XP. Keep track of the number of times this application has been launched. Applications with + /// sufficiently high counts appear in the Start Menu's list of most frequently used programs. /// SEE_MASK_FLAG_LOG_USAGE = 0x04000000, /// - /// The hInstApp member is used to specify the IUnknown of an object that implements IServiceProvider. This object will be used as a site pointer. - /// The site pointer is used to provide services to the ShellExecute function, the handler binding process, and invoked verb handlers. + /// The hInstApp member is used to specify the IUnknown of an object that implements IServiceProvider. This object will be used + /// as a site pointer. The site pointer is used to provide services to the ShellExecute function, the handler binding process, + /// and invoked verb handlers. /// SEE_MASK_FLAG_HINST_IS_SITE = 0x08000000 } @@ -239,97 +463,131 @@ namespace Vanara.PInvoke { /// Move the files specified in pFrom to the location specified in pTo. FO_MOVE = 0x0001, + /// Copy the files specified in the pFrom member to the location specified in the pTo member. FO_COPY = 0x0002, + /// Delete the files specified in pFrom. FO_DELETE = 0x0003, - /// Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead. + + /// + /// Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use + /// FO_MOVE instead. + /// FO_RENAME = 0x0004 } - /// The flags that specify the file information to retrieve from . + /// FLags used by SHEmptyRecycleBin. + [PInvokeData("shellapi.h", MSDNShortId = "c3995be7-bc8b-4e1f-8ef6-fdf4c0a75720")] + [Flags] + public enum SHERB + { + /// No dialog box confirming the deletion of the objects will be displayed. + SHERB_NOCONFIRMATION = 0x00000001, + + /// No dialog box indicating the progress will be displayed. + SHERB_NOPROGRESSUI = 0x00000002, + + /// No sound will be played when the operation is complete. + SHERB_NOSOUND = 0x00000004 + } + + /// + /// The flags that specify the file information to retrieve from . + /// [PInvokeData("Shellapi.h", MSDNShortId = "bb762179")] [Flags] public enum SHGFI { /// - /// Retrieve the handle to the icon that represents the file and the index of the icon within the system image list. The handle is copied to the - /// hIcon member of the structure specified by psfi, and the index is copied to the iIcon member. + /// Retrieve the handle to the icon that represents the file and the index of the icon within the system image list. The handle + /// is copied to the hIcon member of the structure specified by psfi, and the index is copied to the iIcon member. /// SHGFI_ICON = 0x000000100, /// - /// Retrieve the display name for the file, which is the name as it appears in Windows Explorer. The name is copied to the szDisplayName member of - /// the structure specified in psfi. The returned display name uses the long file name, if there is one, rather than the 8.3 form of the file name. - /// Note that the display name can be affected by settings such as whether extensions are shown. + /// Retrieve the display name for the file, which is the name as it appears in Windows Explorer. The name is copied to the + /// szDisplayName member of the structure specified in psfi. The returned display name uses the long file name, if there is one, + /// rather than the 8.3 form of the file name. Note that the display name can be affected by settings such as whether extensions + /// are shown. /// SHGFI_DISPLAYNAME = 0x000000200, /// - /// Retrieve the string that describes the file's type. The string is copied to the szTypeName member of the structure specified in psfi. + /// Retrieve the string that describes the file's type. The string is copied to the szTypeName member of the structure specified + /// in psfi. /// SHGFI_TYPENAME = 0x000000400, /// - /// Retrieve the item attributes. The attributes are copied to the dwAttributes member of the structure specified in the psfi parameter. These are - /// the same attributes that are obtained from IShellFolder::GetAttributesOf. + /// Retrieve the item attributes. The attributes are copied to the dwAttributes member of the structure specified in the psfi + /// parameter. These are the same attributes that are obtained from IShellFolder::GetAttributesOf. /// SHGFI_ATTRIBUTES = 0x000000800, /// - /// Retrieve the name of the file that contains the icon representing the file specified by pszPath, as returned by the IExtractIcon::GetIconLocation - /// method of the file's icon handler. Also retrieve the icon index within that file. The name of the file containing the icon is copied to the - /// szDisplayName member of the structure specified by psfi. The icon's index is copied to that structure's iIcon member. + /// Retrieve the name of the file that contains the icon representing the file specified by pszPath, as returned by the + /// IExtractIcon::GetIconLocation method of the file's icon handler. Also retrieve the icon index within that file. The name of + /// the file containing the icon is copied to the szDisplayName member of the structure specified by psfi. The icon's index is + /// copied to that structure's iIcon member. /// SHGFI_ICONLOCATION = 0x000001000, /// - /// Retrieve the type of the executable file if pszPath identifies an executable file. The information is packed into the return value. This flag - /// cannot be specified with any other flags. + /// Retrieve the type of the executable file if pszPath identifies an executable file. The information is packed into the return + /// value. This flag cannot be specified with any other flags. /// SHGFI_EXETYPE = 0x000002000, /// - /// Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return value is a handle to - /// the system image list. Only those images whose indices are successfully copied to iIcon are valid. Attempting to access other images in the - /// system image list will result in undefined behavior. + /// Retrieve the index of a system image list icon. If successful, the index is copied to the iIcon member of psfi. The return + /// value is a handle to the system image list. Only those images whose indices are successfully copied to iIcon are valid. + /// Attempting to access other images in the system image list will result in undefined behavior. /// SHGFI_SYSICONINDEX = 0x000004000, - /// Modify SHGFI_ICON, causing the function to add the link overlay to the file's icon. The SHGFI_ICON flag must also be set. + /// + /// Modify SHGFI_ICON, causing the function to add the link overlay to the file's icon. The SHGFI_ICON flag must also be set. + /// SHGFI_LINKOVERLAY = 0x000008000, /// - /// Modify SHGFI_ICON, causing the function to blend the file's icon with the system highlight color. The SHGFI_ICON flag must also be set. + /// Modify SHGFI_ICON, causing the function to blend the file's icon with the system highlight color. The SHGFI_ICON flag must + /// also be set. /// SHGFI_SELECTED = 0x000010000, /// - /// Modify SHGFI_ATTRIBUTES to indicate that the dwAttributes member of the SHFILEINFO structure at psfi contains the specific attributes that are - /// desired. These attributes are passed to IShellFolder::GetAttributesOf. If this flag is not specified, 0xFFFFFFFF is passed to - /// IShellFolder::GetAttributesOf, requesting all attributes. This flag cannot be specified with the SHGFI_ICON flag. + /// Modify SHGFI_ATTRIBUTES to indicate that the dwAttributes member of the SHFILEINFO structure at psfi contains the specific + /// attributes that are desired. These attributes are passed to IShellFolder::GetAttributesOf. If this flag is not specified, + /// 0xFFFFFFFF is passed to IShellFolder::GetAttributesOf, requesting all attributes. This flag cannot be specified with the + /// SHGFI_ICON flag. /// SHGFI_ATTR_SPECIFIED = 0x000020000, - /// Modify SHGFI_ICON, causing the function to retrieve the file's large icon. The SHGFI_ICON flag must also be set. + /// + /// Modify SHGFI_ICON, causing the function to retrieve the file's large icon. The SHGFI_ICON flag must also be set. + /// SHGFI_LARGEICON = 0x000000000, /// - /// Modify SHGFI_ICON, causing the function to retrieve the file's small icon. Also used to modify SHGFI_SYSICONINDEX, causing the function to return - /// the handle to the system image list that contains small icon images. The SHGFI_ICON and/or SHGFI_SYSICONINDEX flag must also be set. + /// Modify SHGFI_ICON, causing the function to retrieve the file's small icon. Also used to modify SHGFI_SYSICONINDEX, causing + /// the function to return the handle to the system image list that contains small icon images. The SHGFI_ICON and/or + /// SHGFI_SYSICONINDEX flag must also be set. /// SHGFI_SMALLICON = 0x000000001, /// - /// Modify SHGFI_ICON, causing the function to retrieve the file's open icon. Also used to modify SHGFI_SYSICONINDEX, causing the function to return - /// the handle to the system image list that contains the file's small open icon. A container object displays an open icon to indicate that the - /// container is open. The SHGFI_ICON and/or SHGFI_SYSICONINDEX flag must also be set. + /// Modify SHGFI_ICON, causing the function to retrieve the file's open icon. Also used to modify SHGFI_SYSICONINDEX, causing the + /// function to return the handle to the system image list that contains the file's small open icon. A container object displays + /// an open icon to indicate that the container is open. The SHGFI_ICON and/or SHGFI_SYSICONINDEX flag must also be set. /// SHGFI_OPENICON = 0x000000002, /// - /// Modify SHGFI_ICON, causing the function to retrieve a Shell-sized icon. If this flag is not specified the function sizes the icon according to - /// the system metric values. The SHGFI_ICON flag must also be set. + /// Modify SHGFI_ICON, causing the function to retrieve a Shell-sized icon. If this flag is not specified the function sizes the + /// icon according to the system metric values. The SHGFI_ICON flag must also be set. /// SHGFI_SHELLICONSIZE = 0x000000004, @@ -337,8 +595,9 @@ namespace Vanara.PInvoke SHGFI_PIDL = 0x000000008, /// - /// Indicates that the function should not attempt to access the file specified by pszPath. Rather, it should act as if the file specified by pszPath - /// exists with the file attributes passed in dwFileAttributes. This flag cannot be combined with the SHGFI_ATTRIBUTES, SHGFI_EXETYPE, or SHGFI_PIDL flags. + /// Indicates that the function should not attempt to access the file specified by pszPath. Rather, it should act as if the file + /// specified by pszPath exists with the file attributes passed in dwFileAttributes. This flag cannot be combined with the + /// SHGFI_ATTRIBUTES, SHGFI_EXETYPE, or SHGFI_PIDL flags. /// SHGFI_USEFILEATTRIBUTES = 0x000000010, @@ -346,11 +605,410 @@ namespace Vanara.PInvoke SHGFI_ADDOVERLAYS = 0x000000020, /// - /// Return the index of the overlay icon. The value of the overlay index is returned in the upper eight bits of the iIcon member of the structure - /// specified by psfi. This flag requires that the SHGFI_ICON be set as well. + /// Return the index of the overlay icon. The value of the overlay index is returned in the upper eight bits of the iIcon member + /// of the structure specified by psfi. This flag requires that the SHGFI_ICON be set as well. /// SHGFI_OVERLAYINDEX = 0x000000040 } + + /// Flags for SHGetNewLinkInfo. + [PInvokeData("shellapi.h", MSDNShortId = "ca658d5c-af7b-400c-8f4d-7d4b07bf7f2b")] + [Flags] + public enum SHGNLI + { + /// + /// 0x000000001. The target pointed to by is a PIDL that represents the target. If this flag is not included, is regarded as the + /// address of a string that contains the path and file name of the target. + /// + SHGNLI_PIDL = 0x000000001, + + /// + /// 0x000000002. Skip the normal checks that ensure that the shortcut name is unique within the destination folder. If this flag + /// is not included, the function creates the shortcut name and then determines whether the name is unique in the destination + /// folder. If a file with the same name already exists in the destination folder, the shortcut name will be modified. This + /// process is repeated until a unique name is found. + /// + SHGNLI_NOUNIQUE = 0x000000002, + + /// 0x000000004. The created name will be preceded by the string "Shortcut to ". + SHGNLI_PREFIXNAME = 0x000000004, + + /// + /// 0x000000008. Version 5.0 Do not add the .lnk file name extension. You must set the _WIN32_IE macro to 5.01 or greater + /// to use this flag. For more information about versioning, see Shell and Common Controls Versions. + /// + SHGNLI_NOLNK = 0x000000008, + + /// + /// 0x000000010. Windows Vista and later. Use the non-localized parsing name of the target pointed to by as the name of + /// the shortcut file. If this flag is not set, the localized name is used. + /// + SHGNLI_NOLOCNAME = 0x000000010, + + /// + /// 0x000000020. Windows 7 and later. Append a .url file name extension (rather than .lnk) to the name pointed to by . If + /// this flag is not set, the shortcut name uses a .lnk extension unless SHGNLI_NOLNK is set. + /// + SHGNLI_USEURLEXT = 0x000000020, + } + + /// Flags for SHGetStockIconInfo. + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetstockiconinfo + [PInvokeData("shellapi.h", MSDNShortId = "c08b1a53-e67c-4ed0-a9c6-d000c448e182")] + public enum SHGSI : uint + { + /// + /// The szPath and iIcon members of the SHSTOCKICONINFO structure receive the path and icon index of the requested + /// icon, in a format suitable for passing to the ExtractIcon function. The numerical value of this flag is zero, so you always + /// get the icon location regardless of other flags. + /// + SHGSI_ICONLOCATION = 0, + + /// The hIcon member of the SHSTOCKICONINFO structure receives a handle to the specified icon. + SHGSI_ICON = SHGFI.SHGFI_ICON, + + /// + /// The iSysImageImage member of the SHSTOCKICONINFO structure receives the index of the specified icon in the system imagelist. + /// + SHGSI_SYSICONINDEX = SHGFI.SHGFI_SYSICONINDEX, + + /// Modifies the SHGSI_ICON value by causing the function to add the link overlay to the file's icon. + SHGSI_LINKOVERLAY = SHGFI.SHGFI_LINKOVERLAY, + + /// Modifies the SHGSI_ICON value by causing the function to blend the icon with the system highlight color. + SHGSI_SELECTED = SHGFI.SHGFI_SELECTED, + + /// + /// Modifies the SHGSI_ICON value by causing the function to retrieve the large version of the icon, as specified by the + /// SM_CXICON and SM_CYICON system metrics. + /// + SHGSI_LARGEICON = SHGFI.SHGFI_LARGEICON, + + /// + /// Modifies the SHGSI_ICON value by causing the function to retrieve the small version of the icon, as specified by the + /// SM_CXSMICON and SM_CYSMICON system metrics. + /// + SHGSI_SMALLICON = SHGFI.SHGFI_SMALLICON, + + /// + /// Modifies the SHGSI_LARGEICON or SHGSI_SMALLICON values by causing the function to retrieve the Shell-sized icons rather than + /// the sizes specified by the system metrics. + /// + SHGSI_SHELLICONSIZE = SHGFI.SHGFI_SHELLICONSIZE, + } + + /// + /// Used by SHGetStockIconInfo to identify which stock system icon to retrieve. + /// + /// + /// SIID_INVALID, with a value of -1, indicates an invalid SHSTOCKICONID value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ne-shellapi-shstockiconid typedef enum SHSTOCKICONID { + // SIID_DOCNOASSOC , SIID_DOCASSOC , SIID_APPLICATION , SIID_FOLDER , SIID_FOLDEROPEN , SIID_DRIVE525 , SIID_DRIVE35 , + // SIID_DRIVEREMOVE , SIID_DRIVEFIXED , SIID_DRIVENET , SIID_DRIVENETDISABLED , SIID_DRIVECD , SIID_DRIVERAM , SIID_WORLD , + // SIID_SERVER , SIID_PRINTER , SIID_MYNETWORK , SIID_FIND , SIID_HELP , SIID_SHARE , SIID_LINK , SIID_SLOWFILE , SIID_RECYCLER , + // SIID_RECYCLERFULL , SIID_MEDIACDAUDIO , SIID_LOCK , SIID_AUTOLIST , SIID_PRINTERNET , SIID_SERVERSHARE , SIID_PRINTERFAX , + // SIID_PRINTERFAXNET , SIID_PRINTERFILE , SIID_STACK , SIID_MEDIASVCD , SIID_STUFFEDFOLDER , SIID_DRIVEUNKNOWN , SIID_DRIVEDVD , + // SIID_MEDIADVD , SIID_MEDIADVDRAM , SIID_MEDIADVDRW , SIID_MEDIADVDR , SIID_MEDIADVDROM , SIID_MEDIACDAUDIOPLUS , SIID_MEDIACDRW , + // SIID_MEDIACDR , SIID_MEDIACDBURN , SIID_MEDIABLANKCD , SIID_MEDIACDROM , SIID_AUDIOFILES , SIID_IMAGEFILES , SIID_VIDEOFILES , + // SIID_MIXEDFILES , SIID_FOLDERBACK , SIID_FOLDERFRONT , SIID_SHIELD , SIID_WARNING , SIID_INFO , SIID_ERROR , SIID_KEY , + // SIID_SOFTWARE , SIID_RENAME , SIID_DELETE , SIID_MEDIAAUDIODVD , SIID_MEDIAMOVIEDVD , SIID_MEDIAENHANCEDCD , SIID_MEDIAENHANCEDDVD + // , SIID_MEDIAHDDVD , SIID_MEDIABLURAY , SIID_MEDIAVCD , SIID_MEDIADVDPLUSR , SIID_MEDIADVDPLUSRW , SIID_DESKTOPPC , SIID_MOBILEPC , + // SIID_USERS , SIID_MEDIASMARTMEDIA , SIID_MEDIACOMPACTFLASH , SIID_DEVICECELLPHONE , SIID_DEVICECAMERA , SIID_DEVICEVIDEOCAMERA , + // SIID_DEVICEAUDIOPLAYER , SIID_NETWORKCONNECT , SIID_INTERNET , SIID_ZIPFILE , SIID_SETTINGS , SIID_DRIVEHDDVD , SIID_DRIVEBD , + // SIID_MEDIAHDDVDROM , SIID_MEDIAHDDVDR , SIID_MEDIAHDDVDRAM , SIID_MEDIABDROM , SIID_MEDIABDR , SIID_MEDIABDRE , + // SIID_CLUSTEREDDRIVE , SIID_MAX_ICONS } ; + [PInvokeData("shellapi.h", MSDNShortId = "37da5555-3626-465e-b834-3a28b75495c4")] + public enum SHSTOCKICONID + { + /// Document of a type with no associated application. + SIID_DOCNOASSOC = 0, + + /// Document of a type with an associated application. + SIID_DOCASSOC = 1, + + /// Generic application with no custom icon. + SIID_APPLICATION = 2, + + /// Folder (generic, unspecified state). + SIID_FOLDER = 3, + + /// Folder (open). + SIID_FOLDEROPEN = 4, + + /// 5.25-inch disk drive. + SIID_DRIVE525 = 5, + + /// 3.5-inch disk drive. + SIID_DRIVE35 = 6, + + /// Removable drive. + SIID_DRIVEREMOVE = 7, + + /// Fixed drive (hard disk). + SIID_DRIVEFIXED = 8, + + /// Network drive (connected). + SIID_DRIVENET = 9, + + /// Network drive (disconnected). + SIID_DRIVENETDISABLED = 10, + + /// CD drive. + SIID_DRIVECD = 11, + + /// RAM disk drive. + SIID_DRIVERAM = 12, + + /// The entire network. + SIID_WORLD = 13, + + /// A computer on the network. + SIID_SERVER = 15, + + /// A local printer or print destination. + SIID_PRINTER = 16, + + /// The Network virtual folder (FOLDERID_NetworkFolder/CSIDL_NETWORK). + SIID_MYNETWORK = 17, + + /// The Search feature. + SIID_FIND = 22, + + /// The Help and Support feature. + SIID_HELP = 23, + + /// Overlay for a shared item. + SIID_SHARE = 28, + + /// Overlay for a shortcut. + SIID_LINK = 29, + + /// Overlay for items that are expected to be slow to access. + SIID_SLOWFILE = 30, + + /// The Recycle Bin (empty). + SIID_RECYCLER = 31, + + /// The Recycle Bin (not empty). + SIID_RECYCLERFULL = 32, + + /// Audio CD media. + SIID_MEDIACDAUDIO = 40, + + /// Security lock. + SIID_LOCK = 47, + + /// A virtual folder that contains the results of a search. + SIID_AUTOLIST = 49, + + /// A network printer. + SIID_PRINTERNET = 50, + + /// A server shared on a network. + SIID_SERVERSHARE = 51, + + /// A local fax printer. + SIID_PRINTERFAX = 52, + + /// A network fax printer. + SIID_PRINTERFAXNET = 53, + + /// A file that receives the output of a Print to file operation. + SIID_PRINTERFILE = 54, + + /// A category that results from a Stack by command to organize the contents of a folder. + SIID_STACK = 55, + + /// Super Video CD (SVCD) media. + SIID_MEDIASVCD = 56, + + /// A folder that contains only subfolders as child items. + SIID_STUFFEDFOLDER = 57, + + /// Unknown drive type. + SIID_DRIVEUNKNOWN = 58, + + /// DVD drive. + SIID_DRIVEDVD = 59, + + /// DVD media. + SIID_MEDIADVD = 60, + + /// DVD-RAM media. + SIID_MEDIADVDRAM = 61, + + /// DVD-RW media. + SIID_MEDIADVDRW = 62, + + /// DVD-R media. + SIID_MEDIADVDR = 63, + + /// DVD-ROM media. + SIID_MEDIADVDROM = 64, + + /// CD+ (enhanced audio CD) media. + SIID_MEDIACDAUDIOPLUS = 65, + + /// CD-RW media. + SIID_MEDIACDRW = 66, + + /// CD-R media. + SIID_MEDIACDR = 67, + + /// A writeable CD in the process of being burned. + SIID_MEDIACDBURN = 68, + + /// Blank writable CD media. + SIID_MEDIABLANKCD = 69, + + /// CD-ROM media. + SIID_MEDIACDROM = 70, + + /// An audio file. + SIID_AUDIOFILES = 71, + + /// An image file. + SIID_IMAGEFILES = 72, + + /// A video file. + SIID_VIDEOFILES = 73, + + /// A mixed file. + SIID_MIXEDFILES = 74, + + /// Folder back. + SIID_FOLDERBACK = 75, + + /// Folder front. + SIID_FOLDERFRONT = 76, + + /// Security shield. Use for UAC prompts only. + SIID_SHIELD = 77, + + /// Warning. + SIID_WARNING = 78, + + /// Informational. + SIID_INFO = 79, + + /// Error. + SIID_ERROR = 80, + + /// Key. + SIID_KEY = 81, + + /// Software. + SIID_SOFTWARE = 82, + + /// A UI item, such as a button, that issues a rename command. + SIID_RENAME = 83, + + /// A UI item, such as a button, that issues a delete command. + SIID_DELETE = 84, + + /// Audio DVD media. + SIID_MEDIAAUDIODVD = 85, + + /// Movie DVD media. + SIID_MEDIAMOVIEDVD = 86, + + /// Enhanced CD media. + SIID_MEDIAENHANCEDCD = 87, + + /// Enhanced DVD media. + SIID_MEDIAENHANCEDDVD = 88, + + /// High definition DVD media in the HD DVD format. + SIID_MEDIAHDDVD = 89, + + /// High definition DVD media in the Blu-ray Disc™ format. + SIID_MEDIABLURAY = 90, + + /// Video CD (VCD) media. + SIID_MEDIAVCD = 91, + + /// DVD+R media. + SIID_MEDIADVDPLUSR = 92, + + /// DVD+RW media. + SIID_MEDIADVDPLUSRW = 93, + + /// A desktop computer. + SIID_DESKTOPPC = 94, + + /// A mobile computer (laptop). + SIID_MOBILEPC = 95, + + /// The User Accounts Control Panel item. + SIID_USERS = 96, + + /// Smart media. + SIID_MEDIASMARTMEDIA = 97, + + /// CompactFlash media. + SIID_MEDIACOMPACTFLASH = 98, + + /// A cell phone. + SIID_DEVICECELLPHONE = 99, + + /// A digital camera. + SIID_DEVICECAMERA = 100, + + /// A digital video camera. + SIID_DEVICEVIDEOCAMERA = 101, + + /// An audio player. + SIID_DEVICEAUDIOPLAYER = 102, + + /// Connect to network. + SIID_NETWORKCONNECT = 103, + + /// The Network and Internet Control Panel item. + SIID_INTERNET = 104, + + /// A compressed file with a .zip file name extension. + SIID_ZIPFILE = 105, + + /// The Additional Options Control Panel item. + SIID_SETTINGS = 106, + + /// + /// Windows Vista with Service Pack 1 (SP1) and later. High definition DVD drive (any type - HD DVD-ROM, HD DVD-R, HD-DVD-RAM) + /// that uses the HD DVD format. + /// + SIID_DRIVEHDDVD = 132, + + /// + /// Windows Vista with SP1 and later. High definition DVD drive (any type - BD-ROM, BD-R, BD-RE) that uses the Blu-ray Disc format. + /// + SIID_DRIVEBD = 133, + + /// Windows Vista with SP1 and later. High definition DVD-ROM media in the HD DVD-ROM format. + SIID_MEDIAHDDVDROM = 134, + + /// Windows Vista with SP1 and later. High definition DVD-R media in the HD DVD-R format. + SIID_MEDIAHDDVDR = 135, + + /// Windows Vista with SP1 and later. High definition DVD-RAM media in the HD DVD-RAM format. + SIID_MEDIAHDDVDRAM = 136, + + /// Windows Vista with SP1 and later. High definition DVD-ROM media in the Blu-ray Disc BD-ROM format. + SIID_MEDIABDROM = 137, + + /// Windows Vista with SP1 and later. High definition write-once media in the Blu-ray Disc BD-R format. + SIID_MEDIABDR = 138, + + /// Windows Vista with SP1 and later. High definition read/write media in the Blu-ray Disc BD-RE format. + SIID_MEDIABDRE = 139, + + /// Windows Vista with SP1 and later. A cluster disk array. + SIID_CLUSTEREDDRIVE = 140, + + /// The highest valid value in the enumeration. Values over 160 are Windows 7-only icons. + SIID_MAX_ICONS = 181, + } + /// /// Retrieves an object that implements an IQueryAssociations interface. /// @@ -377,8 +1035,8 @@ namespace Vanara.PInvoke /// /// For systems earlier than Windows Vista, use the AssocCreate function. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-assoccreateforclasses - // SHSTDAPI AssocCreateForClasses( const ASSOCIATIONELEMENT *rgClasses, ULONG cClasses, REFIID riid, void **ppv ); + // 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)] [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); @@ -447,8 +1105,8 @@ namespace Vanara.PInvoke /// /// Examples /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-commandlinetoargvw - // LPWSTR * CommandLineToArgvW( LPCWSTR lpCmdLine, int *pNumArgs ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-commandlinetoargvw LPWSTR * CommandLineToArgvW( LPCWSTR + // lpCmdLine, int *pNumArgs ); [DllImport(Lib.Shell32, SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "9889a016-b7a5-402b-8305-6f7c199d41b3")] [return: MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] @@ -477,8 +1135,8 @@ namespace Vanara.PInvoke /// the WM_DROPFILES message from File Manager. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragacceptfiles - // void DragAcceptFiles( HWND hWnd, BOOL fAccept ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragacceptfiles void DragAcceptFiles( HWND hWnd, BOOL + // fAccept ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "1f16f6e4-7847-4bc7-adce-995876db24bd")] public static extern void DragAcceptFiles(HandleRef hWnd, [MarshalAs(UnmanagedType.Bool)] bool fAccept); @@ -495,8 +1153,7 @@ namespace Vanara.PInvoke /// /// No return value. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragfinish - // void DragFinish( HDROP hDrop ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragfinish void DragFinish( HDROP hDrop ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "9b15e8a5-de68-4dcb-8e1a-0ee0393aa9db")] public static extern void DragFinish(IntPtr hDrop); @@ -543,8 +1200,8 @@ namespace Vanara.PInvoke /// is the required size, in characters, of the buffer, the terminating null character. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragqueryfilea - // UINT DragQueryFileA( HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragqueryfilea UINT DragQueryFileA( HDROP hDrop, UINT + // iFile, LPSTR lpszFile, UINT cch ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "93fab381-9035-46c4-ba9d-efb2d0801d84")] public static extern uint DragQueryFile(IntPtr hDrop, uint iFile, string lpszFile, uint cch); @@ -566,8 +1223,8 @@ namespace Vanara.PInvoke /// /// The window for which coordinates are returned is the window that received the WM_DROPFILES message. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragquerypoint - // BOOL DragQueryPoint( HDROP hDrop, POINT *ppt ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-dragquerypoint BOOL DragQueryPoint( HDROP hDrop, POINT + // *ppt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "87794ab0-a075-4a1f-869f-5998bdc57a1d")] [return: MarshalAs(UnmanagedType.Bool)] @@ -583,24 +1240,36 @@ namespace Vanara.PInvoke /// Type: HICON /// If successful, the function returns the handle to the new icon that was created; otherwise, NULL. /// - // HICON DuplicateIcon( _Reserved_ HINSTANCE hInst, _In_ HICON hIcon); - // https://msdn.microsoft.com/en-us/library/windows/desktop/bb776411(v=vs.85).aspx + // HICON DuplicateIcon( _Reserved_ HINSTANCE hInst, _In_ HICON hIcon); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776411(v=vs.85).aspx [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776411")] public static extern IntPtr DuplicateIcon(SafeLibraryHandle hInst, IntPtr hIcon); - /// - /// Gets a handle to an icon stored as a resource in a file or an icon stored in a file's associated executable file. - /// + /// Gets a handle to an icon stored as a resource in a file or an icon stored in a file's associated executable file. /// A handle to the instance of the calling application. - /// Pointer to a string that, on entry, specifies the full path and file name of the file that contains the icon. The function extracts the icon handle from that file, or from an executable file associated with that file. - /// When this function returns, if the icon handle was obtained from an executable file (either an executable file pointed to by lpIconPath or an associated executable file) the function stores the full path and file name of that executable in the buffer pointed to by this parameter. - /// Pointer to a WORD value that, on entry, specifies the index of the icon whose handle is to be obtained. - /// When the function returns, if the icon handle was obtained from an executable file(either an executable file pointed to by lpIconPath or an associated executable file), this value points to the icon's index in that file. - /// If the function succeeds, the return value is an icon handle. If the icon is extracted from an associated executable file, the function stores the full path and file name of the executable file in the string pointed to by lpIconPath, and stores the icon's identifier in the WORD pointed to by lpiIcon. - /// If the function fails, the return value is NULL. - // public static Icon ExtractAssociatedIcon( string filePath ) - // https://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon(v=vs.110).aspx + /// + /// Pointer to a string that, on entry, specifies the full path and file name of the file that contains the icon. The function + /// extracts the icon handle from that file, or from an executable file associated with that file. + /// + /// When this function returns, if the icon handle was obtained from an executable file (either an executable file pointed to by + /// lpIconPath or an associated executable file) the function stores the full path and file name of that executable in the buffer + /// pointed to by this parameter. + /// + /// + /// + /// Pointer to a WORD value that, on entry, specifies the index of the icon whose handle is to be obtained. + /// + /// When the function returns, if the icon handle was obtained from an executable file(either an executable file pointed to by + /// lpIconPath or an associated executable file), this value points to the icon's index in that file. + /// + /// + /// + /// If the function succeeds, the return value is an icon handle. If the icon is extracted from an associated executable file, the + /// function stores the full path and file name of the executable file in the string pointed to by lpIconPath, and stores the icon's + /// identifier in the WORD pointed to by lpiIcon. + /// If the function fails, the return value is NULL. + /// + // public static Icon ExtractAssociatedIcon( string filePath ) https://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon(v=vs.110).aspx [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776414")] public static extern IntPtr ExtractAssociatedIcon(SafeLibraryHandle hInst, StringBuilder lpIconPath, ref ushort lpiIcon); @@ -631,8 +1300,8 @@ namespace Vanara.PInvoke /// /// The icon handle returned by this function must be released by calling DestroyIcon when it is no longer needed. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-extractassociatediconexa - // HICON ExtractAssociatedIconExA( HINSTANCE hInst, LPSTR pszIconPath, WORD *piIconIndex, WORD *piIconId ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-extractassociatediconexa HICON ExtractAssociatedIconExA( + // HINSTANCE hInst, LPSTR pszIconPath, WORD *piIconIndex, WORD *piIconId ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "f32260b0-917b-4406-aeee-34f71a7c7309")] public static extern IntPtr ExtractAssociatedIconEx(SafeLibraryHandle hInst, StringBuilder pszIconPath, ref ushort piIconIndex, ref ushort piIconId); @@ -672,23 +1341,44 @@ namespace Vanara.PInvoke /// no icons were found in the file, the return value is NULL. /// /// - // HICON ExtractIcon( _Reserved_ HINSTANCE hInst, _In_ LPCTSTR lpszExeFileName, UINT nIconIndex); - // https://msdn.microsoft.com/en-us/library/windows/desktop/bb776416(v=vs.85).aspx + // HICON ExtractIcon( _Reserved_ HINSTANCE hInst, _In_ LPCTSTR lpszExeFileName, UINT nIconIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776416(v=vs.85).aspx [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776416")] public static extern IntPtr ExtractIcon(SafeLibraryHandle hInst, string lpszExeFileName, uint nIconIndex); /// - /// The ExtractIconEx function creates an array of handles to large or small icons extracted from the specified executable file, DLL, or icon file. + /// The ExtractIconEx function creates an array of handles to large or small icons extracted from the specified executable file, DLL, + /// or icon file. /// /// String that specifies the name of an executable file, DLL, or icon file from which icons will be extracted. - /// Specifies the zero-based index of the first icon to extract. For example, if this value is zero, the function extracts the first icon in the specified file. - /// If this value is –1 and phiconLarge and phiconSmall are both NULL, the function returns the total number of icons in the specified file. If the file is an executable file or DLL, the return value is the number of RT_GROUP_ICON resources. If the file is an .ico file, the return value is 1. - /// If this value is a negative number and either phiconLarge or phiconSmall is not NULL, the function begins by extracting the icon whose resource identifier is equal to the absolute value of nIconIndex. For example, use -3 to extract the icon whose resource identifier is 3. - /// An array of icon handles that receives handles to the large icons extracted from the file. If this parameter is NULL, no large icons are extracted from the file. - /// Array of icon handles that receives handles to the small icons extracted from the file. If this parameter is NULL, no small icons are extracted from the file. + /// + /// Specifies the zero-based index of the first icon to extract. For example, if this value is zero, the function extracts the first + /// icon in the specified file. + /// + /// If this value is –1 and phiconLarge and phiconSmall are both NULL, the function returns the total number of icons in the + /// specified file. If the file is an executable file or DLL, the return value is the number of RT_GROUP_ICON resources. If the file + /// is an .ico file, the return value is 1. + /// + /// + /// If this value is a negative number and either phiconLarge or phiconSmall is not NULL, the function begins by extracting the icon + /// whose resource identifier is equal to the absolute value of nIconIndex. For example, use -3 to extract the icon whose resource + /// identifier is 3. + /// + /// + /// + /// An array of icon handles that receives handles to the large icons extracted from the file. If this parameter is NULL, no large + /// icons are extracted from the file. + /// + /// + /// Array of icon handles that receives handles to the small icons extracted from the file. If this parameter is NULL, no small icons + /// are extracted from the file. + /// /// The number of icons to extract from the file. - /// If the nIconIndex parameter is -1, the phiconLarge parameter is NULL, and the phiconSmall parameter is NULL, then the return value is the number of icons contained in the specified file. Otherwise, the return value is the number of icons successfully extracted from the file. + /// + /// If the nIconIndex parameter is -1, the phiconLarge parameter is NULL, and the phiconSmall parameter is NULL, then the return + /// value is the number of icons contained in the specified file. Otherwise, the return value is the number of icons successfully + /// extracted from the file. + /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "ms648069")] public static extern int ExtractIconEx([MarshalAs(UnmanagedType.LPTStr)] string lpszFile, int nIconIndex, @@ -749,14 +1439,19 @@ namespace Vanara.PInvoke /// /// /// Use FindExecutable for documents. If you want to retrieve the path of an executable file, use the following: - /// Here, pszExecutableName is a pointer to a null-terminated string that specifies the name of the executable file, pszPath is a pointer to the null-terminated string buffer that receives the path to the executable file, and pcchOut is a pointer to a DWORD that specifies the number of characters in the pszPath buffer. When the function returns, pcchOut is set to the number of characters actually placed in the buffer. See AssocQueryString for more information. + /// + /// Here, pszExecutableName is a pointer to a null-terminated string that specifies the name of the executable file, pszPath is a + /// pointer to the null-terminated string buffer that receives the path to the executable file, and pcchOut is a pointer to a DWORD + /// that specifies the number of characters in the pszPath buffer. When the function returns, pcchOut is set to the number of + /// characters actually placed in the buffer. See AssocQueryString for more information. + /// /// /// When FindExecutable returns, the parameter may contain the path to the Dynamic Data Exchange (DDE) server started if a /// server does not respond to a request to initiate a DDE conversation with the DDE client application. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-findexecutablea - // HINSTANCE FindExecutableA( LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-findexecutablea HINSTANCE FindExecutableA( LPCSTR + // lpFile, LPCSTR lpDirectory, LPSTR lpResult ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "969edbd9-164e-457f-ab0a-dc4d069bf16b")] public static extern IntPtr FindExecutable(string lpFile, string lpDirectory, StringBuilder lpResult); @@ -775,8 +1470,8 @@ namespace Vanara.PInvoke /// /// This function initializes class WC_NETADDRESS. If this function returns TRUE, the control can be created. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-initnetworkaddresscontrol - // BOOL InitNetworkAddressControl( ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-initnetworkaddresscontrol BOOL + // InitNetworkAddressControl( ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "52b475e3-7335-4c34-80d7-ccd81af0e0ec")] [return: MarshalAs(UnmanagedType.Bool)] @@ -827,8 +1522,8 @@ namespace Vanara.PInvoke /// New /// is selected from a shortcut menu. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl/nf-shobjidl-shadddefaultpropertiesbyext - // SHSTDAPI SHAddDefaultPropertiesByExt( PCWSTR pszExt, IPropertyStore *pPropStore ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl/nf-shobjidl-shadddefaultpropertiesbyext SHSTDAPI + // SHAddDefaultPropertiesByExt( PCWSTR pszExt, IPropertyStore *pPropStore ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shobjidl.h", MSDNShortId = "ba0fec36-3983-4064-9202-6158af565d9b")] public static extern HRESULT SHAddDefaultPropertiesByExt([MarshalAs(UnmanagedType.LPWStr)] string pszExt, IPropertyStore pPropStore); @@ -863,8 +1558,8 @@ namespace Vanara.PInvoke /// This function should be called only once for the property sheet extension array named in . /// This function calls each extension's IShellPropSheetExt::AddPages method. See that page for further details. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shaddfrompropsheetextarray - // WINSHELLAPI UINT SHAddFromPropSheetExtArray( HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shaddfrompropsheetextarray WINSHELLAPI UINT + // SHAddFromPropSheetExtArray( HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "e0570cd6-dda2-43e4-8540-58baef37bf18")] public static extern uint SHAddFromPropSheetExtArray(IntPtr hpsxa, AddPropSheetPageProc lpfnAddPage, IntPtr lParam); @@ -888,8 +1583,7 @@ namespace Vanara.PInvoke /// /// You can free this memory by calling SHFree. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shalloc - // void * SHAlloc( SIZE_T cb ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shalloc void * SHAlloc( SIZE_T cb ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "621e4335-1484-4111-9cfe-7ae5c6d5c609")] public static extern IntPtr SHAlloc(SizeT cb); @@ -953,67 +1647,1230 @@ namespace Vanara.PInvoke /// message sent. Links to those documents are given in the See Also section. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shappbarmessage - // UINT_PTR SHAppBarMessage( DWORD dwMessage, PAPPBARDATA pData ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shappbarmessage UINT_PTR SHAppBarMessage( DWORD + // dwMessage, PAPPBARDATA pData ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "173d6eff-b33b-4d7d-bedd-5ebfb1e45954")] public static extern UIntPtr SHAppBarMessage(ABM dwMessage, ref APPBARDATA pData); /// - /// Performs an operation on a specified file. + /// Sends a message to the taskbar's status area. /// - /// A pointer to a SHELLEXECUTEINFO structure that contains and receives information about the application being executed. + /// + /// Type: DWORD + /// A value that specifies the action to be taken by this function. It can have one of the following values: + /// NIM_ADD (0x00000000) + /// + /// 0x00000000. Adds an icon to the status area. The icon is given an identifier in the NOTIFYICONDATA structure pointed to by + /// —either through its uID or guidItem member. This identifier is used in subsequent calls to Shell_NotifyIcon + /// to perform later actions on the icon. + /// + /// NIM_MODIFY (0x00000001) + /// + /// 0x00000001. Modifies an icon in the status area. NOTIFYICONDATA structure pointed to by uses the ID originally assigned to the + /// icon when it was added to the notification area (NIM_ADD) to identify the icon to be modified. + /// + /// NIM_DELETE (0x00000002) + /// + /// 0x00000002. Deletes an icon from the status area. NOTIFYICONDATA structure pointed to by uses the ID originally assigned to the + /// icon when it was added to the notification area (NIM_ADD) to identify the icon to be deleted. + /// + /// NIM_SETFOCUS (0x00000003) + /// + /// 0x00000003. Shell32.dll version 5.0 and later only. Returns focus to the taskbar notification area. Notification area icons + /// should use this message when they have completed their UI operation. For example, if the icon displays a shortcut menu, but the + /// user presses ESC to cancel it, use NIM_SETFOCUS to return focus to the notification area. + /// + /// NIM_SETVERSION (0x00000004) + /// + /// 0x00000004. Shell32.dll version 5.0 and later only. Instructs the notification area to behave according to the version number + /// specified in the uVersion member of the structure pointed to by . The version number specifies which members are recognized. + /// + /// + /// NIM_SETVERSION must be called every time a notification area icon is added (NIM_ADD)>. It does not need to be called with + /// NIM_MOFIDY. The version setting is not persisted once a user logs off. + /// + /// For details, see the Remarks section. + /// + /// + /// TBD + /// + /// + /// Type: BOOL + /// + /// Returns TRUE if successful, or FALSE otherwise. If is set to NIM_SETVERSION, the function returns TRUE if + /// the version was successfully changed, or FALSE if the requested version is not supported. + /// + /// + /// + /// + /// As of Windows 2000 (Shell32.dll version 5.0), if you set the uVersion member of the NOTIFYICONDATA structure pointed to by + /// to NOTIFYICON_VERSION_4 or higher, Shell_NotifyIcon mouse and keyboard events are handled differently than in earlier + /// versions of Windows. The differences include the following: + /// + /// + /// + /// If a user selects a notify icon's shortcut menu with the keyboard, the Shell now sends the associated application a + /// WM_CONTEXTMENU message. Earlier versions send WM_RBUTTONDOWN and WM_RBUTTONUP messages. + /// + /// + /// If a user selects a notify icon with the keyboard and activates it with the SPACEBAR or ENTER key, the version 5.0 Shell sends + /// the associated application an NIN_KEYSELECT notification. Earlier versions send WM_RBUTTONDOWN and WM_RBUTTONUP messages. + /// + /// + /// If a user selects a notify icon with the mouse and activates it with the ENTER key, the Shell now sends the associated + /// application an NIN_SELECT notification. Earlier versions send WM_RBUTTONDOWN and WM_RBUTTONUP messages. + /// + /// + /// As of Windows XP ( + /// Shell32.dll version 6.0 + /// + /// ), if a user passes the mouse pointer over an icon with which a balloon notification is associated, the Shell sends the following messages: + /// + /// + /// NIN_BALLOONSHOW. Sent when the balloon is shown (balloons are queued). + /// + /// NIN_BALLOONHIDE. Sent when the balloon disappears. For example, when the icon is deleted. This message is not sent if the balloon + /// is dismissed because of a timeout or if the user clicks the mouse. + /// + /// NIN_BALLOONTIMEOUT. Sent when the balloon is dismissed because of a timeout. + /// NIN_BALLOONUSERCLICK. Sent when the balloon is dismissed because the user clicked the mouse. + /// + /// + /// In addition to those messages, as of Windows Vista (Shell32.dll version 6.0.6), if a user passes the mouse pointer over an icon + /// with which a balloon notification is associated, the Windows Vista Shell also adds the following messages: + /// + /// + /// + /// NIN_POPUPOPEN. Sent when the user hovers the cursor over an icon to indicate that the richer pop-up UI should be used in place of + /// a standard textual tooltip. + /// + /// NIN_POPUPCLOSE. Sent when a cursor no longer hovers over an icon to indicate that the rich pop-up UI should be closed. + /// + /// Regardless of the operating system version, you can select which way the Shell should behave by calling + /// Shell_NotifyIcon + /// with + /// dwMessage + /// set to + /// NIM_SETVERSION + /// . Set the + /// uVersion + /// member of the + /// NOTIFYICONDATA + /// structure pointed to by + /// lpdata + /// to indicate whether you want Windows 2000, Windows Vista, or pre-version 5.0 (Windows 95) behavior. + /// + /// Note The messages discussed above are not conventional Windows messages. They are sent as the value of the + /// application-defined message that is specified in the uCallbackMessage member of the NOTIFYICONDATA structure pointed to by + /// , when Shell_NotifyIcon is called with the NIM_ADD flag set in . + /// + /// + /// As of Windows XP Service Pack 2 (SP2), a custom icon can be displayed in the notification balloon. This allows the calling + /// process to customize the notification beyond the previously available options of info, warning, and error, and distinguish it + /// from other types of notification for the user. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicona BOOL Shell_NotifyIconA( DWORD + // dwMessage, PNOTIFYICONDATAA lpData ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "a316bc29-5f19-4a04-a32b-f4caeea0c029")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool Shell_NotifyIcon(uint dwMessage, ref NOTIFYICONDATA lpData); + + /// + /// Gets the screen coordinates of the bounding rectangle of a notification icon. + /// + /// + /// Type: const NOTIFYICONIDENTIFIER* + /// Pointer to a NOTIFYICONIDENTIFIER structure that identifies the icon. + /// + /// + /// Type: RECT* + /// Pointer to a RECT structure that, when this function returns successfully, receives the coordinates of the icon. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shell_notifyicongetrect SHSTDAPI + // Shell_NotifyIconGetRect( const NOTIFYICONIDENTIFIER *identifier, RECT *iconLocation ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "81ad13be-a908-4079-b47c-6f983919700b")] + public static extern HRESULT Shell_NotifyIconGetRect(ref NOTIFYICONIDENTIFIER identifier, ref RECT iconLocation); + + /// + /// Displays a ShellAbout dialog box. + /// + /// + /// Type: HWND + /// A window handle to a parent window. This parameter can be NULL. + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string that contains text to be displayed in the title bar of the ShellAbout dialog box and + /// on the first line of the dialog box after the text "Microsoft". If the text contains a separator (#) that divides it into two + /// parts, the function displays the first part in the title bar and the second part on the first line after the text "Microsoft". + /// + /// + /// Windows 2000, Windows XP, Windows Server 2003: If the string pointed to by this parameter contains a separator (#), then + /// the string must be writeable. + /// + /// Windows Vista, Windows Server 2008: This string cannot exceed 200 characters in length. + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string that contains text to be displayed in the dialog box after the version and copyright + /// information. This parameter can be NULL. + /// + /// + /// + /// Type: HICON + /// + /// The handle of an icon that the function displays in the dialog box. This parameter can be NULL, in which case the function + /// displays the Windows icon. + /// + /// + /// + /// Type: int + /// TRUE if successful; otherwise, FALSE. + /// + /// + /// Note that the ShellAbout function dialog box uses text and a default icon that are specific to Windows. + /// + /// To see an example of a ShellAbout dialog box, choose About Windows from the Help menu drop-down list in + /// Windows Explorer. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shellabouta INT ShellAboutA( HWND hWnd, LPCSTR szApp, + // LPCSTR szOtherStuff, HICON hIcon ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "0919e356-84e8-475e-8628-23097b19c50d")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ShellAbout(HandleRef hWnd, string szApp, string szOtherStuff, IntPtr hIcon); + + /// + /// Performs an operation on a specified file. + /// + /// + /// Type: HWND + /// + /// A handle to the parent window used for displaying a UI or error messages. This value can be NULL if the operation is not + /// associated with a window. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string, referred to in this case as a , that specifies the action to be performed. The set + /// of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are + /// available verbs. The following verbs are commonly used: + /// + /// edit + /// Launches an editor and opens the document for editing. If is not a document file, the function will fail. + /// explore + /// Explores a folder specified by . + /// find + /// Initiates a search beginning in the directory specified by . + /// open + /// Opens the item specified by the parameter. The item can be a file or folder. + /// print + /// Prints the file specified by . If is not a document file, the function fails. + /// NULL + /// + /// The default verb is used, if available. If not, the "open" verb is used. If neither verb is available, the system uses the first + /// verb listed in the registry. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string that specifies the file or object on which to execute the specified verb. To specify + /// a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported on all objects. For example, + /// not all document types support the "print" verb. If a relative path is used for the parameter do not use a relative path for . + /// + /// + /// + /// Type: LPCTSTR + /// + /// If specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to + /// be passed to the application. The format of this string is determined by the verb that is to be invoked. If specifies a document + /// file, should be NULL. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string that specifies the default (working) directory for the action. If this value is + /// NULL, the current working directory is used. If a relative path is provided at , do not use a relative path for . + /// + /// + /// + /// Type: INT + /// + /// The flags that specify how an application is to be displayed when it is opened. If specifies a document file, the flag is simply + /// passed to the associated application. It is up to the application to decide how to handle it. These values are defined in Winuser.h. + /// + /// SW_HIDE (0) + /// Hides the window and activates another window. + /// SW_MAXIMIZE (3) + /// Maximizes the specified window. + /// SW_MINIMIZE (6) + /// Minimizes the specified window and activates the next top-level window in the z-order. + /// SW_RESTORE (9) + /// + /// Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and + /// position. An application should specify this flag when restoring a minimized window. + /// + /// SW_SHOW (5) + /// Activates the window and displays it in its current size and position. + /// SW_SHOWDEFAULT (10) + /// + /// Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to the CreateProcess function by the + /// program that started the application. An application should call ShowWindow with this flag to set the initial show state of its + /// main window. + /// + /// SW_SHOWMAXIMIZED (3) + /// Activates the window and displays it as a maximized window. + /// SW_SHOWMINIMIZED (2) + /// Activates the window and displays it as a minimized window. + /// SW_SHOWMINNOACTIVE (7) + /// Displays the window as a minimized window. The active window remains active. + /// SW_SHOWNA (8) + /// Displays the window in its current state. The active window remains active. + /// SW_SHOWNOACTIVATE (4) + /// Displays a window in its most recent size and position. The active window remains active. + /// SW_SHOWNORMAL (1) + /// + /// Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. + /// An application should specify this flag when displaying the window for the first time. + /// + /// + /// + /// Type: HINSTANCE + /// + /// If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the + /// cause of the failure. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is + /// not a true HINSTANCE, however. It can be cast only to an int and compared to either 32 or the following error codes below. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// 0 + /// The operating system is out of memory or resources. + /// + /// + /// ERROR_FILE_NOT_FOUND + /// The specified file was not found. + /// + /// + /// ERROR_PATH_NOT_FOUND + /// The specified path was not found. + /// + /// + /// ERROR_BAD_FORMAT + /// The .exe file is invalid (non-Win32 .exe or error in .exe image). + /// + /// + /// SE_ERR_ACCESSDENIED + /// The operating system denied access to the specified file. + /// + /// + /// SE_ERR_ASSOCINCOMPLETE + /// The file name association is incomplete or invalid. + /// + /// + /// SE_ERR_DDEBUSY + /// The DDE transaction could not be completed because other DDE transactions were being processed. + /// + /// + /// SE_ERR_DDEFAIL + /// The DDE transaction failed. + /// + /// + /// SE_ERR_DDETIMEOUT + /// The DDE transaction could not be completed because the request timed out. + /// + /// + /// SE_ERR_DLLNOTFOUND + /// The specified DLL was not found. + /// + /// + /// SE_ERR_FNF + /// The specified file was not found. + /// + /// + /// SE_ERR_NOASSOC + /// + /// There is no application associated with the given file name extension. This error will also be returned if you attempt to print a + /// file that is not printable. + /// + /// + /// + /// SE_ERR_OOM + /// There was not enough memory to complete the operation. + /// + /// + /// SE_ERR_PNF + /// The specified path was not found. + /// + /// + /// SE_ERR_SHARE + /// A sharing violation occurred. + /// + /// + /// + /// + /// + /// Because ShellExecute can delegate execution to Shell extensions (data sources, context menu handlers, verb + /// implementations) that are activated using Component Object Model (COM), COM should be initialized before ShellExecute is + /// called. Some Shell extensions require the COM single-threaded apartment (STA) type. In that case, COM should be initialized as + /// shown here: + /// + /// This method allows you to execute any commands in a folder's shortcut menu or stored in the registry. + /// To open a folder, use either of the following calls: + /// or + /// To explore a folder, use the following call: + /// To launch the Shell's Find utility for a directory, use the following call. + /// If + /// lpOperation + /// is + /// NULL + /// , the function opens the file specified by + /// lpFile + /// . If + /// lpOperation + /// is "open" or "explore", the function attempts to open or explore the folder. + /// To obtain information about the application that is launched as a result of calling ShellExecute, use ShellExecuteEx. + /// + /// Note The Launch folder windows in a separate process setting in Folder Options affects ShellExecute. If that + /// option is disabled (the default setting), ShellExecute uses an open Explorer window rather than launch a new one. If no + /// Explorer window is open, ShellExecute launches a new one. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shellexecutea HINSTANCE ShellExecuteA( HWND hwnd, LPCSTR + // lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "8b1f3978-a0ee-4684-8a37-98e270b63897")] + public static extern IntPtr ShellExecute(HandleRef hwnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, ShowWindowCommand nShowCmd); + + /// Performs an operation on a specified file. + /// + /// A pointer to a SHELLEXECUTEINFO structure that contains and receives information about the application being executed. + /// /// Returns TRUE if successful; otherwise, FALSE. Call GetLastError for extended error information. [DllImport(Lib.Shell32, CharSet = CharSet.Auto, SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("Shellapi.h", MSDNShortId = "bb762154")] public static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo); - /// Copies, moves, renames, or deletes a file system object. This function has been replaced in Windows Vista by . - /// A pointer to an SHFILEOPSTRUCT structure that contains information this function needs to carry out the specified operation. This parameter must contain a valid value that is not NULL. You are responsible for validating the value. If you do not validate it, you will experience unexpected results. + /// + /// Empties the Recycle Bin on the specified drive. + /// + /// + /// Type: HWND + /// + /// A handle to the parent window of any dialog boxes that might be displayed during the operation. This parameter can be NULL. + /// + /// + /// + /// Type: LPCTSTR + /// + /// The address of a null-terminated string of maximum length MAX_PATH that contains the path of the root drive on which the Recycle + /// Bin is located. This parameter can contain the address of a string formatted with the drive, folder, and subfolder names, for + /// example c:\windows\system. It can also contain an empty string or NULL. If this value is an empty string or NULL, + /// all Recycle Bins on all drives will be emptied. + /// + /// + /// + /// Type: DWORD + /// One or more of the following values. + /// SHERB_NOCONFIRMATION + /// No dialog box confirming the deletion of the objects will be displayed. + /// SHERB_NOPROGRESSUI + /// No dialog box indicating the progress will be displayed. + /// SHERB_NOSOUND + /// No sound will be played when the operation is complete. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shemptyrecyclebina SHSTDAPI SHEmptyRecycleBinA( HWND + // hwnd, LPCSTR pszRootPath, DWORD dwFlags ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "c3995be7-bc8b-4e1f-8ef6-fdf4c0a75720")] + public static extern HRESULT SHEmptyRecycleBin(HandleRef hwnd, string pszRootPath, SHERB dwFlags); + + /// + /// Enumerates the user accounts that have unread email. + /// + /// + /// Type: HKEY + /// A valid HKEY for a given user. + /// + /// + /// Type: DWORD + /// The index of the user account. + /// + /// + /// Type: LPTSTR + /// A pointer to a Unicode string that specifies the email address of an account belonging to the specified user. + /// + /// + /// Type: int + /// The number of characters in the email address. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// The parameter is the HKEY for the root of the user's information, for example HKEY_CURRENT_USER, or any key enumerated + /// under HKEY_USERS. + /// + /// + // 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)] + [PInvokeData("shellapi.h", MSDNShortId = "67ec8355-f902-4b71-972f-94e403701f96")] + public static extern HRESULT SHEnumerateUnreadMailAccountsW(IntPtr hKeyUser, uint dwIndex, StringBuilder pszMailAddress, int cchMailAddress); + + /// + /// Enforces strict validation of parameters used in a call to CreateProcess or ShellExecute. + /// + /// + /// Type: PCWSTR + /// + /// A command line, which may or may not include parameters. If the parameters are substitution parameters, then + /// SHEvaluateSystemCommandTemplate should be called before parameters have been replaced. + /// + /// + /// + /// Type: PWSTR* + /// + /// A pointer to the verified path to the application. This value should be passed as the parameter in a call to CreateProcess or as + /// the parameter in a call to ShellExecute. This resource is allocated using CoTaskMemAlloc, and it is the responsibility of the + /// caller to free the resource when it is no longer needed by calling CoTaskMemFree. + /// + /// + /// + /// Type: PWSTR* + /// + /// A pointer to a command-line string template to be used in a call to CreateProcess. Command-line parameters should be specified + /// based on this template, and then passed as the parameter to CreateProcess. It is guaranteed to be of a form that + /// PathGetArgs can always read correctly. This resource is allocated using CoTaskMemAlloc, and it is the responsibility of the + /// caller to free the resource when it is no longer needed by calling CoTaskMemFree. + /// + /// This parameter can be NULL if this function is not being used in association with a call to CreateProcess. + /// + /// + /// Type: PWSTR* + /// + /// A pointer to a command-line string template to be used in a call to ShellExecute. Command-line parameters should be specified + /// based on this template, and then passed as the parameter to ShellExecute. This parameter is identical to calling + /// PathGetArgs. This resource is allocated using CoTaskMemAlloc, and it is the responsibility of the caller to free the resource + /// when it is no longer needed by calling CoTaskMemFree. + /// + /// This parameter can be NULL if this function is not being used in association with a call to CreateProcess. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// This function is used when a calling process needs the deterministic behavior from a command template, regardless of execution + /// context. It ignores the current process state, such as the , GetCurrentDirectory, and parent process directory. + /// + /// This function is used when the command is hard-coded. + /// + /// This function is used by ShellExecute when handling file associations from HKEY_CLASSES_ROOT. The purpose of this function is to + /// reduce CreateProcess command-line exploits. It is not designed for processing user input and if used for that purpose can + /// generate unexpected failures. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shevaluatesystemcommandtemplate SHSTDAPI + // SHEvaluateSystemCommandTemplate( PCWSTR pszCmdTemplate, PWSTR *ppszApplication, PWSTR *ppszCommandLine, PWSTR *ppszParameters ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("shellapi.h", MSDNShortId = "554b941d-7d03-47ae-a23a-2c47c5ca1044")] + public static extern HRESULT SHEvaluateSystemCommandTemplate(string pszCmdTemplate, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszApplication, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszCommandLine, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszParameters); + + /// + /// Copies, moves, renames, or deletes a file system object. This function has been replaced in Windows Vista by . + /// + /// + /// A pointer to an SHFILEOPSTRUCT structure that contains information this function needs to carry out the specified operation. This + /// parameter must contain a valid value that is not NULL. You are responsible for validating the value. If you do not validate it, + /// you will experience unexpected results. + /// /// Returns zero if successful; otherwise nonzero. Applications normally should simply check for zero or nonzero. [PInvokeData("Shellapi.h")] [DllImport("shell32.dll", CharSet = CharSet.Auto)] public static extern int SHFileOperation([In] ref SHFILEOPSTRUCT lpFileOp); /// - /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. + /// Frees a file name mapping object that was retrieved by the SHFileOperation function. /// - /// A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative paths are valid. - /// If the uFlags parameter includes the SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully qualified PIDL. Relative PIDLs are not allowed. - /// If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes. - /// This string can use either short (the 8.3 form) or long file names. - /// A combination of one or more file attribute flags (FILE_ATTRIBUTE_ values as defined in Winnt.h). If uFlags does not include the SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored. + /// + /// Type: HANDLE + /// A handle to the file name mapping object to be freed. + /// + /// + /// This function does not return a value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shfreenamemappings void SHFreeNameMappings( HANDLE + // hNameMappings ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "4552b2e0-9257-48f8-84cc-003217f1696f")] + public static extern void SHFreeNameMappings(IntPtr hNameMappings); + + /// Retrieves disk space information for a disk volume. + /// + /// Type: LPCTSTR + /// + /// A null-terminated string that specifies the volume for which size information is retrieved. This can be a drive letter, UNC name, + /// or the path of a folder. You cannot use NULL to represent the current drive. + /// + /// + /// When using Shell32.dll versions previous to version 5.0, this must be an ANSI string. Unicode is not supported in those versions. + /// + /// + /// + /// Type: ULARGE_INTEGER* + /// + /// The address of a ULARGE_INTEGER value that receives the number of bytes on the volume available to the calling + /// application. If the operating system implements per-user quotas, this value may be less than the total number of free bytes on + /// the volume. + /// + /// + /// + /// Type: ULARGE_INTEGER* + /// The address of a ULARGE_INTEGER value that receives the total size of the volume, in bytes. + /// + /// + /// Type: ULARGE_INTEGER* + /// The address of a ULARGE_INTEGER value that receives the number of bytes of free space on the volume. + /// + /// + /// Type: BOOL + /// Returns TRUE if successful, FALSE otherwise. + /// + // BOOL SHGetDiskFreeSpace( LPCTSTR pszVolume, ULARGE_INTEGER *pqwFreeCaller, ULARGE_INTEGER *pqwTot, ULARGE_INTEGER *pqwFree); https://msdn.microsoft.com/en-us/library/windows/desktop/bb762176(v=vs.85).aspx + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("Shellapi.h", MSDNShortId = "bb762176")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHGetDiskFreeSpace(string pszVolume, out ulong pqwFreeCaller, out ulong pqwTot, out ulong pqwFree); + + /// + /// Retrieves disk space information for a disk volume. + /// + /// + /// Type: LPCTSTR + /// + /// A null-terminated string that specifies the volume for which size information is retrieved. This can be a drive letter, UNC name, + /// or the path of a folder. You cannot use NULL to represent the current drive. + /// + /// + /// + /// Type: ULARGE_INTEGER* + /// + /// Pointer to a value that receives the number of bytes on the volume available to the calling application. If the operating system + /// implements per-user quotas, this value may be less than the total number of free bytes on the volume. + /// + /// + /// + /// Type: ULARGE_INTEGER* + /// Pointer to a value that receives the total size of the volume, in bytes. + /// + /// + /// Type: ULARGE_INTEGER* + /// Pointer to a value that receives the number of bytes of free space on the volume. + /// + /// + /// Type: BOOL + /// Returns TRUE if successful, FALSE otherwise. + /// + /// + /// + /// The similarly named function SHGetDiskFreeSpace is merely an alias for SHGetDiskFreeSpaceEx. When you call + /// SHGetDiskFreeSpace you actually call this function. + /// + /// + /// This function calls the GetDiskFreeSpaceEx function if it is available on the operating system. If GetDiskFreeSpaceEx is + /// not available, it is emulated by calling the GetDiskFreeSpace function and manipulating the return values. For additional + /// information, see the documentation for GetDiskFreeSpaceEx. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetdiskfreespaceexa BOOL SHGetDiskFreeSpaceExA( LPCSTR + // pszDirectoryName, ULARGE_INTEGER *pulFreeBytesAvailableToCaller, ULARGE_INTEGER *pulTotalNumberOfBytes, ULARGE_INTEGER + // *pulTotalNumberOfFreeBytes ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "f8adbfa8-124a-4934-b5dc-16e261c15a8b")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHGetDiskFreeSpaceEx(string pszDirectoryName, out ulong pulFreeBytesAvailableToCaller, out ulong pulTotalNumberOfBytes, out ulong pulTotalNumberOfFreeBytes); + + /// + /// Returns the type of media that is in the given drive. + /// + /// + /// Type: PCWSTR + /// The drive in which to check the media type. + /// + /// + /// Type: DWORD* + /// A pointer to the type of media in the given drive. A combination of ARCONTENT flags. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetdrivemedia HRESULT SHGetDriveMedia( PCWSTR + // pszDrive, DWORD *pdwMediaContent ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "9b1208cd-3c13-456a-8a7f-0f149cb86d38")] + public static extern HRESULT SHGetDriveMedia([MarshalAs(UnmanagedType.LPWStr)] string pszDrive, out ARCONTENT pdwMediaContent); + + /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. + /// + /// A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative + /// paths are valid. + /// + /// If the uFlags parameter includes the SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that + /// contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully + /// qualified PIDL. Relative PIDLs are not allowed. + /// + /// + /// If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The + /// function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes + /// parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing + /// FILE_ATTRIBUTE_NORMAL in dwFileAttributes. + /// + /// This string can use either short (the 8.3 form) or long file names. + /// + /// + /// A combination of one or more file attribute flags (FILE_ATTRIBUTE_ values as defined in Winnt.h). If uFlags does not include the + /// SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored. + /// /// Pointer to a SHFILEINFO structure to receive the file information. /// The size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter. /// The flags that specify the file information to retrieve. - /// Returns a value whose meaning depends on the uFlags parameter. + /// + /// Returns a value whose meaning depends on the uFlags parameter. /// If uFlags does not contain SHGFI_EXETYPE or SHGFI_SYSICONINDEX, the return value is nonzero if successful, or zero otherwise. - /// If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the following values. + /// + /// If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the + /// following values. + /// + /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto, SetLastError = true)] [PInvokeData("Shellapi.h", MSDNShortId = "bb762179")] public static extern IntPtr SHGetFileInfo(string pszPath, FileAttributes dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, SHGFI uFlags); - /// - /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. - /// - /// A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative paths are valid. - /// If the uFlags parameter includes the SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully qualified PIDL. Relative PIDLs are not allowed. - /// If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL in dwFileAttributes. - /// This string can use either short (the 8.3 form) or long file names. - /// A combination of one or more file attribute flags (FILE_ATTRIBUTE_ values as defined in Winnt.h). If uFlags does not include the SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored. + /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. + /// + /// A pointer to a null-terminated string of maximum length MAX_PATH that contains the path and file name. Both absolute and relative + /// paths are valid. + /// + /// If the uFlags parameter includes the SHGFI_PIDL flag, this parameter must be the address of an ITEMIDLIST (PIDL) structure that + /// contains the list of item identifiers that uniquely identifies the file within the Shell's namespace. The PIDL must be a fully + /// qualified PIDL. Relative PIDLs are not allowed. + /// + /// + /// If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. The + /// function will proceed as if the file exists with the specified name and with the file attributes passed in the dwFileAttributes + /// parameter. This allows you to obtain information about a file type by passing just the extension for pszPath and passing + /// FILE_ATTRIBUTE_NORMAL in dwFileAttributes. + /// + /// This string can use either short (the 8.3 form) or long file names. + /// + /// + /// A combination of one or more file attribute flags (FILE_ATTRIBUTE_ values as defined in Winnt.h). If uFlags does not include the + /// SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored. + /// /// Pointer to a SHFILEINFO structure to receive the file information. /// The size, in bytes, of the SHFILEINFO structure pointed to by the psfi parameter. /// The flags that specify the file information to retrieve. - /// Returns a value whose meaning depends on the uFlags parameter. + /// + /// Returns a value whose meaning depends on the uFlags parameter. /// If uFlags does not contain SHGFI_EXETYPE or SHGFI_SYSICONINDEX, the return value is nonzero if successful, or zero otherwise. - /// If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the following values. + /// + /// If uFlags contains the SHGFI_EXETYPE flag, the return value specifies the type of the executable file. It will be one of the + /// following values. + /// + /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto, SetLastError = true)] [PInvokeData("Shellapi.h", MSDNShortId = "bb762179")] public static extern IntPtr SHGetFileInfo(PIDL itemIdList, FileAttributes dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, SHGFI uFlags); + /// + /// Retrieves the localized name of a file in a Shell folder. + /// + /// + /// Type: PCWSTR + /// A pointer to a string that specifies the fully qualified path of the file. + /// + /// + /// Type: PWSTR + /// When this function returns, contains a pointer to a string resource that specifies the localized version of the file name. + /// + /// + /// Type: UINT + /// When this function returns, contains the size of the string, in WCHARs, at pszResModule. + /// + /// + /// Type: int* + /// When this function returns, contains a pointer to the ID of the localized file name in the resource file. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetlocalizedname SHSTDAPI SHGetLocalizedName( PCWSTR + // pszPath, PWSTR pszResModule, UINT cch, int *pidsRes ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "2929b77f-4467-44a8-9885-96f0c3e35584")] + public static extern HRESULT SHGetLocalizedName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszResModule, uint cch, out int pidsRes); + + /// + /// + /// Creates a name for a new shortcut based on the shortcut's proposed target. This function does not create the shortcut, just the name. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to the path and file name of the shortcut's target. If does not contain the SHGNLI_PIDL value, this parameter is + /// the address of a null-terminated string that contains the target. If contains the SHGNLI_PIDL value, this parameter is a + /// PIDL that represents the target. + /// + /// + /// + /// Type: LPCTSTR + /// A pointer to a null-terminated string that contains the path of the folder in which the shortcut would be created. + /// + /// + /// Type: LPTSTR + /// + /// A pointer to a string that receives the null-terminated path and file name for the shortcut. This buffer is assumed to be at + /// least MAX_PATH characters in size. + /// + /// + /// + /// Type: BOOL* + /// + /// The address of a BOOL value that receives a flag indicating whether the shortcut would be copied. When a shortcut to + /// another shortcut is created, the Shell simply copies the target shortcut and modifies that copied shortcut appropriately. This + /// parameter receives a nonzero value if the target specified in specifies a shortcut that will cause the target shortcut to be + /// copied. This parameter receives zero if the target does not specify a shortcut that would be copied. + /// + /// + /// + /// Type: UINT + /// The options for the function. This can be zero or a combination of the following values. + /// SHGNLI_PIDL (0x000000001) + /// + /// 0x000000001. The target pointed to by is a PIDL that represents the target. If this flag is not included, is regarded as the + /// address of a string that contains the path and file name of the target. + /// + /// SHGNLI_NOUNIQUE (0x000000002) + /// + /// 0x000000002. Skip the normal checks that ensure that the shortcut name is unique within the destination folder. If this flag is + /// not included, the function creates the shortcut name and then determines whether the name is unique in the destination folder. If + /// a file with the same name already exists in the destination folder, the shortcut name will be modified. This process is repeated + /// until a unique name is found. + /// + /// SHGNLI_PREFIXNAME (0x000000004) + /// 0x000000004. The created name will be preceded by the string "Shortcut to ". + /// SHGNLI_NOLNK (0x000000008) + /// + /// 0x000000008. Version 5.0 Do not add the .lnk file name extension. You must set the _WIN32_IE macro to 5.01 or greater to + /// use this flag. For more information about versioning, see Shell and Common Controls Versions. + /// + /// SHGNLI_NOLOCNAME (0x000000010) + /// + /// 0x000000010. Windows Vista and later. Use the non-localized parsing name of the target pointed to by as the name of the + /// shortcut file. If this flag is not set, the localized name is used. + /// + /// SHGNLI_USEURLEXT (0x000000020) + /// + /// 0x000000020. Windows 7 and later. Append a .url file name extension (rather than .lnk) to the name pointed to by . If this + /// flag is not set, the shortcut name uses a .lnk extension unless SHGNLI_NOLNK is set. + /// + /// + /// + /// Type: BOOL + /// Returns TRUE if successful; otherwise, FALSE. + /// + /// + /// + /// SHGetNewLinkInfo determines whether the destination file system supports long file names. If it does, a long file name is + /// used for the shortcut name. If the destination file system does not support long file names, the shortcut name is returned in an + /// 8.3 format. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetnewlinkinfoa BOOL SHGetNewLinkInfoA( LPCSTR + // pszLinkTo, LPCSTR pszDir, LPSTR pszName, BOOL *pfMustCopy, UINT uFlags ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "ca658d5c-af7b-400c-8f4d-7d4b07bf7f2b")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHGetNewLinkInfo(string pszLinkTo, string pszDir, StringBuilder pszName, [MarshalAs(UnmanagedType.Bool)] out bool pfMustCopy, SHGNLI uFlags); + + /// + /// + /// Retrieves an object that represents a specific window's collection of properties, which allows those properties to be queried or set. + /// + /// + /// + /// Type: HWND + /// A handle to the window whose properties are being retrieved. + /// + /// + /// Type: REFIID + /// A reference to the IID of the property store object to retrieve through . This is typically IID_IPropertyStore. + /// + /// + /// Type: void** + /// When this function returns, contains the interface pointer requested in . This is typically IPropertyStore. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// An application can use this function to obtain access to a window's property store so that it can set an explicit Application + /// User Model ID (AppUserModelID) in the System.AppUserModel.ID property. + /// + /// + /// A window's properties must be removed before the window is closed. If this is not done, the resources used by those properties + /// are not returned to the system. A property is removed by setting it to the PROPVARIANT type VT_EMPTY. + /// + /// + /// When a call is made to IPropertyStore::SetValue on the object retrieved through , the properties and values are immediately + /// stored on the window. Therefore, no call to IPropertyStore::Commit is needed. No error occurs if it is called, but it has no effect. + /// + /// + /// An application sets AppUserModelIDs on individual windows to control the application's taskbar grouping and Jump List contents. + /// For instance, a suite application might want to provide a different taskbar button for each of its subfeatures, with the windows + /// relating to that subfeature grouped under that button. Without window-level AppUserModelIDs, those windows would all be grouped + /// together under the main process. + /// + /// + /// Applications should also use this property store to set these relaunch properties so that the system can return the application + /// to that state. + /// + /// + /// System.AppUserModel.RelaunchCommand + /// System.AppUserModel.RelaunchDisplayNameResource + /// System.AppUserModel.RelaunchIconResource + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetpropertystoreforwindow SHSTDAPI + // SHGetPropertyStoreForWindow( HWND hwnd, REFIID riid, void **ppv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "772aa2c8-6dd1-480c-a008-58f30902cb80")] + public static extern HRESULT SHGetPropertyStoreForWindow(HandleRef hwnd, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); + + /// + /// Retrieves information about system-defined Shell icons. + /// + /// + /// Type: SHSTOCKICONID + /// One of the values from the SHSTOCKICONID enumeration that specifies which icon should be retrieved. + /// + /// + /// Type: UINT + /// A combination of zero or more of the following flags that specify which information is requested. + /// SHGSI_ICONLOCATION + /// + /// The szPath and iIcon members of the SHSTOCKICONINFO structure receive the path and icon index of the requested + /// icon, in a format suitable for passing to the ExtractIcon function. The numerical value of this flag is zero, so you always get + /// the icon location regardless of other flags. + /// + /// SHGSI_ICON + /// The hIcon member of the SHSTOCKICONINFO structure receives a handle to the specified icon. + /// SHGSI_SYSICONINDEX + /// + /// The iSysImageImage member of the SHSTOCKICONINFO structure receives the index of the specified icon in the system imagelist. + /// + /// SHGSI_LINKOVERLAY + /// Modifies the SHGSI_ICON value by causing the function to add the link overlay to the file's icon. + /// SHGSI_SELECTED + /// Modifies the SHGSI_ICON value by causing the function to blend the icon with the system highlight color. + /// SHGSI_LARGEICON + /// + /// Modifies the SHGSI_ICON value by causing the function to retrieve the large version of the icon, as specified by the SM_CXICON + /// and SM_CYICON system metrics. + /// + /// SHGSI_SMALLICON + /// + /// Modifies the SHGSI_ICON value by causing the function to retrieve the small version of the icon, as specified by the SM_CXSMICON + /// and SM_CYSMICON system metrics. + /// + /// SHGSI_SHELLICONSIZE + /// + /// Modifies the SHGSI_LARGEICON or SHGSI_SMALLICON values by causing the function to retrieve the Shell-sized icons rather than the + /// sizes specified by the system metrics. + /// + /// + /// + /// Type: SHSTOCKICONINFO* + /// + /// A pointer to a SHSTOCKICONINFO structure. When this function is called, the cbSize member of this structure needs to be + /// set to the size of the SHSTOCKICONINFO structure. When this function returns, contains a pointer to a + /// SHSTOCKICONINFO structure that contains the requested information. + /// + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// If this function returns an icon handle in the hIcon member of the SHSTOCKICONINFO structure pointed to by , you are + /// responsible for freeing the icon with DestroyIcon when you no longer need it. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetstockiconinfo SHSTDAPI SHGetStockIconInfo( + // SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "c08b1a53-e67c-4ed0-a9c6-d000c448e182")] + public static extern HRESULT SHGetStockIconInfo(SHSTOCKICONID siid, uint uFlags, ref SHSTOCKICONINFO psii); + + /// + /// Retrieves a specified user's unread message count for any or all email accounts. + /// + /// + /// Type: HKEY + /// + /// A valid HKEY for a given user. This parameter should be NULL if the function is called in a user's environment, in which + /// case HKEY_CURRENT_USER is used. This parameter should be NULL if the function is called from the SYSTEM context, in + /// which case HKEY_USERS<i>{SID} is used. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a string in Unicode that specifies the email address of an account belonging to the specified user. When this + /// parameter is NULL, returns the total count of unread messages for all accounts owned by the designated user. + /// + /// + /// + /// Type: DWORD* + /// Pointer to a DWORD value which receives the unread message count. + /// + /// + /// Type: FILETIME* + /// + /// A pointer to a FILETIME structure. The use of this parameter is determined by whether is NULL. If is NULL, then + /// this parameter is treated as an [in] parameter, which specifies a filter, so that only unread mail newer than the specified time + /// appears. If is not NULL, then this parameter is treated as an [out] parameter, which points to a FILETIME structure + /// into which the function places the timestamp of the last SHSetUnreadMailCount call for the specified user and email account. + /// + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a string that returns the ShellExecute command statement passed into the last SHSetUnreadMailCount call for the + /// specified user and email account. This command string starts the email application that owns the account referenced by . If the + /// ShellExecute command is not required, this parameter can be NULL. If is NULL, this parameter is ignored and must be NULL. + /// + /// + /// + /// Type: int + /// + /// The maximum size, in characters, of the ShellExecute command buffer pointed to by . This parameter must be zero for total counts + /// when is NULL. It can also be NULL whenever the ShellExecute command string is not required. + /// + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shgetunreadmailcountw HRESULT SHGetUnreadMailCountW( + // HKEY hKeyUser, LPCWSTR pszMailAddress, DWORD *pdwCount, FILETIME *pFileTime, LPWSTR pszShellExecuteCommand, int + // cchShellExecuteCommand ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("shellapi.h", MSDNShortId = "d2a57fa0-13fe-4e12-89cc-8a6dbdb44f08")] + public static extern HRESULT SHGetUnreadMailCountW(IntPtr hKeyUser, string pszMailAddress, out uint pdwCount, ref System.Runtime.InteropServices.ComTypes.FILETIME pFileTime, StringBuilder pszShellExecuteCommand, int cchShellExecuteCommand); + + /// + /// Executes a command on a printer object. + /// + /// Note This function has been deprecated as of Windows Vista. It is recommended that, in its place, you invoke verbs on + /// printers through IContextMenu or ShellExecute. + /// + /// + /// + /// Type: HWND + /// The handle of the parent window of any windows or dialog boxes that are created during the operation. + /// + /// + /// Type: UINT + /// The type of printer operation to perform. One of the following values: + /// PRINTACTION_OPEN (0) + /// 0x0. Open the printer specified by . The parameter is ignored. + /// PRINTACTION_PROPERTIES (1) + /// + /// 0x1. Display the property pages for the printer specified by . The parameter can be NULL or can name a specific property + /// sheet to display, either by name or number. If the high WORD of is nonzero, it is assumed that this parameter is a pointer + /// to a buffer that contains the name of the sheet to open. Otherwise, is seen as the zero-based index of the property sheet to open. + /// + /// PRINTACTION_NETINSTALL (2) + /// 0x2. Install the network printer specified by . The parameter is ignored. + /// PRINTACTION_NETINSTALLLINK (3) + /// + /// 0x3. Create a shortcut to the network printer specified by . The parameter specifies the drive and path of the folder in which to + /// create the shortcut. The network printer must already have been installed on the local computer. + /// + /// PRINTACTION_TESTPAGE (4) + /// 0x4. Print a test page on the printer specified by . The parameter is ignored. + /// PRINTACTION_OPENNETPRN (5) + /// 0x5. Open the network printer specified by . The parameter is ignored. + /// PRINTACTION_DOCUMENTDEFAULTS (6) + /// 0x6. Display the default document properties for the printer specified by . The parameter is ignored. + /// PRINTACTION_SERVERPROPERTIES (7) + /// 0x7. Display the properties for the printer server specified by . The parameter is ignored. + /// + /// + /// Type: LPCTSTR + /// + /// Pointer to a null-terminated string that contains additional information for the printer command. The information contained in + /// this parameter depends upon the value of . + /// + /// + /// + /// Type: LPCTSTR + /// + /// Pointer to a null-terminated string that contains additional information for the printer command. The information contained in + /// this parameter depends upon the value of . + /// + /// + /// + /// Type: BOOL + /// + /// TRUE to specify that SHInvokePrinterCommand should not return until the command is completed; FALSE if the + /// function should return as soon as the command is initialized. + /// + /// + /// + /// Type: BOOL + /// Returns TRUE if successful; otherwise, FALSE. + /// + /// + /// + /// When a printer name is specified by , the name can either be the name of a local printer or the server and share name of a + /// network printer. When specifying a network printer name, the name must be specified in this format: + /// + /// This function is implemented in + /// Shell versions 4.71 + /// + /// and later. In order to maintain backward compatibility with previous Shell versions, this function should not be used explicitly. + /// Instead, the + /// + /// LoadLibrary + /// and + /// GetProcAddress + /// functions should be used to obtain the function address. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shinvokeprintercommanda BOOL SHInvokePrinterCommandA( + // HWND hwnd, UINT uAction, LPCSTR lpBuf1, LPCSTR lpBuf2, BOOL fModal ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shellapi.h", MSDNShortId = "32a5802f-cef7-4dbd-affd-82285fe97a8c")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHInvokePrinterCommand(HandleRef hwnd, PRINTACTION uAction, string lpBuf1, string lpBuf2, [MarshalAs(UnmanagedType.Bool)] bool fModal); + + /// + /// + /// Determines whether a file or folder is available for offline use. This function also determines whether the file would be opened + /// from the network, from the local Offline Files cache, or from both locations. + /// + /// + /// + /// TBD + /// + /// + /// Type: LPDWORD + /// A pointer to a variable of type DWORD that receives one or more of the following flags if the function succeeds. + /// OFFLINE_STATUS_LOCAL (0x01) + /// If the file is open, it is open in the cache. + /// OFFLINE_STATUS_REMOTE (0x02) + /// If the file is open, it is open on the server. + /// OFFLINE_STATUS_INCOMPLETE (0x04) + /// The local copy is currently incomplete. The file cannot be opened in offline mode until it has been synchronized. + /// + /// + /// Type: HRESULT + /// This function can return one of these values. + /// + /// + /// Return code + /// Description + /// + /// + /// S_OK + /// The file or directory is cached. It is available offline unless OFFLINE_STATUS_INCOMPLETE is set. + /// + /// + /// E_INVALIDARG + /// The path is invalid or not a network path. The file or directory is not cached. + /// + /// + /// E_FAIL + /// The file or directory is not cached. + /// + /// + /// + /// + /// If is a directory, SHIsFileAvailableOffline will not return the OFFLINE_STATUS_INCOMPLETE flag. + /// + /// If SHIsFileAvailableOffline returns both OFFLINE_STATUS_LOCAL and OFFLINE_STATUS_REMOTE, the file or + /// directory is open in both places. This is common when the server is online. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shisfileavailableoffline SHSTDAPI + // SHIsFileAvailableOffline( PCWSTR pwszPath, DWORD *pdwStatus ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "9acf212d-9309-42b0-ba96-faa0ecf0b865")] + public static extern HRESULT SHIsFileAvailableOffline([MarshalAs(UnmanagedType.LPWStr)] string pwszPath, out OFFLINE_STATUS pdwStatus); + + /// + /// + /// Signals the Shell that during the next operation requiring overlay information, it should load icon overlay identifiers that + /// either failed creation or were not present for creation at startup. Identifiers that have already been loaded are not affected. + /// + /// + /// + /// Type: HRESULT + /// Always returns S_OK. + /// + /// + /// + /// A call to SHLoadNonloadedIconOverlayIdentifiers does not result in the immediate loading of a Shell extension, nor does it + /// cause an icon overlay handler to be loaded. A call to SHLoadNonloadedIconOverlayIdentifiers results in a situation such + /// that the next code to ask for icon overlay information triggers a comparison of icon overlays in the registry to those that are + /// already loaded. If an icon overlay is newly registered and the system has not already reached its upper limit of fifteen icon + /// overlays, the new overlay is loaded. SHLoadNonloadedIconOverlayIdentifiers alone does not load a new icon overlay; you + /// also need to trigger an action that uses the overlay, such as a refresh of a Windows Explorer view. + /// + /// For more information, see How to Implement Icon Overlay Handlers. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shloadnonloadediconoverlayidentifiers SHSTDAPI + // SHLoadNonloadedIconOverlayIdentifiers( ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shellapi.h", MSDNShortId = "d2c4f37e-6e9d-4536-90ea-d69461c4105a")] + public static extern HRESULT SHLoadNonloadedIconOverlayIdentifiers(); + /// /// Contains information about a system appbar message. /// @@ -1027,6 +2884,7 @@ namespace Vanara.PInvoke /// The size of the structure, in bytes. /// public uint cbSize; + /// /// Type: HWND /// @@ -1035,6 +2893,7 @@ namespace Vanara.PInvoke /// /// public IntPtr hWnd; + /// /// Type: LPARAM /// A message-dependent value. This member is used with these messages: @@ -1068,6 +2927,7 @@ namespace Vanara.PInvoke /// /// public uint uCallbackMessage; + /// /// Type: UINT /// A value that specifies an edge of the screen. This member is used when sending one of these messages: @@ -1099,116 +2959,417 @@ namespace Vanara.PInvoke /// Where to obtain association data and the form the data is stored in. One of the following values from the ASSOCCLASS enumeration. /// public ASSOCCLASS ac; + /// A registry key that specifies a class that contains association information. public IntPtr hkClass; + /// A pointer to the name of a class that contains association information. public string pszClass; } + /// - /// Contains information used by ShellExecuteEx. + /// Contains information that the system needs to display notifications in the notification area. Used by Shell_NotifyIcon. /// - [StructLayout(LayoutKind.Sequential)] - [PInvokeData("Shellapi.h", MSDNShortId = "bb759784")] - public struct SHELLEXECUTEINFO + /// + /// + /// See Notifications in the Windows User Experience Interaction Guidelines for more information on notification UI and content best practices. + /// + /// + /// If you set the NIF_INFO flag in the uFlags member, the balloon-style notification is used. For more discussion of + /// these notifications, see Balloon tooltips. + /// + /// + /// No more than one balloon notification at a time can be displayed for the taskbar. If an application attempts to display a + /// notification when one is already being displayed, the new notification is queued and displayed when the older notification goes + /// away. In versions of Windows before Windows Vista, the new notification would not appear until the existing notification has been + /// visible for at least the system minimum timeout length, regardless of the original notification's uTimeout value. If the + /// user does not appear to be using the computer, the system does not count this time toward the timeout. + /// + /// + /// Several members of this structure are only supported for Windows 2000 and later. To enable these members, include one of the + /// following lines in your header: + /// + /// + /// Note that you must initialize the structure with its size. If you use the size of the currently defined structure, the + /// application might not run with earlier versions of Shell32.dll, which expect a smaller structure. You can run your application + /// against earlier versions of Shell32.dll by defining the appropriate version number (see + /// + /// Shell and Common Controls Versions + /// ). However, this might cause problems if your application also needs to run on more recent systems. + /// + /// You can maintain application compatibility with all Shell32.dll versions while still using the current header files by setting + /// the size of the NOTIFYICONDATA structure appropriately. Before you initialize the structure, use DllGetVersion to + /// determine which Shell32.dll version is installed on the system and initialize cbSize with one of these values: + /// + /// + /// + /// Shell32.dll Version + /// cbSize + /// + /// + /// 6.0.6 or higher (Windows Vista and later) + /// sizeof(NOTIFYICONDATA) + /// + /// + /// 6.0 (Windows XP) + /// NOTIFYICONDATA_V3_SIZE + /// + /// + /// 5.0 (Windows 2000) + /// NOTIFYICONDATA_V2_SIZE + /// + /// + /// Versions lower than 5.0 + /// NOTIFYICONDATA_V1_SIZE + /// + /// + /// + /// Using this value for cbSize allows your application to use NOTIFYICONDATA in a method compatible with earlier + /// Shell32.dll versions. + /// + /// + /// The following code example shows version checking that can enable an application that uses the guidItem member to run on + /// both Windows Vista and Windows 7. It provides a Boolean function that returns TRUE if the operating system is Windows 7. + /// Unless this member returns TRUE, the guidItem member must be set to 0. + /// + /// + /// Note This code is specific to the Windows 7 version number. It is expected that future versions of Windows and Windows + /// Server will support the guidItem member, and at that time this code must be updated to identify later version numbers as + /// valid as well. + /// + /// The following code example shows the use of + /// LoadIconMetric + /// to load an icon for use with high DPI. + /// Troubleshooting + /// If you are using the + /// guidItem + /// member to identify the icon, and that icon is not seen or some calls to + /// Shell_NotifyIcon + /// fail, one of the following cases is the likely cause: + /// + /// + /// The NIF_GUID flag was not set in every call to Shell_NotifyIcon. Once you identify the notification icon with a GUID in one call + /// to Shell_NotifyIcon, you must use that same GUID to identify the icon in any subsequent Shell_NotifyIcon calls that + /// deal with that same icon. + /// + /// + /// The binary file that contains the icon was moved. The path of the binary file is included in the registration of the icon's GUID + /// and cannot be changed. Settings associated with the icon are preserved through an upgrade only if the file path and GUID are + /// unchanged. If the path must be changed, the application should remove any GUID information that was added when the existing icon + /// was registered. Once that information is removed, you can move the binary file to a new location and reregister it with a new + /// GUID. Any settings associated with the original GUID registration will be lost. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_notifyicondataa typedef struct _NOTIFYICONDATAA { DWORD + // cbSize; HWND hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; HICON hIcon; CHAR szTip[64]; CHAR szTip[128]; DWORD dwState; + // DWORD dwStateMask; CHAR szInfo[256]; union { UINT uTimeout; UINT uVersion; } DUMMYUNIONNAME; CHAR szInfoTitle[64]; DWORD + // dwInfoFlags; GUID guidItem; HICON hBalloonIcon; } NOTIFYICONDATAA, *PNOTIFYICONDATAA; + [PInvokeData("shellapi.h", MSDNShortId = "fdcc42c1-b3e5-4b04-8d79-7b6c29699d53")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct NOTIFYICONDATA { - /// - /// Required. The size of this structure, in bytes. - /// - public int cbSize; + /// Size of this structure, in bytes. + public uint cbSize; /// - /// Flags that indicate the content and validity of the other structure members. - /// - public ShellExecuteMaskFlags fMask; - - /// - /// Optional. A handle to the parent window, used to display any message boxes that the system might produce while executing this function. This value can be NULL. + /// Handle to the window that receives notification messages associated with an icon in the taskbar status area. The Shell uses + /// hWnd and uID to identify which icon to operate on when Shell_NotifyIcon is invoked. /// public IntPtr hwnd; /// - /// A string, referred to as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. This parameter can be NULL, in which case the default verb is used if available. If not, the "open" verb is used. If neither verb is available, the system uses the first verb listed in the registry. The following verbs are commonly used: + /// Application-defined identifier of the taskbar icon. The Shell uses hWnd and uID to identify which icon to operate on when + /// Shell_NotifyIcon is invoked. You can have multiple icons associated with a single hWnd by assigning each a different uID. + /// + public uint uID; + + /// + /// Flags that indicate which of the other members contain valid data. This member can be a combination of the NIF_XXX constants. + /// + public NIF uFlags; + + /// + /// Application-defined message identifier. The system uses this identifier to send notifications to the window identified in hWnd. + /// + public uint uCallbackMessage; + + /// Handle to the icon to be added, modified, or deleted. + public IntPtr hIcon; + + /// + /// String with the text for a standard ToolTip. It can have a maximum of 64 characters including the terminating NULL. For + /// Version 5.0 and later, szTip can have a maximum of 128 characters, including the terminating NULL. + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + public string szTip; + + /// State of the icon. + public NIS dwState; + + /// + /// A value that specifies which bits of the state member are retrieved or modified. For example, setting this member to + /// NIS_HIDDEN causes only the item's hidden state to be retrieved. + /// + public NIS dwStateMask; + + /// + /// String with the text for a balloon ToolTip. It can have a maximum of 255 characters. To remove the ToolTip, set the NIF_INFO + /// flag in uFlags and set szInfo to an empty string. + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + public string szInfo; + + /// + /// NOTE: This field is also used for the Timeout value. Specifies whether the Shell notify icon interface should use Windows 95 + /// or Windows 2000 behavior. For more information on the differences in these two behaviors, see Shell_NotifyIcon. This member + /// is only employed when using Shell_NotifyIcon to send an NIM_VERSION message. + /// + public int uTimeoutOrVersion; + + /// + /// String containing a title for a balloon ToolTip. This title appears in boldface above the text. It can have a maximum of 63 characters. + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] + public string szInfoTitle; + + /// + /// Adds an icon to a balloon ToolTip. It is placed to the left of the title. If the szTitleInfo member is zero-length, the icon + /// is not shown. See RMUtils.WinAPI.Structs.BalloonIconStyle for more information. + /// + public NIIF dwInfoFlags; + + /// + /// + /// Windows 7 and later: A registered GUID that identifies the icon.This value overrides uID and is the recommended method of + /// identifying the icon.The NIF_GUID flag must be set in the uFlags member. + /// + /// Windows XP and Windows Vista: Reserved; must be set to 0. + /// + /// If your application is intended to run on both Windows Vista and Windows 7, it is imperative that you check the version of + /// Windows and only specify a nonzero guidItem if on Windows 7 or later. + /// + /// + /// If you identify the notification icon with a GUID in one call to Shell_NotifyIcon, you must use that same GUID to identify + /// the icon in any subsequent Shell_NotifyIcon calls that deal with that same icon. + /// + /// To generate a GUID for use in this member, use a GUID-generating tool such as Guidgen.exe. + /// + public Guid guidItem; + + /// + /// Windows Vista and later. The handle of a customized notification icon provided by the application that should be used + /// independently of the notification area icon. If this member is non-NULL and the NIIF_USER flag is set in the dwInfoFlags + /// member, this icon is used as the notification icon. If this member is NULL, the legacy behavior is carried out. + /// + public IntPtr hBalloonIcon; + } + + /// + /// Contains information used by Shell_NotifyIconGetRect to identify the icon for which to retrieve the bounding rectangle. + /// + /// + /// The icon can be identified to Shell_NotifyIconGetRect through this structure in two ways: + /// + /// + /// guidItem alone (recommended) + /// + /// + /// hWnd plus uID + /// + /// + /// If guidItem is not GUID_NULL, hWnd and uID are ignored. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_notifyiconidentifier typedef struct + // _NOTIFYICONIDENTIFIER { DWORD cbSize; HWND hWnd; UINT uID; GUID guidItem; } NOTIFYICONIDENTIFIER, *PNOTIFYICONIDENTIFIER; + [PInvokeData("shellapi.h", MSDNShortId = "2fe4ffba-6fe5-4d34-9cb1-f266e4594b8e")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct NOTIFYICONIDENTIFIER + { + /// + /// Type: DWORD + /// The size of this structure, in bytes. + /// + public uint cbSize; + + /// + /// Type: HWND + /// + /// A handle to the parent window used by the notification's callback function. For more information, see the member of the + /// NOTIFYICONDATA structure. + /// + /// + public IntPtr hWnd; + + /// + /// Type: UINT + /// + /// The application-defined identifier of the notification icon. Multiple icons can be associated with a single , each with their + /// own . + /// + /// + public uint uID; + + /// + /// Type: GUID + /// A registered GUID that identifies the icon. Use GUID_NULL if the icon is not identified by a GUID. + /// + public Guid guidItem; + } + + /// Contains information used by ShellExecuteEx. + [StructLayout(LayoutKind.Sequential)] + [PInvokeData("Shellapi.h", MSDNShortId = "bb759784")] + public struct SHELLEXECUTEINFO + { + /// Required. The size of this structure, in bytes. + public int cbSize; + + /// Flags that indicate the content and validity of the other structure members. + public ShellExecuteMaskFlags fMask; + + /// + /// Optional. A handle to the parent window, used to display any message boxes that the system might produce while executing this + /// function. This value can be NULL. + /// + public IntPtr hwnd; + + /// + /// A string, referred to as a verb, that specifies the action to be performed. The set of available verbs depends on the + /// particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. This + /// parameter can be NULL, in which case the default verb is used if available. If not, the "open" verb is used. If neither verb + /// is available, the system uses the first verb listed in the registry. The following verbs are commonly used: /// - /// editLaunches an editor and opens the document for editing.If lpFile is not a document file, the function will fail. - /// exploreExplores the folder specified by lpFile. - /// findInitiates a search starting from the specified directory. - /// openOpens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder. - /// printPrints the document file specified by lpFile.If lpFile is not a document file, the function will fail. - /// propertiesDisplays the file or folder's properties. + /// + /// edit + /// Launches an editor and opens the document for editing.If lpFile is not a document file, the function will fail. + /// + /// + /// explore + /// Explores the folder specified by lpFile. + /// + /// + /// find + /// Initiates a search starting from the specified directory. + /// + /// + /// open + /// Opens the file specified by the lpFile parameter. The file can be an executable file, a document file, or a folder. + /// + /// + /// print + /// Prints the document file specified by lpFile.If lpFile is not a document file, the function will fail. + /// + /// + /// properties + /// Displays the file or folder's properties. + /// /// /// [MarshalAs(UnmanagedType.LPTStr)] public string lpVerb; /// - /// The address of a null-terminated string that specifies the name of the file or object on which ShellExecuteEx will perform the action specified by the lpVerb parameter. The system registry verbs that are supported by the ShellExecuteEx function include "open" for executable files and document files and "print" for document files for which a print handler has been registered. Other applications might have added Shell verbs through the system registry, such as "play" for .avi and .wav files. To specify a Shell namespace object, pass the fully qualified parse name and set the SEE_MASK_INVOKEIDLIST flag in the fMask parameter. - /// If the SEE_MASK_INVOKEIDLIST flag is set, you can use either lpFile or lpIDList to identify the item by its file system path or its PIDL respectively. One of the two values—lpFile or lpIDList—must be set. - /// If the path is not included with the name, the current directory is assumed. + /// The address of a null-terminated string that specifies the name of the file or object on which ShellExecuteEx will perform + /// the action specified by the lpVerb parameter. The system registry verbs that are supported by the ShellExecuteEx function + /// include "open" for executable files and document files and "print" for document files for which a print handler has been + /// registered. Other applications might have added Shell verbs through the system registry, such as "play" for .avi and .wav + /// files. To specify a Shell namespace object, pass the fully qualified parse name and set the SEE_MASK_INVOKEIDLIST flag in the + /// fMask parameter. If the SEE_MASK_INVOKEIDLIST flag is set, you can use either lpFile or lpIDList to identify the item + /// by its file system path or its PIDL respectively. One of the two values—lpFile or lpIDList—must be set.If the + /// path is not included with the name, the current directory is assumed. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpFile; /// - /// Optional. The address of a null-terminated string that contains the application parameters. The parameters must be separated by spaces. If the lpFile member specifies a document file, lpParameters should be NULL. + /// Optional. The address of a null-terminated string that contains the application parameters. The parameters must be separated + /// by spaces. If the lpFile member specifies a document file, lpParameters should be NULL. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpParameters; /// - /// Optional. The address of a null-terminated string that specifies the name of the working directory. If this member is NULL, the current directory is used as the working directory. + /// Optional. The address of a null-terminated string that specifies the name of the working directory. If this member is NULL, + /// the current directory is used as the working directory. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpDirectory; /// - /// Required. Flags that specify how an application is to be shown when it is opened; one of the SW_ values listed for the ShellExecute function. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up to the application to decide how to handle it. + /// Required. Flags that specify how an application is to be shown when it is opened; one of the SW_ values listed for the + /// ShellExecute function. If lpFile specifies a document file, the flag is simply passed to the associated application. It is up + /// to the application to decide how to handle it. /// public ShowWindowCommand nShellExecuteShow; /// - /// [out] If SEE_MASK_NOCLOSEPROCESS is set and the ShellExecuteEx call succeeds, it sets this member to a value greater than 32. If the function fails, it is set to an SE_ERR_XXX error value that indicates the cause of the failure. Although hInstApp is declared as an HINSTANCE for compatibility with 16-bit Windows applications, it is not a true HINSTANCE. It can be cast only to an int and compared to either 32 or the following SE_ERR_XXX error codes. + /// [out] If SEE_MASK_NOCLOSEPROCESS is set and the ShellExecuteEx call succeeds, it sets this member to a value greater than 32. + /// If the function fails, it is set to an SE_ERR_XXX error value that indicates the cause of the failure. Although hInstApp is + /// declared as an HINSTANCE for compatibility with 16-bit Windows applications, it is not a true HINSTANCE. It can be cast only + /// to an int and compared to either 32 or the following SE_ERR_XXX error codes. /// public IntPtr hInstApp; /// - /// The address of an absolute ITEMIDLIST structure (PCIDLIST_ABSOLUTE) to contain an item identifier list that uniquely identifies the file to execute. This member is ignored if the fMask member does not include SEE_MASK_IDLIST or SEE_MASK_INVOKEIDLIST. + /// The address of an absolute ITEMIDLIST structure (PCIDLIST_ABSOLUTE) to contain an item identifier list that uniquely + /// identifies the file to execute. This member is ignored if the fMask member does not include SEE_MASK_IDLIST or SEE_MASK_INVOKEIDLIST. /// public IntPtr lpIDList; /// /// The address of a null-terminated string that specifies one of the following: /// - /// A ProgId. For example, "Paint.Picture". - /// A URI protocol scheme. For example, "http". - /// A file extension. For example, ".txt". - /// A registry path under HKEY_CLASSES_ROOT that names a subkey that contains one or more Shell verbs. This key will have a subkey that conforms to the Shell verb registry schema, such as shell\verb name. + /// + /// A ProgId. For example, "Paint.Picture". + /// + /// + /// A URI protocol scheme. For example, "http". + /// + /// + /// A file extension. For example, ".txt". + /// + /// + /// + /// A registry path under HKEY_CLASSES_ROOT that names a subkey that contains one or more Shell verbs. This key will have a + /// subkey that conforms to the Shell verb registry schema, such as shell\verb name. + /// + /// /// /// This member is ignored if fMask does not include SEE_MASK_CLASSNAME. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpClass; /// - /// A handle to the registry key for the file type. The access rights for this registry key should be set to KEY_READ. This member is ignored if fMask does not include SEE_MASK_CLASSKEY. + /// A handle to the registry key for the file type. The access rights for this registry key should be set to KEY_READ. This + /// member is ignored if fMask does not include SEE_MASK_CLASSKEY. /// public IntPtr hkeyClass; /// - /// A keyboard shortcut to associate with the application. The low-order word is the virtual key code, and the high-order word is a modifier flag (HOTKEYF_). For a list of modifier flags, see the description of the WM_SETHOTKEY message. This member is ignored if fMask does not include SEE_MASK_HOTKEY. + /// A keyboard shortcut to associate with the application. The low-order word is the virtual key code, and the high-order word is + /// a modifier flag (HOTKEYF_). For a list of modifier flags, see the description of the WM_SETHOTKEY message. This member is + /// ignored if fMask does not include SEE_MASK_HOTKEY. /// public uint dwHotKey; /// - /// A handle to the icon for the file type. This member is ignored if fMask does not include SEE_MASK_ICON. This value is used only in Windows XP and earlier. It is ignored as of Windows Vista. + /// A handle to the icon for the file type. This member is ignored if fMask does not include SEE_MASK_ICON. This value is used + /// only in Windows XP and earlier. It is ignored as of Windows Vista. /// OR - /// A handle to the monitor upon which the document is to be displayed. This member is ignored if fMask does not include SEE_MASK_HMONITOR. + /// + /// A handle to the monitor upon which the document is to be displayed. This member is ignored if fMask does not include SEE_MASK_HMONITOR. + /// /// public IntPtr hIcon; /// - /// A handle to the newly started application. This member is set on return and is always NULL unless fMask is set to SEE_MASK_NOCLOSEPROCESS. Even if fMask is set to SEE_MASK_NOCLOSEPROCESS, hProcess will be NULL if no process was launched. For example, if a document to be launched is a URL and an instance of Internet Explorer is already running, it will display the document. No new process is launched, and hProcess will be NULL. - /// ShellExecuteEx does not always return an hProcess, even if a process is launched as the result of the call. For example, an hProcess does not return when you use SEE_MASK_INVOKEIDLIST to invoke IContextMenu. + /// A handle to the newly started application. This member is set on return and is always NULL unless fMask is set to + /// SEE_MASK_NOCLOSEPROCESS. Even if fMask is set to SEE_MASK_NOCLOSEPROCESS, hProcess will be NULL if no process was launched. + /// For example, if a document to be launched is a URL and an instance of Internet Explorer is already running, it will display + /// the document. No new process is launched, and hProcess will be NULL. ShellExecuteEx does not always return an hProcess, + /// even if a process is launched as the result of the call. For example, an hProcess does not return when you use + /// SEE_MASK_INVOKEIDLIST to invoke IContextMenu. /// public IntPtr hProcess; - /// - /// Initializes a new instance of the struct. - /// + /// Initializes a new instance of the struct. /// Name of the file. /// The parameters. public SHELLEXECUTEINFO(string fileName, string parameters = null) : this() @@ -1226,7 +3387,8 @@ namespace Vanara.PInvoke public struct SHFILEINFO { /// - /// A handle to the icon that represents the file. You are responsible for destroying this handle with DestroyIcon when you no longer need it. + /// A handle to the icon that represents the file. You are responsible for destroying this handle with DestroyIcon when you no + /// longer need it. /// public IntPtr hIcon; @@ -1234,13 +3396,14 @@ namespace Vanara.PInvoke public int iIcon; /// - /// An array of values that indicates the attributes of the file object. For information about these values, see the IShellFolder::GetAttributesOf method. + /// An array of values that indicates the attributes of the file object. For information about these values, see the + /// IShellFolder::GetAttributesOf method. /// public int dwAttributes; /// - /// A string that contains the name of the file as it appears in the Windows Shell, or the path and file name of the file that contains the icon - /// representing the file. + /// A string that contains the name of the file as it appears in the Windows Shell, or the path and file name of the file that + /// contains the icon representing the file. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; @@ -1259,36 +3422,136 @@ namespace Vanara.PInvoke { /// A window handle to the dialog box to display information about the status of the file operation. public IntPtr hwnd; + /// A value that indicates which operation to perform. public ShellFileOperation wFunc; - /// This string must be double-null terminated. + + /// + /// This string must be double-null terminated. /// A pointer to one or more source file names.These names should be fully qualified paths to prevent unexpected results. - /// Standard MS-DOS wildcard characters, such as "*", are permitted only in the file-name position.Using a wildcard character elsewhere in the string will lead to unpredictable results. - /// Although this member is declared as a single null-terminated string, it is actually a buffer that can hold multiple null-delimited file names.Each file name is terminated by a single NULL character. The last file name is terminated with a double NULL character ("\0\0") to indicate the end of the buffer. + /// + /// Standard MS-DOS wildcard characters, such as "*", are permitted only in the file-name position.Using a wildcard character + /// elsewhere in the string will lead to unpredictable results. + /// + /// + /// Although this member is declared as a single null-terminated string, it is actually a buffer that can hold multiple + /// null-delimited file names.Each file name is terminated by a single NULL character. The last file name is terminated with a + /// double NULL character ("\0\0") to indicate the end of the buffer. + /// + /// [MarshalAs(UnmanagedType.LPTStr)] public string pFrom; - /// This string must be double-null terminated. - /// A pointer to the destination file or directory name. This parameter must be set to NULL if it is not used. Wildcard characters are not allowed. Their use will lead to unpredictable results. - /// Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must meet the following specifications: + + /// + /// This string must be double-null terminated. + /// + /// A pointer to the destination file or directory name. This parameter must be set to NULL if it is not used. Wildcard + /// characters are not allowed. Their use will lead to unpredictable results. + /// + /// + /// Like pFrom, the pTo member is also a double-null terminated string and is handled in much the same way. However, pTo must + /// meet the following specifications: + /// /// - /// Wildcard characters are not supported. - /// Copy and Move operations can specify destination directories that do not exist. In those cases, the system attempts to create them and normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags. - /// For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES. - /// Pack multiple names into the pTo string in the same way as for pFrom. - /// Use fully qualified paths. Using relative paths is not prohibited, but can have unpredictable results. - /// + /// + /// Wildcard characters are not supported. + /// + /// + /// + /// Copy and Move operations can specify destination directories that do not exist. In those cases, the system attempts to create + /// them and normally displays a dialog box to ask the user if they want to create the new directory. To suppress this dialog box + /// and have the directories created silently, set the FOF_NOCONFIRMMKDIR flag in fFlags. + /// + /// + /// + /// + /// For Copy and Move operations, the buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES. + /// + /// + /// + /// Pack multiple names into the pTo string in the same way as for pFrom. + /// + /// + /// Use fully qualified paths. Using relative paths is not prohibited, but can have unpredictable results. + /// + /// + /// [MarshalAs(UnmanagedType.LPTStr)] public string pTo; + /// Flags that control the file operation. public FILEOP_FLAGS fFlags; - /// When the function returns, this member contains TRUE if any file operations were aborted before they were completed; otherwise, FALSE. An operation can be manually aborted by the user through UI or it can be silently aborted by the system if the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set. + + /// + /// When the function returns, this member contains TRUE if any file operations were aborted before they were completed; + /// otherwise, FALSE. An operation can be manually aborted by the user through UI or it can be silently aborted by the system if + /// the FOF_NOERRORUI or FOF_NOCONFIRMATION flags were set. + /// [MarshalAs(UnmanagedType.Bool)] public bool fAnyOperationsAborted; - /// When the function returns, this member contains a handle to a name mapping object that contains the old and new names of the renamed files. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. See Remarks for more details. + + /// + /// When the function returns, this member contains a handle to a name mapping object that contains the old and new names of the + /// renamed files. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. See Remarks for more details. + /// public IntPtr hNameMappings; - /// A pointer to the title of a progress dialog box. This is a null-terminated string. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag. + + /// + /// A pointer to the title of a progress dialog box. This is a null-terminated string. This member is used only if fFlags + /// includes the FOF_SIMPLEPROGRESS flag. + /// [MarshalAs(UnmanagedType.LPTStr)] public string lpszProgressTitle; } + + /// + /// Receives information used to retrieve a stock Shell icon. This structure is used in a call SHGetStockIconInfo. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_shstockiconinfo typedef struct _SHSTOCKICONINFO { DWORD + // cbSize; HICON hIcon; int iSysImageIndex; int iIcon; WCHAR szPath[MAX_PATH]; } SHSTOCKICONINFO; + [PInvokeData("shellapi.h", MSDNShortId = "4d32826a-bb40-4805-9826-801c142b8d28")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct SHSTOCKICONINFO + { + /// + /// Type: DWORD + /// The size of this structure, in bytes. + /// + public uint cbSize; + + /// + /// Type: HICON + /// When SHGetStockIconInfo is called with the SHGSI_ICON flag, this member receives a handle to the icon. + /// + public IntPtr hIcon; + + /// + /// Type: int + /// + /// When SHGetStockIconInfo is called with the SHGSI_SYSICONINDEX flag, this member receives the index of the image in the system + /// icon cache. + /// + /// + public int iSysImageIndex; + + /// + /// Type: int + /// + /// When SHGetStockIconInfo is called with the SHGSI_ICONLOCATION flag, this member receives the index of the icon in the + /// resource whose path is received in szPath. + /// + /// + public int iIcon; + + /// + /// Type: WCHAR[MAX_PATH] + /// + /// When SHGetStockIconInfo is called with the SHGSI_ICONLOCATION flag, this member receives the path of the resource that + /// contains the icon. The index of the icon within the resource is received in iIcon. + /// + /// + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)] + public string szPath; + } } } \ No newline at end of file diff --git a/PInvoke/Shell32/ShlObj.cs b/PInvoke/Shell32/ShlObj.cs index 4bb8e956..958e5724 100644 --- a/PInvoke/Shell32/ShlObj.cs +++ b/PInvoke/Shell32/ShlObj.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices.ComTypes; using System.Security; using System.Text; using Vanara.InteropServices; +using static Vanara.Extensions.BitHelper; using static Vanara.PInvoke.AdvApi32; using static Vanara.PInvoke.ComCtl32; using static Vanara.PInvoke.Kernel32; @@ -26,16 +27,175 @@ namespace Vanara.PInvoke // Defined in wingdi.h private const int LF_FACESIZE = 32; + /// + /// + /// [This interface is supported through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be unsupported in + /// subsequent versions of Windows.] + /// + /// + /// Defines the prototype for the callback function used by the system folder view object. This function essentially duplicates the + /// functionality of IShellFolderViewCB. + /// + /// + /// + /// Type: IShellView* + /// A pointer to the owning instance of IShellView, if applicable. This parameter can be NULL. + /// + /// + /// Type: IShellFolder* + /// A pointer to the instance of IShellFolder the message applies to. + /// + /// + /// Type: HWND + /// The handle of the window that contains the view that receives the message. + /// + /// + /// Type: UINT + /// One of the following notifications. + /// + /// + /// Type: WPARAM + /// Additional information dependent on the value in uMsg. See the individual notification pages for specific requirements. + /// + /// + /// Type: LPARAM + /// Additional information dependent on the value in uMsg. See the individual notification pages for specific requirements. + /// + /// + /// Type: HRESULT + /// If this function pointer succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // typedef HRESULT ( CALLBACK *LPFNVIEWCALLBACK)( _In_ IShellView *psvOuter, _In_ IShellFolder *psf, _In_ HWND hwndMain, UINT uMsg, + // WPARAM wParam, LPARAM lParam); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776771(v=vs.85).aspx + [PInvokeData("Shlobj_core.h", MSDNShortId = "bb776771")] + [UnmanagedFunctionPointer(CallingConvention.Winapi)] + public delegate HRESULT LPFNVIEWCALLBACK(IShellView psvOuter, IShellFolder psf, IntPtr hwndMain, uint uMsg, IntPtr wParam, IntPtr lParam); + /// A flag that controls how PifMgr_CloseProperties operates. [PInvokeData("shlobj_core.h", MSDNShortId = "fd50d4f8-87c8-4162-9e88-3c8592b929fa")] public enum CLOSEPROPS { /// No options specified. CLOSEPROPS_NONE = 0x0000, + /// Abandon cached data. CLOSEPROPS_DISCARD = 0x0001 } + /// + /// + /// Represents information about the effects of a drag-and-drop operation. The DoDragDrop function and many of the methods in + /// the IDropSource and IDropTarget use the values of this enumeration. + /// + /// + /// + /// + /// Your application should always mask values from the DROPEFFECT enumeration to ensure compatibility with future + /// implementations. Presently, only some of the positions in a DROPEFFECT value have meaning. In the future, more + /// interpretations for the bits will be added. Drag sources and drop targets should carefully mask these values appropriately before + /// comparing. They should never compare a DROPEFFECT against, say, DROPEFFECT_COPY by doing the following: + /// + /// Instead, the application should always mask for the value or values being sought as using one of the following techniques: + /// This allows for the definition of new drop effects, while preserving backward compatibility with existing code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/com/dropeffect-constants + [PInvokeData("OleIdl.h", MSDNShortId = "d8e46899-3fbf-4012-8dd3-67fa627526d5")] + // public static extern + public enum DROPEFFECT : uint + { + /// Drop target cannot accept the data. + DROPEFFECT_NONE = 0, + + /// Drop results in a copy. The original data is untouched by the drag source. + DROPEFFECT_COPY = 1, + + /// Drag source should remove the data. + DROPEFFECT_MOVE = 2, + + /// Drag source should create a link to the original data. + DROPEFFECT_LINK = 4, + + /// + /// Scrolling is about to start or is currently occurring in the target. This value is used in addition to the other values. + /// + DROPEFFECT_SCROLL = 0x80000000, + } + + /// A flag that controls the action of SHGetSetFolderCustomSettings. + [PInvokeData("shlobj_core.h", MSDNShortId = "38b78a4b-ba68-4dff-812d-d4c7421eb202")] + [Flags] + public enum FCS + { + /// Retrieve the custom folder settings in pfcs. + FCS_READ = 0x00000001, + + /// Use pfcs to set the custom folder's settings regardless of whether the values are already present. + FCS_FORCEWRITE = 0x00000002, + + /// Use pfcs to set the custom folder's settings if the values are not already present. + FCS_WRITE = (FCS_READ | FCS_FORCEWRITE), + } + + /// Flags used by SHFOLDERCUSTOMSETTINGS.dwMask. + [PInvokeData("shlobj_core.h", MSDNShortId = "a6357372-80ef-4719-b53f-87eb3fdc1b0d")] + [Flags] + public enum FOLDERCUSTOMSETTINGSMASK : uint + { + /// Deprecated. pvid contains the folder's GUID. + FCSM_VIEWID = 0x0001, + + /// Deprecated. pszWebViewTemplate contains a pointer to a buffer containing the path to the folder's WebView template. + FCSM_WEBVIEWTEMPLATE = 0x0002, + + /// pszInfoTip contains a pointer to a buffer containing the folder's info tip. + FCSM_INFOTIP = 0x0004, + + /// pclsid contains the folder's CLSID. + FCSM_CLSID = 0x0008, + + /// pszIconFile contains the path to the file containing the folder's icon. + FCSM_ICONFILE = 0x0010, + + /// pszLogo contains the path to the file containing the folder's thumbnail icon. + FCSM_LOGO = 0x0020, + + /// Not used. + FCSM_FLAGS = 0x0040, + } + + /// Flags used by SHGetPathFromIDListEx. + [PInvokeData("shlobj_core.h", MSDNShortId = "80270c59-275d-4b13-b16c-0c07bb79ed8e")] + [Flags] + public enum GPFIDL_FLAGS + { + /// Win32 file names, servers, and root drives are included. + GPFIDL_DEFAULT = 0x0000, + + /// Uses short file names. + GPFIDL_ALTNAME = 0x0001, + + /// Include UNC printer names items. + GPFIDL_UNCPRINTER = 0x0002, + } + + /// Flags used by Shell_MergeMenus. + [PInvokeData("shlobj_core.h", MSDNShortId = "f9e005fd-b1f2-4a5f-ad36-9c44998dc4eb")] + [Flags] + public enum MM + { + /// + /// Add a separator between the items from the two menus if one does not exist already. If you are inserting the entries from + /// hmSrc into the middle of hmDst, a separator is added above and below the hmSrc material. + /// + MM_ADDSEPARATOR = 0x00000001, + + /// Do not remove any existing separators in the two menus. Note that this could result in two separators in a row. + MM_SUBMENUSHAVEIDS = 0x00000002, + + /// Set this flag if the submenus have IDs which should be adjusted. + MM_DONTREMOVESEPS = 0x00000004, + } + /// Used for options in SHOpenFolderAndSelectItems. [PInvokeData("Shlobj.h", MSDNShortId = "bb762232")] public enum OFASI : uint @@ -44,14 +204,14 @@ namespace Vanara.PInvoke OFASI_NONE = 0, /// - /// Select an item and put its name in edit mode. This flag can only be used when a single item is being selected. For multiple item selections, it - /// is ignored. + /// Select an item and put its name in edit mode. This flag can only be used when a single item is being selected. For multiple + /// item selections, it is ignored. /// OFASI_EDIT = 1, /// - /// Select the item or items on the desktop rather than in a Windows Explorer window. Note that if the desktop is obscured behind open windows, it - /// will not be made visible. + /// Select the item or items on the desktop rather than in a Windows Explorer window. Note that if the desktop is obscured behind + /// open windows, it will not be made visible. /// OFASI_OPENDESKTOP = 2 } @@ -62,6 +222,7 @@ namespace Vanara.PInvoke { /// No options specified. OPENPROPS_NONE = 0x0000, + /// /// Ignore any existing .pif files and get the properties from win.ini or _Default.pif. This flag is ignored on Windows NT, /// Windows 2000, and Windows XP. @@ -76,15 +237,19 @@ namespace Vanara.PInvoke { /// The cleaned path is not a valid file name. This flag is always returned in conjunction with PCS_PATHTOOLONG. PCS_FATAL = 0x80000000, + /// Replaced one or more invalid characters. PCS_REPLACEDCHAR = 0x00000001, + /// Removed one or more invalid characters. PCS_REMOVEDCHAR = 0x00000002, + /// The returned path is truncated. PCS_TRUNCATED = 0x00000004, + /// - /// The function failed because the input path specified at is too long to allow the formation of a valid file name from . When this - /// flag is returned, it is always accompanied by the PCS_FATAL flag. + /// The function failed because the input path specified at is too long to allow the formation of a valid file name from . When + /// this flag is returned, it is always accompanied by the PCS_FATAL flag. /// PCS_PATHTOOLONG = 0x00000008, } @@ -96,17 +261,23 @@ namespace Vanara.PInvoke { /// Return TRUE if the file's existence is verified; otherwise FALSE. PRF_VERIFYEXISTS = 0x0001, + /// Look for the specified path with the following extensions appended: .pif, .com, .bat, .cmd, .lnk, and .exe. PRF_TRYPROGRAMEXTENSIONS = 0x0002 | PRF_VERIFYEXISTS, + /// Look first in the directory or directories specified by dirs. PRF_FIRSTDIRDEF = 0x0004, + /// Ignore .lnk files. PRF_DONTFINDLNK = 0x0008, + /// Require an absolute (full) path. PRF_REQUIREABSOLUTE = 0x0010 } - /// Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero (QITIPF_DEFAULT). + /// + /// Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero (QITIPF_DEFAULT). + /// [PInvokeData("Shlobj.h", MSDNShortId = "bb761357")] public enum QITIP { @@ -129,39 +300,43 @@ namespace Vanara.PInvoke QITIPF_SINGLELINE = 0x00000010, } - /// Indicates whether to enable or disable Async Register and Deregister for SHChangeNotifyRegisterThread. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ne-shlobj_core-scnrt_status - // typedef enum SCNRT_STATUS { SCNRT_ENABLE , SCNRT_DISABLE } ; + /// + /// Indicates whether to enable or disable Async Register and Deregister for SHChangeNotifyRegisterThread. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ne-shlobj_core-scnrt_status typedef enum SCNRT_STATUS { + // SCNRT_ENABLE , SCNRT_DISABLE } ; [PInvokeData("shlobj_core.h", MSDNShortId = "31fd993b-d8cb-40cc-9f31-15711dba1b10")] public enum SCNRT_STATUS { /// Enable Async Register and Deregister for SHChangeNotifyRegisterThread. SCNRT_ENABLE, + /// Disable Async Register and Deregister for SHChangeNotifyRegisterThread. SCNRT_DISABLE, } /// - /// Indicates the interpretation of the data passed by SHAddToRecentDocs in its pv parameter to identify the item whose usage statistics are being tracked. + /// Indicates the interpretation of the data passed by SHAddToRecentDocs in its pv parameter to identify the item whose usage + /// statistics are being tracked. /// [PInvokeData("Shlobj.h", MSDNShortId = "dd378453")] public enum SHARD { /// - /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFO structure that pairs an IShellItem that identifies the item with an - /// AppUserModelID that associates it with a particular process or application. + /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFO structure that pairs an IShellItem that identifies + /// the item with an AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFO = 4, /// - /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOIDLIST structure that pairs an absolute PIDL that identifies the item with - /// an AppUserModelID that associates it with a particular process or application. + /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOIDLIST structure that pairs an absolute PIDL that + /// identifies the item with an AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFOIDLIST = 5, /// - /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOLINK structure that pairs an IShellLink that identifies the item with an - /// AppUserModelID that associates it with a particular process or application. + /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOLINK structure that pairs an IShellLink that + /// identifies the item with an AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFOLINK = 7, @@ -174,7 +349,9 @@ namespace Vanara.PInvoke /// The pv parameter points to a null-terminated Unicode string with the path and file name of the object. SHARD_PATHW = 3, - /// The pv parameter points to a PIDL that identifies the document's file object. PIDLs that identify non-file objects are not accepted. + /// + /// The pv parameter points to a PIDL that identifies the document's file object. PIDLs that identify non-file objects are not accepted. + /// SHARD_PIDL = 1, /// Windows 7 and later. The pv parameter is an interface pointer to an IShellItem object. @@ -191,111 +368,135 @@ namespace Vanara.PInvoke /// previous PIDL or name of the item. dwItem2 contains the new PIDL or name of the item. /// SHCNE_RENAMEITEM = 0x00000001, + /// /// A nonfolder item has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was /// created. dwItem2 is not used and should be NULL. /// SHCNE_CREATE = 0x00000002, + /// /// A nonfolder item has been deleted. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was /// deleted. dwItem2 is not used and should be NULL. /// SHCNE_DELETE = 0x00000004, + /// /// A folder has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was /// created. dwItem2 is not used and should be NULL. /// SHCNE_MKDIR = 0x00000008, + /// /// A folder has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was /// removed. dwItem2 is not used and should be NULL. /// SHCNE_RMDIR = 0x00000010, + /// /// Storage media has been inserted into a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive that contains the new media. dwItem2 is not used and should be NULL. /// SHCNE_MEDIAINSERTED = 0x00000020, + /// /// Storage media has been removed from a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive from which the media was removed. dwItem2 is not used and should be NULL. /// SHCNE_MEDIAREMOVED = 0x00000040, + /// /// A drive has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was removed. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEREMOVED = 0x00000080, + /// /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was added. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEADD = 0x00000100, + /// /// A folder on the local computer is being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. /// dwItem1 contains the folder that is being shared. dwItem2 is not used and should be NULL. /// SHCNE_NETSHARE = 0x00000200, + /// /// A folder on the local computer is no longer being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in /// uFlags. dwItem1 contains the folder that is no longer being shared. dwItem2 is not used and should be NULL. /// SHCNE_NETUNSHARE = 0x00000400, + /// /// The attributes of an item or folder have changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains /// the item or folder that has changed. dwItem2 is not used and should be NULL. /// SHCNE_ATTRIBUTES = 0x00000800, + /// /// The contents of an existing folder have changed, but the folder still exists and has not been renamed. SHCNF_IDLIST or /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that has changed. dwItem2 is not used and should be NULL. /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or SHCNE_RENAMEFOLDER, respectively. /// SHCNE_UPDATEDIR = 0x00001000, + /// /// An existing item (a folder or a nonfolder) has changed, but the item still exists and has not been renamed. SHCNF_IDLIST or /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that has changed. dwItem2 is not used and should be NULL. /// If a nonfolder item has been created, deleted, or renamed, use SHCNE_CREATE, SHCNE_DELETE, or SHCNE_RENAMEITEM, respectively, instead. /// SHCNE_UPDATEITEM = 0x00002000, + /// /// The computer has disconnected from a server. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// server from which the computer was disconnected. dwItem2 is not used and should be NULL. /// SHCNE_SERVERDISCONNECT = 0x00004000, + /// /// An image in the system image list has changed. SHCNF_DWORD must be specified in uFlags. dwItem2 contains the index in the /// system image list that has changed. dwItem1 is not used and should be NULL. /// SHCNE_UPDATEIMAGE = 0x00008000, + /// /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was added. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEADDGUI = 0x00010000, + /// /// The name of a folder has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the previous PIDL /// or name of the folder. dwItem2 contains the new PIDL or name of the folder. /// SHCNE_RENAMEFOLDER = 0x00020000, + /// /// The amount of free space on a drive has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive on which the free space changed. dwItem2 is not used and should be NULL. /// SHCNE_FREESPACE = 0x00040000, + /// Not currently used. SHCNE_EXTENDED_EVENT = 0x04000000, + /// /// A file type association has changed. SHCNF_IDLIST must be specified in the uFlags parameter. dwItem1 and dwItem2 are not used /// and must be NULL. This event should also be sent for registered protocols. /// SHCNE_ASSOCCHANGED = 0x08000000, + /// All disk related events. SHCNE_DISKEVENTS = 0x0002381F, + /// All global events. SHCNE_GLOBALEVENTS = 0x0C0581E0, + /// All events. SHCNE_ALLEVENTS = 0x7FFFFFFF, + /// /// The presence of this flag indicates that the event was generated by an interrupt. It is stripped out before the clients of /// SHCNNotify_ see it. @@ -313,44 +514,81 @@ namespace Vanara.PInvoke /// ITEMIDLIST must be relative to the desktop folder. /// SHCNF_IDLIST = 0x0000, + /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHA = 0x0001, + /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected /// by the change. /// SHCNF_PRINTERA = 0x0002, + /// The dwItem1 and dwItem2 parameters are DWORD values. SHCNF_DWORD = 0x0003, + /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHW = 0x0005, + /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected /// by the change. /// SHCNF_PRINTERW = 0x0006, + /// Indicates that a type is defined. SHCNF_TYPE = 0x00FF, + /// /// The function should not return until the notification has been delivered to all affected components. As this flag modifies /// other data-type flags, it cannot be used by itself. /// SHCNF_FLUSH = 0x1000, + /// /// The function should begin delivering notifications to all affected components but should return as soon as the notification /// process has begun. As this flag modifies other data-type flags, it cannot by used by itself. This flag includes SHCNF_FLUSH. /// SHCNF_FLUSHNOWAIT = 0x3000, + /// Notify clients registered for all children. SHCNF_NOTIFYRECURSIVE = 0x10000 } + /// Flags used by SHChangeNotifyRegister. + [PInvokeData("shlobj_core.h", MSDNShortId = "73143865-ca2f-4578-a7a2-2ba4833eddd8")] + [Flags] + public enum SHCNRF + { + /// Interrupt level notifications from the file system. + SHCNRF_InterruptLevel = 0x0001, + + /// Shell-level notifications from the shell. + SHCNRF_ShellLevel = 0x0002, + + /// + /// Interrupt events on the whole subtree. This flag must be combined with the SHCNRF_InterruptLevel flag. When using this flag, + /// notifications must also be made recursive by setting the fRecursive member of the corresponding SHChangeNotifyEntry structure + /// referenced by pshcne to TRUE. Use of SHCNRF_RecursiveInterrupt on a single level view—for example, a PIDL that is relative + /// and contains only one SHITEMID—will block event notification at the highest level and thereby prevent a recursive, child + /// update. Thus, an icon dragged into the lowest level of a folder hierarchy may fail to appear in the view as expected. + /// + SHCNRF_RecursiveInterrupt = 0x1000, + + /// + /// Messages received use shared memory. Call SHChangeNotification_Lock to access the actual data. Call + /// SHChangeNotification_Unlock to release the memory when done. We recommend this flag because it provides a + /// more robust delivery method. All clients should specify this flag. + /// + SHCNRF_NewDelivery = 0x8000, + } + /// Receives a value that determines what type the item is in . [PInvokeData("Shlobj_core.h", MSDNShortId = "bb759775")] public enum SHDID @@ -419,6 +657,26 @@ namespace Vanara.PInvoke SHDID_MOBILE_DEVICE = 21, } + /// Format ID for SHFormatDrive. + [PInvokeData("shlobj_core.h", MSDNShortId = "4aa255fa-c407-47db-9b1f-d449e0a0e94f")] + public enum SHFMT_ID + { + /// The default format ID. + SHFMT_ID_DEFAULT = 0xFFFF + } + + /// Format options for SHFormatDrive. + [PInvokeData("shlobj_core.h", MSDNShortId = "4aa255fa-c407-47db-9b1f-d449e0a0e94f")] + [Flags] + public enum SHFMT_OPT + { + /// If this flag is set, then the Quick Format option is selected. + SHFMT_OPT_FULL = 0x0001, + + /// Selects the Create an MS-DOS startup disk option, creating a system boot disk. + SHFMT_OPT_SYSONLY = 0x0002 + } + /// The format in which the data is being requested. [PInvokeData("Shlobj.h", MSDNShortId = "bb762174")] public enum SHGetDataFormat @@ -453,28 +711,150 @@ namespace Vanara.PInvoke public enum SHIL { /// - /// The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in - /// Display Properties, the image is 48x48 pixels. + /// The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the + /// Appearance tab in Display Properties, the image is 48x48 pixels. /// SHIL_LARGE = 0, /// These images are the Shell standard small icon size of 16x16, but the size can be customized by the user. SHIL_SMALL = 1, - /// These images are the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user. + /// + /// These images are the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user. + /// SHIL_EXTRALARGE = 2, - /// These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON. + /// + /// These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON. + /// SHIL_SYSSMALL = 3, /// Windows Vista and later. The image is normally 256x256 pixels. SHIL_JUMBO = 4, } + /// Object type options for SHObjectProperties. + [PInvokeData("shlobj_core.h", MSDNShortId = "7517c461-955b-446e-85d7-a707c9bd183a")] + [Flags] + public enum SHOP + { + /// Contains the friendly name of a printer. + SHOP_PRINTERNAME = 0x00000001, + + /// Contains a fully qualified file name. + SHOP_FILEPATH = 0x00000002, + + /// + /// Contains either (a) a volume name of the form \?\Volume{GUID}, where {GUID} is a globally unique identifier (for example, + /// "\?\Volume{2eca078d-5cbc-43d3-aff8-7e8511f60d0e})", or (b) a drive path (for example, "C:"). + /// + SHOP_VOLUMEGUID = 0x00000004, + } + /// - /// CSIDL (constant special item ID list) values provide a unique system-independent way to identify special folders used frequently by applications, but - /// which may not have the same name or location on any given system. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on - /// another. These constants are defined in Shlobj.h. + /// Used by the SHGetSetSettings function to specify which members of its SHELLSTATE structure should be set or retrived. + /// + // https://msdn.microsoft.com/en-us/2a883110-fdc3-4451-9e47-e58894600e3b + [PInvokeData("Shlobj.h", MSDNShortId = "bb762591")] + [Flags] + public enum SSF : uint + { + /// The fShowAllObjects member is being requested. + SSF_SHOWALLOBJECTS = 0x00000001, + + /// The fShowExtensions member is being requested. + SSF_SHOWEXTENSIONS = 0x00000002, + + /// Not used. + SSF_HIDDENFILEEXTS = 0x00000004, + + /// Not used. + SSF_SERVERADMINUI = 0x00000004, + + /// The fShowCompColor member is being requested. + SSF_SHOWCOMPCOLOR = 0x00000008, + + /// The lParamSort and iSortDirection members are being requested. + SSF_SORTCOLUMNS = 0x00000010, + + /// The fShowSysFiles member is being requested. + SSF_SHOWSYSFILES = 0x00000020, + + /// The fDoubleClickInWebView member is being requested. + SSF_DOUBLECLICKINWEBVIEW = 0x00000080, + + /// + /// The fShowAttribCol member is being requested. + /// Windows Vista: Not used. + /// + SSF_SHOWATTRIBCOL = 0x00000100, + + /// + /// The fDesktopHTML member is being requested. Set is not available. Instead, for versions of Windows prior to Windows XP, + /// enable desktop HTML by IActiveDesktop. The use of IActiveDesktop for this purpose, however, is not recommended for Windows XP + /// and later versions of Windows, and is deprecated in Windows Vista. + /// + SSF_DESKTOPHTML = 0x00000200, + + /// The fWin95Classic member is being requested. + SSF_WIN95CLASSIC = 0x00000400, + + /// The fDontPrettyPath member is being requested. + SSF_DONTPRETTYPATH = 0x00000800, + + /// The fMapNetDrvBtn member is being requested. + SSF_MAPNETDRVBUTTON = 0x00001000, + + /// The fShowInfoTip member is being requested. + SSF_SHOWINFOTIP = 0x00002000, + + /// The fHideIcons member is being requested. + SSF_HIDEICONS = 0x00004000, + + /// The fNoConfirmRecycle member is being requested. + SSF_NOCONFIRMRECYCLE = 0x00008000, + + /// + /// The fFilter member is being requested. + /// Windows Vista: Not used. + /// + SSF_FILTER = 0x00010000, + + /// The fWebView member is being requested. + SSF_WEBVIEW = 0x00020000, + + /// The fShowSuperHidden member is being requested. + SSF_SHOWSUPERHIDDEN = 0x00040000, + + /// The fSepProcess member is being requested. + SSF_SEPPROCESS = 0x00080000, + + /// Windows XP and later. The fNoNetCrawling member is being requested. + SSF_NONETCRAWLING = 0x00100000, + + /// Windows XP and later. The fStartPanelOn member is being requested. + SSF_STARTPANELON = 0x00200000, + + /// Not used. + SSF_SHOWSTARTPAGE = 0x00400000, + + /// Windows Vista and later. The fAutoCheckSelect member is being requested. + SSF_AUTOCHECKSELECT = 0x00800000, + + /// Windows Vista and later. The fIconsOnly member is being requested. + SSF_ICONSONLY = 0x01000000, + + /// Windows Vista and later. The fShowTypeOverlay member is being requested. + SSF_SHOWTYPEOVERLAY = 0x02000000, + + /// Windows 8 and later: The fShowStatusBar member is being requested. + SSF_SHOWSTATUSBAR = 0x04000000, + } + + /// + /// CSIDL (constant special item ID list) values provide a unique system-independent way to identify special folders used frequently + /// by applications, but which may not have the same name or location on any given system. For example, the system folder may be + /// "C:\Windows" on one system and "C:\Winnt" on another. These constants are defined in Shlobj.h. /// [PInvokeData("Shlobj.h", MSDNShortId = "bb762494")] internal enum CSIDL @@ -589,15 +969,72 @@ namespace Vanara.PInvoke /// PKEY_NewMenuAllowedTypes /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-assocgetdetailsofpropkey - // SHSTDAPI AssocGetDetailsOfPropKey( IShellFolder *psf, PCUITEMID_CHILD pidl, const PROPERTYKEY *pkey, VARIANT *pv, BOOL *pfFoundPropKey ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-assocgetdetailsofpropkey SHSTDAPI + // AssocGetDetailsOfPropKey( IShellFolder *psf, PCUITEMID_CHILD pidl, const PROPERTYKEY *pkey, VARIANT *pv, BOOL *pfFoundPropKey ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [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); - /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable in subsequent versions of Windows.]Creates an Open dialog box so that the user can specify the drive, directory, and name of a file to open.Type: HWNDA handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.Type: PWSTRA null-terminated Unicode string that contains a file name used to initialize the File Name edit control. This string corresponds to the OPENFILENAME structure's lpstrFile member and is used in exactly the same way.Type: UINTThe number of characters in , including the terminating null character.Type: PCWSTRThe fully qualified file path of the initial directory. This string corresponds to the OPENFILENAME structure's lpstrInitialDir member and is used in exactly the same way.Type: PCWSTRA null-terminated Unicode string that contains the default file name extension. This extension is added to if the user does not specify an extension. The string should not contain any '.' characters. If this string is NULL and the user fails to type an extension, no extension is appended.Type: PCWSTRA null-terminated Unicode string that defines the filter. This string corresponds to the OPENFILENAME structure's lpstrFilter member and is used in exactly the same way.TBDType: BOOLIf the user specifies a file name and clicks OK, the return value is TRUE. The buffer that points to contains the full path and file name that the user specifies. If the user cancels or closes the Open dialog box or an error occurs, the return value is FALSE. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-getfilenamefrombrowse - // BOOL GetFileNameFromBrowse( HWND hwnd, PWSTR pszFilePath, UINT cchFilePath, PCWSTR pszWorkingDir, PCWSTR pszDefExt, PCWSTR pszFilters, PCWSTR pszTitle ); + /// + /// + /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable + /// in subsequent versions of Windows.] + /// + /// Creates an Open dialog box so that the user can specify the drive, directory, and name of a file to open. + /// + /// + /// Type: HWND + /// + /// A handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the + /// dialog box has no owner. + /// + /// + /// + /// Type: PWSTR + /// + /// A null-terminated Unicode string that contains a file name used to initialize the File Name edit control. This string corresponds + /// to the OPENFILENAME structure's lpstrFile member and is used in exactly the same way. + /// + /// + /// + /// Type: UINT + /// The number of characters in , including the terminating null character. + /// + /// + /// Type: PCWSTR + /// + /// The fully qualified file path of the initial directory. This string corresponds to the OPENFILENAME structure's + /// lpstrInitialDir member and is used in exactly the same way. + /// + /// + /// + /// Type: PCWSTR + /// + /// A null-terminated Unicode string that contains the default file name extension. This extension is added to if the user does not + /// specify an extension. The string should not contain any '.' characters. If this string is NULL and the user fails to type + /// an extension, no extension is appended. + /// + /// + /// + /// Type: PCWSTR + /// + /// A null-terminated Unicode string that defines the filter. This string corresponds to the OPENFILENAME structure's + /// lpstrFilter member and is used in exactly the same way. + /// + /// + /// + /// TBD + /// + /// + /// Type: BOOL + /// + /// If the user specifies a file name and clicks OK, the return value is TRUE. The buffer that points to contains the + /// full path and file name that the user specifies. If the user cancels or closes the Open dialog box or an error occurs, the + /// return value is FALSE. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-getfilenamefrombrowse BOOL GetFileNameFromBrowse( HWND hwnd, + // PWSTR pszFilePath, UINT cchFilePath, PCWSTR pszWorkingDir, PCWSTR pszDefExt, PCWSTR pszFilters, PCWSTR pszTitle ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj.h", MSDNShortId = "1f075051-18c8-4ec2-b010-f983ba2d3303")] [return: MarshalAs(UnmanagedType.Bool)] @@ -622,15 +1059,36 @@ namespace Vanara.PInvoke /// Type: PIDLIST_RELATIVE /// Returns the ITEMIDLIST structure specified by , with appended or prepended. Returns NULL on failure. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilappendid - // PIDLIST_RELATIVE ILAppendID( PIDLIST_RELATIVE pidl, LPCSHITEMID pmkid, BOOL fAppend ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilappendid PIDLIST_RELATIVE ILAppendID( + // PIDLIST_RELATIVE pidl, LPCSHITEMID pmkid, BOOL fAppend ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "d1bb5993-fe23-42d4-a2c5-8e54e6e37d09")] public static extern IntPtr ILAppendID(IntPtr pidl, ref SHITEMID pmkid, [MarshalAs(UnmanagedType.Bool)] bool fAppend); - /// Determines whether a specified ITEMIDLIST structure is the child of another ITEMIDLIST structure.Type: PCIDLIST_ABSOLUTEA pointer to the parent ITEMIDLIST structure.Type: PCIDLIST_ABSOLUTEA pointer to the child ITEMIDLIST structure.Type: PUIDLIST_RELATIVEReturns a pointer to the child's simple ITEMIDLIST structure if is a child of . The returned structure consists of , minus the SHITEMID structures that make up . Returns NULL if is not a child of .Note The returned pointer is a pointer into the existing parent structure. It is an alias for . No new memory is allocated in association with the returned pointer. It is not the caller's responsibility to free the returned value. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilfindchild - // PUIDLIST_RELATIVE ILFindChild( PIDLIST_ABSOLUTE pidlParent, PCIDLIST_ABSOLUTE pidlChild ); + /// + /// Determines whether a specified ITEMIDLIST structure is the child of another ITEMIDLIST structure. + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// A pointer to the parent ITEMIDLIST structure. + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// A pointer to the child ITEMIDLIST structure. + /// + /// + /// Type: PUIDLIST_RELATIVE + /// + /// Returns a pointer to the child's simple ITEMIDLIST structure if is a child of . The returned structure consists of , minus the + /// SHITEMID structures that make up . Returns NULL if is not a child of . + /// + /// + /// Note The returned pointer is a pointer into the existing parent structure. It is an alias for . No new memory is allocated + /// in association with the returned pointer. It is not the caller's responsibility to free the returned value. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilfindchild PUIDLIST_RELATIVE ILFindChild( + // PIDLIST_ABSOLUTE pidlParent, PCIDLIST_ABSOLUTE pidlChild ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4f07e989-ae74-4cf4-b3d9-0f59f2653095")] public static extern IntPtr ILFindChild(IntPtr pidlParent, IntPtr pidlChild); @@ -658,8 +1116,8 @@ namespace Vanara.PInvoke /// /// For use where STRICT_TYPED_ITEMIDS is defined. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-illoadfromstreamex - // SHSTDAPI ILLoadFromStreamEx( IStream *pstm, PIDLIST_RELATIVE *pidl ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-illoadfromstreamex SHSTDAPI ILLoadFromStreamEx( + // IStream *pstm, PIDLIST_RELATIVE *pidl ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "6fb735b6-a8c3-439e-9f20-4fda8f008b28")] public static extern HRESULT ILLoadFromStreamEx(IStream pstm, out IntPtr pidl); @@ -682,8 +1140,8 @@ namespace Vanara.PInvoke /// /// The stream must be opened for writing, or ILSaveToStream returns an error. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilsavetostream - // SHSTDAPI ILSaveToStream( IStream *pstm, PCUIDLIST_RELATIVE pidl ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilsavetostream SHSTDAPI ILSaveToStream( IStream + // *pstm, PCUIDLIST_RELATIVE pidl ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "40d5ce57-58dc-4c79-8fe6-5412e3d7dc64")] public static extern HRESULT ILSaveToStream(IStream pstm, IntPtr pidl); @@ -725,15 +1183,15 @@ namespace Vanara.PInvoke /// /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isnetdrive - // int IsNetDrive( int iDrive ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isnetdrive int IsNetDrive( int iDrive ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "44e02665-648a-4cf0-9dc0-038e54d08a49")] public static extern int IsNetDrive(int iDrive); /// - /// [IsUserAnAdmin is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in - /// subsequent versions.] + /// + /// [IsUserAnAdmin is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] /// /// Tests whether the current user is a member of the Administrator's group. /// @@ -747,8 +1205,7 @@ namespace Vanara.PInvoke /// group status rather than calling IsUserAnAdmin. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isuseranadmin - // BOOL IsUserAnAdmin( ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isuseranadmin BOOL IsUserAnAdmin( ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "fe698d32-32f6-4b2b-ad0c-5d9ec815177f")] [return: MarshalAs(UnmanagedType.Bool)] @@ -787,15 +1244,16 @@ namespace Vanara.PInvoke /// Type: IStream* /// Returns the address of an IStream interface if successful, or NULL otherwise. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-openregstream - // IStream * OpenRegStream( HKEY hkey, PCWSTR pszSubkey, PCWSTR pszValue, DWORD grfMode ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-openregstream IStream * OpenRegStream( HKEY hkey, + // PCWSTR pszSubkey, PCWSTR pszValue, DWORD grfMode ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "e1e35c94-84ac-4aa1-b2a1-47b37a7f224e")] public static extern IStream OpenRegStream(IntPtr hkey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, STGM grfMode); /// - /// [PathCleanupSpec is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in - /// subsequent versions.] + /// + /// [PathCleanupSpec is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] /// /// /// Removes illegal characters from a file or directory name. Enforces the 8.3 filename format on drives that do not support long @@ -870,14 +1328,16 @@ namespace Vanara.PInvoke /// 1 (to account for the terminating null character), the function returns PCS_PATHTOOLONG. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathcleanupspec - // int PathCleanupSpec( PCWSTR pszDir, PWSTR pszSpec ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathcleanupspec int PathCleanupSpec( PCWSTR + // pszDir, PWSTR pszSpec ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "593fd2b7-44ae-4309-a185-97e42f3cc0fa")] public static extern PCS PathCleanupSpec([MarshalAs(UnmanagedType.LPWStr)] string pszDir, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszSpec); + /// - /// [PathGetShortPath is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in - /// subsequent versions.] + /// + /// [PathGetShortPath is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] /// /// Retrieves the short path form of a specified input path. /// @@ -891,8 +1351,8 @@ namespace Vanara.PInvoke /// /// This function does not return a value. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathgetshortpath - // void PathGetShortPath( PWSTR pszLongPath ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathgetshortpath void PathGetShortPath( PWSTR + // pszLongPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "f374a575-3fbf-4bed-aa76-76ed81e01d60")] public static extern void PathGetShortPath([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszLongPath); @@ -911,8 +1371,7 @@ namespace Vanara.PInvoke /// Type: BOOL /// Returns TRUE if the file name extension is .cmd, .bat, .pif, .scf, .exe, .com, or .scr; otherwise, FALSE. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathisexe - // BOOL PathIsExe( PCWSTR pszPath ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathisexe BOOL PathIsExe( PCWSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "54e9dae7-f9c4-48b8-9b91-32ed21365fb7")] [return: MarshalAs(UnmanagedType.Bool)] @@ -944,8 +1403,7 @@ namespace Vanara.PInvoke /// /// Note that network conditions can impact function performance time. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-pathisslowa - // BOOL PathIsSlowA( LPCSTR pszFile, DWORD dwAttr ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-pathisslowa BOOL PathIsSlowA( LPCSTR pszFile, DWORD dwAttr ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj.h", MSDNShortId = "f848a098-9248-453b-a957-77c35d70e528")] [return: MarshalAs(UnmanagedType.Bool)] @@ -999,8 +1457,8 @@ namespace Vanara.PInvoke /// names such as "My New Filename (1)", "My New Filename (2)", and so on. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathmakeuniquename - // BOOL PathMakeUniqueName( PWSTR pszUniqueName, UINT cchMax, PCWSTR pszTemplate, PCWSTR pszLongPlate, PCWSTR pszDir ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathmakeuniquename BOOL PathMakeUniqueName( PWSTR + // pszUniqueName, UINT cchMax, PCWSTR pszTemplate, PCWSTR pszLongPlate, PCWSTR pszDir ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "8456ae0c-e83c-43d0-a86a-1861a373d237")] [return: MarshalAs(UnmanagedType.Bool)] @@ -1055,12 +1513,13 @@ namespace Vanara.PInvoke /// /// If PathResolve cannot resolve the path specified in , it calls PathFindOnPath using and as the parameters. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathresolve - // int PathResolve( PWSTR pszPath, PZPCWSTR dirs, UINT fFlags ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathresolve int PathResolve( PWSTR pszPath, + // PZPCWSTR dirs, UINT fFlags ); [DllImport(Lib.Shell32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shlobj_core.h", MSDNShortId = "84bf0b56-513f-4ac6-b2cf-11f0c471da1e")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathResolve(StringBuilder pszPath, string[] dirs, PRF fFlags); + /// /// Creates a unique filename based on an existing filename. /// @@ -1099,8 +1558,8 @@ namespace Vanara.PInvoke /// PathYetAnotherMakeUniqueName. In that case, the function returns FALSE. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathyetanothermakeuniquename - // BOOL PathYetAnotherMakeUniqueName( PWSTR pszUniqueName, PCWSTR pszPath, PCWSTR pszShort, PCWSTR pszFileSpec ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathyetanothermakeuniquename BOOL + // PathYetAnotherMakeUniqueName( PWSTR pszUniqueName, PCWSTR pszPath, PCWSTR pszShort, PCWSTR pszFileSpec ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shlobj_core.h", MSDNShortId = "1f76ecfa-6f2f-4dde-b05e-4252c92660d9")] [return: MarshalAs(UnmanagedType.Bool)] @@ -1144,36 +1603,51 @@ namespace Vanara.PInvoke /// Type: int /// Returns 1 if successful; otherwise, 0. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pickicondlg - // int PickIconDlg( HWND hwnd, PWSTR pszIconPath, UINT cchIconPath, int *piIconIndex ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pickicondlg int PickIconDlg( HWND hwnd, PWSTR + // pszIconPath, UINT cchIconPath, int *piIconIndex ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "3dfcda10-26d8-495d-8c92-7ff16da098c1")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PickIconDlg(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, uint cchIconPath, ref int piIconIndex); /// - /// [PifMgr_CloseProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] - /// Closes application properties that were opened with PifMgr_OpenProperties. - /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. + /// [PifMgr_CloseProperties is available for use in the operating systems specified in the Requirements section.It may be altered or + /// unavailable in subsequent versions.] + /// Closes application properties that were opened with PifMgr_OpenProperties. + /// + /// + /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. + /// /// A flag that specifies how the function operates. - /// Returns NULL if successful. If unsuccessful, the functions returns the handle to the application properties that was passed as hProps. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_closeproperties - // HANDLE PifMgr_CloseProperties(HANDLE hProps, UINT flOpt); + /// + /// Returns NULL if successful. If unsuccessful, the functions returns the handle to the application properties that was passed as hProps. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_closeproperties HANDLE + // PifMgr_CloseProperties(HANDLE hProps, UINT flOpt); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "fd50d4f8-87c8-4162-9e88-3c8592b929fa")] public static extern IntPtr PifMgr_CloseProperties(IntPtr hProps, CLOSEPROPS flOpt); /// - /// [PifMgr_GetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] - /// Returns a specified block of data from a .pif file. - /// A handle to an application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. - /// A null-terminated string that contains the property group name. It can be one of the following, or any other name that corresponds to a valid .pif extension. + /// [PifMgr_GetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or + /// unavailable in subsequent versions.] + /// Returns a specified block of data from a .pif file. + /// + /// + /// A handle to an application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. + /// + /// + /// A null-terminated string that contains the property group name. It can be one of the following, or any other name that + /// corresponds to a valid .pif extension. + /// /// When this function returns, contains a pointer to a PROPPRG structure. /// The size of the buffer, in bytes, pointed to by lpProps. /// Set this parameter to GETPROPS_NONE. - /// Returns NULL if successful. If unsuccessful, the function returns the handle to the application properties that were passed as hProps. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_getproperties - // int PifMgr_GetProperties( HANDLE hProps, PCSTR pszGroup, void* lpProps, int cbProps, UINT flOpt ); + /// + /// Returns NULL if successful. If unsuccessful, the function returns the handle to the application properties that were passed as hProps. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_getproperties int PifMgr_GetProperties( + // HANDLE hProps, PCSTR pszGroup, void* lpProps, int cbProps, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Ansi)] [PInvokeData("shlobj_core.h")] public static extern int PifMgr_GetProperties(IntPtr hProps, string pszGroup, IntPtr lpProps, int cbProps, uint flOpt = 0); @@ -1233,29 +1707,61 @@ namespace Vanara.PInvoke /// Searches the folders specified by the PATH environment variable. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_openproperties - // HANDLE PifMgr_OpenProperties( PCWSTR pszApp, PCWSTR pszPIF, UINT hInf, UINT flOpt ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_openproperties HANDLE + // PifMgr_OpenProperties( PCWSTR pszApp, PCWSTR pszPIF, UINT hInf, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "0bc11528-7278-4765-b3cb-671ba82c9155")] public static extern IntPtr PifMgr_OpenProperties([MarshalAs(UnmanagedType.LPWStr)] string pszApp, [MarshalAs(UnmanagedType.LPWStr)] string pszPIF, uint hInf, OPENPROPS flOpt); + /// - /// [PifMgr_SetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] - /// Assigns values to a block of data from a .pif file. - /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. - /// A null-terminated ANSI string containing the property group name. It can be one of the following, or any other name that corresponds to a valid .pif extension. + /// [PifMgr_SetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or + /// unavailable in subsequent versions.] + /// Assigns values to a block of data from a .pif file. + /// + /// + /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. + /// + /// + /// A null-terminated ANSI string containing the property group name. It can be one of the following, or any other name that + /// corresponds to a valid .pif extension. + /// /// A property group record buffer that holds the data. /// The size of the buffer, in bytes, pointed to by lpProps. /// Always SETPROPS_NONE. /// Returns the amount of information transferred, in bytes. Returns zero if the group cannot be found or an error occurs. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_setproperties - // int PifMgr_SetProperties(HANDLE hProps, PCSTR pszGroup, const void* lpProps, int cbProps, UINT flOpt ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_setproperties int + // PifMgr_SetProperties(HANDLE hProps, PCSTR pszGroup, const void* lpProps, int cbProps, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Ansi)] [PInvokeData("shlobj_core.h")] public static extern int PifMgr_SetProperties(IntPtr hProps, string pszGroup, IntPtr lpProps, int cbProps, uint flOpt = 0); - /// [ReadCabinetState is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]Fills a CABINETSTATE structure with information from the registry.Type: CABINETSTATE*When this function returns, contains a pointer to a CABINETSTATE structure that contains either information pulled from the registry or default information.Type: intThe size of the structure pointed to by , in bytes.Type: BOOLReturns TRUE if the returned structure contains information from the registry. Returns FALSE if the structure contains default information. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-readcabinetstate - // BOOL ReadCabinetState( CABINETSTATE *pcs, int cLength ); + /// + /// + /// [ReadCabinetState is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Fills a CABINETSTATE structure with information from the registry. + /// + /// + /// Type: CABINETSTATE* + /// + /// When this function returns, contains a pointer to a CABINETSTATE structure that contains either information pulled from the + /// registry or default information. + /// + /// + /// + /// Type: int + /// The size of the structure pointed to by , in bytes. + /// + /// + /// Type: BOOL + /// + /// Returns TRUE if the returned structure contains information from the registry. Returns FALSE if the structure + /// contains default information. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-readcabinetstate BOOL ReadCabinetState( + // CABINETSTATE *pcs, int cLength ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "0f0c6a10-588f-4c79-b73b-cf0bf9336ffc")] [return: MarshalAs(UnmanagedType.Bool)] @@ -1314,9 +1820,8 @@ namespace Vanara.PInvoke /// /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-realdrivetype - // int RealDriveType( int iDrive, BOOL fOKToHitNet ); - // public static extern int RealDriveType(int iDrive, [MarshalAs(UnmanagedType.Bool)] bool fOKToHitNet); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-realdrivetype int RealDriveType( int iDrive, BOOL + // fOKToHitNet ); public static extern int RealDriveType(int iDrive, [MarshalAs(UnmanagedType.Bool)] bool fOKToHitNet); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "c4e55b50-637a-446f-aa9c-7d8c71d8071c")] public static extern DRIVE_TYPE RealDriveType(int iDrive, [MarshalAs(UnmanagedType.Bool)] bool fOKToHitNet); @@ -1345,8 +1850,8 @@ namespace Vanara.PInvoke /// Type: int /// Returns the identifier of the button that was pressed to close the dialog box. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialog - // int RestartDialog( HWND hwnd, PCWSTR pszPrompt, DWORD dwReturn ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialog int RestartDialog( HWND hwnd, PCWSTR + // pszPrompt, DWORD dwReturn ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "ec1e3c11-9960-482c-8461-72c4d41dff3c")] public static extern int RestartDialog(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPrompt, uint dwReturn); @@ -1382,25 +1887,26 @@ namespace Vanara.PInvoke /// Type: int /// Returns the identifier of the button that was pressed to close the dialog box. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialogex - // int RestartDialogEx( HWND hwnd, PCWSTR pszPrompt, DWORD dwReturn, DWORD dwReasonCode ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialogex int RestartDialogEx( HWND hwnd, + // PCWSTR pszPrompt, DWORD dwReturn, DWORD dwReasonCode ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "32bc232f-6cc4-4f19-9d33-ba7ad28dfd59")] public static extern int RestartDialogEx(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPrompt, uint dwReturn, uint dwReasonCode); /// - /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function - /// can also be used to clear all usage data. + /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most + /// frequently. This function can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// - /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: + /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the + /// following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// - /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an - /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. + /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the + /// item through an AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// @@ -1412,18 +1918,19 @@ namespace Vanara.PInvoke public static extern void SHAddToRecentDocs(SHARD uFlags, IShellLinkW pv); /// - /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function - /// can also be used to clear all usage data. + /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most + /// frequently. This function can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// - /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: + /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the + /// following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// - /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an - /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. + /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the + /// item through an AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// @@ -1435,18 +1942,19 @@ namespace Vanara.PInvoke public static extern void SHAddToRecentDocs(SHARD uFlags, [MarshalAs(UnmanagedType.LPWStr)] string pv); /// - /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function - /// can also be used to clear all usage data. + /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most + /// frequently. This function can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// - /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: + /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the + /// following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// - /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an - /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. + /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the + /// item through an AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// @@ -1501,8 +2009,8 @@ namespace Vanara.PInvoke /// function with NULL as the bind context. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtofolderidlistparent - // SHSTDAPI SHBindToFolderIDListParent( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtofolderidlistparent SHSTDAPI + // SHBindToFolderIDListParent( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "72a79d1b-15ed-475e-9ebd-03345579a06a")] public static extern HRESULT SHBindToFolderIDListParent(IShellFolder psfRoot, PIDL pidl, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv, IntPtr ppidlLast); @@ -1550,8 +2058,9 @@ namespace Vanara.PInvoke /// Type: HRESULT /// If 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-shbindtofolderidlistparentex - // SHSTDAPI SHBindToFolderIDListParentEx( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, IBindCtx *ppbc, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtofolderidlistparentex SHSTDAPI + // SHBindToFolderIDListParentEx( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, IBindCtx *ppbc, REFIID riid, void **ppv, + // PCUITEMID_CHILD *ppidlLast ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4f9b68cb-d0ae-45f7-90f5-2db1da3ab599")] public static extern HRESULT SHBindToFolderIDListParentEx(IShellFolder psfRoot, PIDL pidl, IBindCtx ppbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv, IntPtr ppidlLast); @@ -1598,17 +2107,55 @@ namespace Vanara.PInvoke /// /// Note This is a helper function that gets the desktop object by calling SHGetDesktopFolder. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtoobject - // SHSTDAPI SHBindToObject( IShellFolder *psf, PCUIDLIST_RELATIVE pidl, IBindCtx *pbc, REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtoobject SHSTDAPI SHBindToObject( + // IShellFolder *psf, PCUIDLIST_RELATIVE pidl, IBindCtx *pbc, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "acc16097-8301-4118-8cb5-00aa2705306a")] public static extern HRESULT SHBindToObject(IShellFolder psf, PIDL pidl, IBindCtx pbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); + /// + /// + /// Takes a pointer to a fully qualified item identifier list (PIDL), and returns a specified interface pointer on the parent object. + /// + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// The item's PIDL. + /// + /// + /// Type: REFIID + /// The REFIID of one of the interfaces exposed by the item's parent object. + /// + /// + /// Type: VOID** + /// A pointer to the interface specified by riid. You must release the object when you are finished. + /// + /// + /// Type: PCUITEMID_CHILD* + /// + /// The item's PIDL relative to the parent folder. This PIDL can be used with many of the methods supported by the parent folder's + /// interfaces. If you set to NULL, the PIDL is not returned. + /// + /// + /// NoteSHBindToParent does not allocate a new PIDL; it simply receives a pointer through this parameter. Therefore, + /// you are not responsible for freeing this resource. + /// + /// + /// + /// Type: HRESULT + /// If 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-shbindtoparent SHSTDAPI SHBindToParent( + // PCIDLIST_ABSOLUTE pidl, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "1cb283a6-3ebf-4986-9f32-5f6ab8d977ad")] + public static extern HRESULT SHBindToParent(PIDL pidl, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv, ref IntPtr ppidlLast); + /// Displays a dialog box that enables the user to select a Shell folder. /// A pointer to a BROWSEINFO structure that contains information used to display the dialog box. /// - /// Returns a PIDL that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the Cancel button in the - /// dialog box, the return value is NULL. + /// Returns a PIDL that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the + /// Cancel button in the dialog box, the return value is NULL. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762115")] @@ -1642,8 +2189,8 @@ namespace Vanara.PInvoke /// Type: HANDLE /// Returns a handle (HLOCK) to the locked memory. Pass this value to SHChangeNotification_Unlock when finished. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_lock - // HANDLE SHChangeNotification_Lock( HANDLE hChange, DWORD dwProcId, PIDLIST_ABSOLUTE **pppidl, LONG *plEvent ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_lock HANDLE + // SHChangeNotification_Lock( HANDLE hChange, DWORD dwProcId, PIDLIST_ABSOLUTE **pppidl, LONG *plEvent ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "8e22d5d0-64be-403c-982d-c23705d85223")] public static extern IntPtr SHChangeNotification_Lock(IntPtr hChange, uint dwProcId, IntPtr pppidl, ref int plEvent); @@ -1659,8 +2206,8 @@ namespace Vanara.PInvoke /// Type: BOOL /// Returns TRUE on success; otherwise, FALSE. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_unlock - // BOOL SHChangeNotification_Unlock( HANDLE hLock ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_unlock BOOL + // SHChangeNotification_Unlock( HANDLE hLock ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "967ede1f-ee9c-46ee-a371-dcfc3a57d824")] [return: MarshalAs(UnmanagedType.Bool)] @@ -1701,13 +2248,115 @@ namespace Vanara.PInvoke /// The NTSHChangeNotifyDeregister function, which is no longer available for use as of Windows Vista, was equivalent to SHChangeNotifyDeregister. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotifyderegister - // BOOL SHChangeNotifyDeregister( ULONG ulID ); + // 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)] [PInvokeData("shlobj_core.h", MSDNShortId = "fad021dc-8199-4384-b623-c98bc618799f")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SHChangeNotifyDeregister(uint ulID); + /// + /// Registers a window to receive notifications from the file system or Shell, if the file system supports notifications. + /// + /// + /// Type: HWND + /// A handle to the window that receives the change or notification messages. + /// + /// + /// Type: int + /// One or more of the following values that indicate the type of events for which to receive notifications. + /// + /// Note In earlier versions of the SDK, these flags are not defined in a header file and implementers must define these + /// values themselves or use their numeric values directly. As of Windows Vista, these flags are defined in Shlobj.h. + /// + /// SHCNRF_InterruptLevel (0x0001) + /// Interrupt level notifications from the file system. + /// SHCNRF_ShellLevel (0x0002) + /// Shell-level notifications from the shell. + /// SHCNRF_RecursiveInterrupt (0x1000) + /// + /// Interrupt events on the whole subtree. This flag must be combined with the SHCNRF_InterruptLevel flag. When using this + /// flag, notifications must also be made recursive by setting the fRecursive member of the corresponding SHChangeNotifyEntry + /// structure referenced by to TRUE. Use of SHCNRF_RecursiveInterrupt on a single level view—for example, a PIDL that + /// is relative and contains only one SHITEMID—will block event notification at the highest level and thereby prevent a recursive, + /// child update. Thus, an icon dragged into the lowest level of a folder hierarchy may fail to appear in the view as expected. + /// + /// SHCNRF_NewDelivery (0x8000) + /// + /// Messages received use shared memory. Call SHChangeNotification_Lock to access the actual data. Call SHChangeNotification_Unlock + /// to release the memory when done. + /// + /// + /// Note We recommend this flag because it provides a more robust delivery method. All clients should specify this flag. + /// + /// + /// + /// Type: LONG + /// + /// Change notification events for which to receive notification. See the SHCNE flags listed in SHChangeNotify for possible values. + /// + /// + /// + /// Type: UINT + /// Message to be posted to the window procedure. + /// + /// + /// Type: int + /// Number of entries in the array. + /// + /// + /// Type: const SHChangeNotifyEntry* + /// + /// Array of SHChangeNotifyEntry structures that contain the notifications. This array should always be set to one when calling + /// SHChangeNotifyRegister or SHChangeNotifyDeregister will not work properly. + /// + /// + /// + /// Type: ULONG + /// Returns a positive integer registration ID. Returns 0 if out of memory or in response to invalid parameters. + /// + /// + /// + /// See the Change Notify Watcher Sample in the Windows Software Development Kit (SDK) for a full example that demonstrates the use + /// of this function. + /// + /// When a change notification event is raised, the message indicated by is delivered to the window specified by the parameter. + /// + /// + /// If SHCNRF_NewDelivery is specified, the and values in the message should be passed to SHChangeNotification_Lock as the and + /// parameters respectively. + /// + /// + /// If SHCNRF_NewDelivery is not specified, is a pointer to two PIDLIST_ABSOLUTE pointers, and specifies the event. The two + /// PIDLIST_ABSOLUTE pointers can be NULL, depending on the event being sent. + /// + /// + /// When a relevant file system event takes place and the + /// hwnd + /// parameter is not + /// NULL + /// , then the message indicated by + /// wMsg + /// is posted to the specified window. Otherwise, if the + /// pshcne + /// parameter is not + /// NULL + /// , then that notification entry is used. + /// + /// For performance reasons, multiple notifications can be combined into a single notification. For example, if a large number of + /// SHCNE_UPDATEITEM notifications are generated for files in the same folder, they can be joined into a single SHCNE_UPDATEDIR notification. + /// + /// + /// The NTSHChangeNotifyRegister function, which is no longer available as of Windows Vista, was equivalent to + /// SHChangeNotifyRegister with the SHCNRF_NewDelivery flag. + /// + /// + // 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)] + [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); + /// /// Enables asynchronous register and deregister of a thread. /// @@ -1718,8 +2367,8 @@ namespace Vanara.PInvoke /// /// This function does not return a value. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-shchangenotifyregisterthread - // void SHChangeNotifyRegisterThread( SCNRT_STATUS status ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-shchangenotifyregisterthread void + // SHChangeNotifyRegisterThread( SCNRT_STATUS status ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj.h", MSDNShortId = "170afefc-b4de-4661-9c12-1341656b0fdb")] public static extern void SHChangeNotifyRegisterThread(SCNRT_STATUS status); @@ -1783,8 +2432,8 @@ namespace Vanara.PInvoke /// lead to unexpected results. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedataobject - // SHSTDAPI SHCreateDataObject( PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedataobject SHSTDAPI SHCreateDataObject( + // PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "d56cdafe-9463-43a5-8ef0-6cfaf0c524a8")] public static extern HRESULT SHCreateDataObject(PIDL pidlFolder, uint cidl, [In, MarshalAs(UnmanagedType.LPArray)] PIDL[] apidl, IDataObject pdtInner, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IDataObject ppv); @@ -1818,8 +2467,8 @@ namespace Vanara.PInvoke /// implementations such as open, explore, delete, and copy. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedefaultcontextmenu - // SHSTDAPI SHCreateDefaultContextMenu( const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedefaultcontextmenu SHSTDAPI + // SHCreateDefaultContextMenu( const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "055ff0a0-9ba7-463d-9684-3fd072b190da")] public static extern HRESULT SHCreateDefaultContextMenu(ref DEFCONTEXTMENU pdcm, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); @@ -1882,8 +2531,8 @@ namespace Vanara.PInvoke /// /// To set security attributes on a new folder, use SHCreateDirectoryEx. /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectory - // int SHCreateDirectory( HWND hwnd, PCWSTR pszPath ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectory int SHCreateDirectory( HWND + // hwnd, PCWSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4927429c-f457-4dda-aa0d-236eb236795c")] public static extern Win32Error SHCreateDirectory([Optional] HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPath); @@ -1964,8 +2613,8 @@ namespace Vanara.PInvoke /// If is set to NULL, no user interface is displayed and the function returns ERROR_CANCELLED. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectoryexa - // int SHCreateDirectoryEx( HWND hwnd, LPCTSTR pszPath, const SECURITY_ATTRIBUTES *psa ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectoryexa int SHCreateDirectoryEx( HWND + // hwnd, LPCTSTR pszPath, const SECURITY_ATTRIBUTES *psa ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj_core.h", MSDNShortId = "7f44f907-cd12-4156-91c0-76e577ae25f6")] public static extern Win32Error SHCreateDirectoryEx([Optional] HandleRef hwnd, string pszPath, [In] SECURITY_ATTRIBUTES psa); @@ -2008,38 +2657,227 @@ namespace Vanara.PInvoke /// Type: HRESULT /// If 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-shcreatefileextracticonw - // SHSTDAPI SHCreateFileExtractIconW( LPCWSTR pszFile, DWORD dwFileAttributes, REFIID riid, void **ppv ); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatefileextracticonw SHSTDAPI + // SHCreateFileExtractIconW( LPCWSTR pszFile, DWORD dwFileAttributes, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "af3beb0a-892b-43e5-b5b8-8005f497b6e5")] public static extern HRESULT SHCreateFileExtractIconW([MarshalAs(UnmanagedType.LPWStr)] string pszFile, FileFlagsAndAttributes dwFileAttributes, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); - /// Creates a new instance of the default Shell folder view object (DefView). - /// Pointer to a SFV_CREATE structure that describes the particulars used in creating this instance of the Shell folder view object. - /// When this function returns successfully, contains an interface pointer to the new IShellView object. On failure, this value is NULL. - /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] - [PInvokeData("Shlobj.h")] + /// + /// + /// [SHCreatePropSheetExtArray is available for use in the operating systems specified in the Requirements section. It may be altered + /// or unavailable in subsequent versions.] + /// + /// Loads all the Shell property sheet extension handlers located under a specified registry key. + /// + /// + /// TBD + /// + /// + /// TBD + /// + /// + /// Type: UINT + /// The maximum number of property sheet handlers to be returned. + /// + /// + /// Type: HPSXA + /// + /// Returns a handle to an array of property sheet handlers. Pass this value to SHAddFromPropSheetExtArray. You do not access this + /// value directly. + /// + /// + /// + /// When you are finished with the returned HPSXA handle, destroy it by calling SHDestroyPropSheetExtArray. + /// This function loads up to property sheet extensions into an array that is then passed to SHAddFromPropSheetExtArray. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-shcreatepropsheetextarray WINSHELLAPI HPSXA + // SHCreatePropSheetExtArray( HKEY hKey, PCWSTR pszSubKey, UINT max_iface ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj.h", MSDNShortId = "88a72529-325d-431e-bc26-bddca787e62b")] + public static extern IntPtr SHCreatePropSheetExtArray(IntPtr hKey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubKey, uint max_iface); + + /// + /// Creates a new instance of the default Shell folder view object (DefView). + /// + /// + /// Type: const SFV_CREATE* + /// + /// Pointer to a SFV_CREATE structure that describes the particulars used in creating this instance of the Shell folder view object. + /// + /// + /// + /// Type: IShellView** + /// + /// When this function returns successfully, contains an interface pointer to the new IShellView object. On failure, this value is NULL. + /// + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// SHCreateShellFolderView is recommended over SHCreateShellFolderViewEx because of the greater flexibility of its elements + /// to participate in various scenarios, provide new functionality to the view, and interact with other objects. + /// + /// + /// When dealing with several instances of IShellView, you might want to verify which is the default Shell folder view object. To do + /// so, call QueryInterface on the object using the IID_CDefView IID. This call succeeds only when made on the default Shell folder + /// view object. + /// + /// Data sources that use the default Shell folder view object must implement these interfaces: + /// + /// IShellFolder + /// IShellFolder2 + /// IPersistFolder + /// IPersistFolder2 + /// + /// Optionally, they can also implement + /// IPersistFolder3 + /// . + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreateshellfolderview SHSTDAPI + // SHCreateShellFolderView( const SFV_CREATE *pcsfv, IShellView **ppsv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "f2948a6d-84a5-456b-b328-ba76dba46e9d")] public static extern HRESULT SHCreateShellFolderView(ref SFV_CREATE pcsfv, out IShellView ppsv); + /// + /// + /// Creates a new instance of the default Shell folder view object. It is recommended that you use SHCreateShellFolderView rather + /// than this function. + /// + /// + /// + /// Type: CSFV* + /// Pointer to a structure that describes the details used in creating this instance of the Shell folder view object. + /// + /// + /// Type: IShellView** + /// + /// The address of an IShellView interface pointer that, when this function returns successfully, points to the new view object. On + /// failure, this value is NULL. + /// + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// SHCreateShellFolderView is recommended over SHCreateShellFolderViewEx because of the greater flexibility of its elements + /// to participate in various scenarios, provide new functionality to the view, and interact with other objects. + /// + /// + /// When dealing with several instances of IShellView, you might want to verify which is the default Shell folder view object. To do + /// so, call QueryInterface on the object using IID_CDefView. This call succeeds only on the default Shell folder view object. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreateshellfolderviewex SHSTDAPI + // SHCreateShellFolderViewEx( CSFV *pcsfv, IShellView **ppsv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "7edd6786-7d74-4065-8cf1-cbb489007a46")] + public static extern HRESULT SHCreateShellFolderViewEx(ref CSFV pcsfv, out IShellView ppsv); + + /// + /// Creates an IShellItem object. + /// Note It is recommended that you use SHCreateItemWithParent or SHCreateItemFromIDList instead of this function. + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// A PIDL to the parent. This value can be NULL. + /// + /// + /// Type: IShellFolder* + /// A pointer to the parent IShellFolder. This value can be NULL. + /// + /// + /// Type: PCUITEMID_CHILD + /// A PIDL to the requested item. If parent information is not included in or , this must be an absolute PIDL. + /// + /// + /// Type: IShellItem** + /// When this method returns, contains the interface pointer to the new IShellItem. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// SHCreateShellItem creates an object that represents a Shell namespace item. The caller must provide parent information in + /// or ; alternatively, the caller can provide an absolute IDList in the parameter. + /// + /// There are three valid calling patterns for this function: + /// + /// + /// The parent folder is identified by an absolute IDList . The parameter points to a child IDList that identifies the item within + /// the folder identified by . + /// + /// + /// The parent folder is identified by . The parameter points to a child IDList that identifies the item within the folder identified + /// by . + /// + /// The item is identified by an absolute IDList passed to the parameter. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreateshellitem SHSTDAPI SHCreateShellItem( + // PCIDLIST_ABSOLUTE pidlParent, IShellFolder *psfParent, PCUITEMID_CHILD pidl, IShellItem **ppsi ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "d4371cdf-a8f4-4a39-ba66-97fd40ed46ae")] + public static extern HRESULT SHCreateShellItem(PIDL pidlParent, IShellFolder psfParent, PIDL pidl, out IShellItem ppsi); + + /// + /// + /// [SHCreateStdEnumFmtEtc is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Creates an IEnumFORMATETC object from an array of FORMATETC structures. + /// + /// + /// Type: UINT + /// The number of entries in the array. + /// + /// + /// Type: const FORMATETC[] + /// An array of FORMATETC structures that specifies the clipboard formats of interest. + /// + /// + /// Type: IEnumFORMATETC** + /// When this function returns successfully, receives an IEnumFORMATETC interface pointer. Receives NULL on failure. + /// + /// + /// Type: HRESULT + /// If 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-shcreatestdenumfmtetc SHSTDAPI + // SHCreateStdEnumFmtEtc( UINT cfmt, const FORMATETC [] afmt, IEnumFORMATETC **ppenumFormatEtc ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "c391c8c8-6062-4e70-9a1f-de0eb610250d")] + public static extern HRESULT SHCreateStdEnumFmtEtc(uint cfmt, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] FORMATETC[] afmt, out IEnumFORMATETC ppenumFormatEtc); + /// Provides a default handler to extract an icon from a file. - /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. + /// + /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. + /// /// - /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position of the icon in the - /// file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a negative number, it refers to the icon's - /// resource ID. + /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position + /// of the icon in the file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a + /// negative number, it refers to the icon's resource ID. /// /// A flag that controls the icon extraction. /// - /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon specified in the LOWORD of - /// nIconSize. This value can be NULL. + /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon + /// specified in the LOWORD of nIconSize. This value can be NULL. /// /// - /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon specified in the HIWORD of nIconSize. + /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon + /// specified in the HIWORD of nIconSize. /// /// - /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 to specify default - /// large and small sizes. + /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 + /// to specify default large and small sizes. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762149")] @@ -2047,54 +2885,521 @@ namespace Vanara.PInvoke ref IntPtr phiconSmall, uint nIconSize); /// Provides a default handler to extract an icon from a file. - /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. + /// + /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. + /// /// - /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position of the icon in the - /// file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a negative number, it refers to the icon's - /// resource ID. + /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position + /// of the icon in the file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a + /// negative number, it refers to the icon's resource ID. /// /// A flag that controls the icon extraction. /// - /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon specified in the LOWORD of - /// nIconSize. This value can be NULL. + /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon + /// specified in the LOWORD of nIconSize. This value can be NULL. /// /// - /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon specified in the HIWORD of nIconSize. + /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon + /// specified in the HIWORD of nIconSize. /// /// - /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 to specify default - /// large and small sizes. + /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 + /// to specify default large and small sizes. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762149")] public static extern HRESULT SHDefExtractIcon(string pszIconFile, int iIndex, uint uFlags, IntPtr phiconLarge, ref IntPtr phiconSmall, uint nIconSize); + /// + /// + /// [SHDestroyPropSheetExtArray is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// Frees property sheet handlers that are pointed to an array created by SHCreatePropSheetExtArray. + /// + /// + /// Type: HPSXA + /// The handle of the array that contains pointers to the property sheet handlers to destroy. + /// + /// + /// This function does not return a value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shdestroypropsheetextarray WINSHELLAPI void + // SHDestroyPropSheetExtArray( HPSXA hpsxa ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "beb3c1b1-deef-440d-8cf7-f76b3f396efa")] + public static extern void SHDestroyPropSheetExtArray(IntPtr hpsxa); + + /// + /// Executes a drag-and-drop operation. Supports drag source creation on demand, as well as drag images. + /// + /// + /// Type: HWND + /// The handle of the window used to obtain the drag image. This value can be NULL. See Remarks for more details. + /// + /// + /// TBD + /// + /// + /// Type: IDropSource* + /// + /// A pointer to an implementation of the IDropSource interface, which is used to communicate with the source during the drag operation. + /// + /// As of Windows Vista, if this value is NULL, the Shell creates a drop source object for you. + /// + /// + /// Type: DWORD + /// + /// The effects that the source allows in the drag-and-drop operation. The most significant effect is whether the drag-and-drop + /// operation permits a move. For a list of possible values, see DROPEFFECT. + /// + /// + /// + /// Type: DWORD* + /// + /// A pointer to a value that indicates how the drag-and-drop operation affected the source data. The parameter is set only if the + /// operation is not canceled. For a list of possible values, see DROPEFFECT. + /// + /// + /// + /// Type: HRESULT + /// This function supports the standard return value E_OUTOFMEMORY, as well as the following values: + /// + /// + /// Return code + /// Description + /// + /// + /// DRAGDROP_S_DROP + /// The drag-and-drop operation was successful. + /// + /// + /// DRAGDROP_S_CANCEL + /// The drag-and-drop operation was canceled. + /// + /// + /// E_UNSPEC + /// Unexpected error occurred. + /// + /// + /// + /// + /// + /// As of Windows Vista, if a drag image is not already stored in the data object and a drag image cannot be obtained from the window + /// specified by , the Shell provides a generic drag image. A drag image can fail to be obtained from the specified window either + /// because is NULL or the specified window does not support the DI_GETDRAGIMAGE message. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shdodragdrop SHSTDAPI SHDoDragDrop( HWND hwnd, + // IDataObject *pdata, IDropSource *pdsrc, DWORD dwEffect, DWORD *pdwEffect ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "76c98516-ede9-47de-b4ad-257a162775b9")] + public static extern HRESULT SHDoDragDrop(HandleRef hwnd, IDataObject pdata, [Optional] IntPtr pdsrc, DROPEFFECT dwEffect, ref DROPEFFECT pdwEffect); + + /// + /// + /// [Shell_GetCachedImageIndex is available for use in the operating systems specified in the Requirements section. It may be altered + /// or unavailable in subsequent versions. Instead, use + /// + /// Shell_GetCachedImageIndexA + /// or + /// Shell_GetCachedImageIndexW + /// .] + /// Retrieves the cache index of a cached icon. + /// + /// + /// TBD + /// + /// + /// Type: int + /// The index of the image within the file named at . + /// + /// + /// Type: UINT + /// Not used. + /// + /// + /// Type: int + /// Returns the index of the image, or –1 on failure. + /// + /// + /// + /// The Shell_GetCachedImageIndexA and Shell_GetCachedImageIndexW versions of this function were added in Windows + /// Vista. For Unicode strings, call either Shell_GetCachedImageIndexW or Shell_GetCachedImageIndex. For ANSI strings, + /// you must call Shell_GetCachedImageIndexA explicitly. + /// + /// + /// Windows Server 2003 and Windows XP: Only Shell_GetCachedImageIndex is supported. Shell_GetCachedImageIndex + /// requires a Unicode string. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shell_getcachedimageindexa int + // Shell_GetCachedImageIndexA( LPCSTR pszIconPath, int iIconIndex, UINT uIconFlags ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shlobj_core.h", MSDNShortId = "f0d4dd1f-a41c-4dd0-9713-e3aec48ff101")] + public static extern int Shell_GetCachedImageIndex(string pszIconPath, int iIconIndex, uint uIconFlags); + + /// + /// + /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable + /// in subsequent versions of Windows.] + /// + /// Retrieves system image lists for large and small icons. + /// + /// + /// Type: HIMAGELIST* + /// A pointer to the handle of an image list which, on success, receives the system image list for large (32 x 32) icons. + /// + /// + /// Type: HIMAGELIST* + /// A pointer to the handle of an image list which, on success, receives the system image list for small (16 x 16) icons. + /// + /// + /// Type: BOOL + /// Returns TRUE on success. On failure, returns FALSE and the image lists pointed to by and are unchanged. + /// + /// + /// + /// Important The image lists retrieved through this function are global system image lists; do not call ImageList_Destroy + /// using them. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shell_getimagelists BOOL Shell_GetImageLists( + // HIMAGELIST *phiml, HIMAGELIST *phimlSmall ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "c3b73616-849c-4149-b04d-a7d389ebf700")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool Shell_GetImageLists(ref IntPtr phiml, ref IntPtr phimlSmall); + + /// + /// + /// [Shell_MergeMenus is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Merges two menus. + /// + /// + /// Type: HMENU + /// The destination menu to which is added. + /// + /// + /// Type: HMENU + /// The source menu which is added to . + /// + /// + /// Type: UINT + /// The point in after which the entries in are inserted. + /// + /// + /// Type: UINT + /// + /// This number is added to each menu's ID to give an adjusted ID. Set to for no adjustment. The value for would typically be the + /// number of items in . This number can be obtained using the GetMenuItemCount. + /// + /// + /// + /// Type: UINT + /// + /// The maximum adjusted ID to add to the menu. Any adjusted ID greater than this value is not added. To allow all IDs, set this + /// parameter to 0xFFFF. + /// + /// + /// + /// Type: ULONG + /// One or more of the following flags. + /// MM_ADDSEPARATOR + /// + /// Add a separator between the items from the two menus if one does not exist already. If you are inserting the entries from into + /// the middle of , a separator is added above and below the material. + /// + /// MM_DONTREMOVESEPS + /// Do not remove any existing separators in the two menus. Note that this could result in two separators in a row. + /// MM_SUBMENUSHAVEIDS + /// Set this flag if the submenus have IDs which should be adjusted. + /// + /// + /// Type: UINT + /// Returns the next open ID at the end of the menu (the maximum adjusted ID + 1). + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shell_mergemenus UINT Shell_MergeMenus( HMENU + // hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "f9e005fd-b1f2-4a5f-ad36-9c44998dc4eb")] + public static extern uint Shell_MergeMenus(IntPtr hmDst, IntPtr hmSrc, uint uInsert, uint uIDAdjust, uint uIDAdjustMax, MM uFlags); + + /// + /// + /// [SHFind_InitMenuPopup is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// + /// Retrieves the IContextMenu instance for the submenu of options displayed for the Search entry in the Classic style Start menu. + /// + /// + /// + /// Type: HMENU + /// The handle of the popup menu. + /// + /// + /// TBD + /// + /// + /// Type: UINT + /// The ID of the first menu item. + /// + /// + /// Type: UINT + /// The ID of the last menu item. + /// + /// + /// Type: IContextMenu* + /// If successful, returns an IContextMenu pointer. On failure, returns NULL. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shfind_initmenupopup IContextMenu * + // SHFind_InitMenuPopup( HMENU hmenu, HWND hwndOwner, UINT idCmdFirst, UINT idCmdLast ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "ca44bd57-6af0-45b3-9331-914e93360743")] + public static extern IContextMenu SHFind_InitMenuPopup(IntPtr hmenu, HandleRef hwndOwner, uint idCmdFirst, uint idCmdLast); + + /// + /// + /// [SHFindFiles is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Displays the Search window UI. + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// + /// The folder from which to start the search. This folder appears in the Look in: box in the Search window. This + /// folder and all of its subfolders are searched unless users choose other options in the Search window's More Advanced + /// Options. This value can be NULL. + /// + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// This parameter is not used and must be set to NULL. + /// + /// Windows Server 2003 and Windows XP: A saved search file (.fnd) to load. You can save search parameters to a .fnd file + /// after the search is begun. This value can be NULL. + /// + /// + /// + /// Type: BOOL + /// Returns TRUE if successful in displaying the Search window; otherwise FALSE. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shfindfiles BOOL SHFindFiles( PCIDLIST_ABSOLUTE + // pidlFolder, PCIDLIST_ABSOLUTE pidlSaveFile ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "c54036c2-e6b9-4b21-b2b2-a6721c502ee5")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHFindFiles(PIDL pidlFolder, IntPtr pidlSaveFile); + + /// + /// + /// [SHFlushSFCache is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Flushes the special folder cache. + /// + /// + /// This function does not return a value. + /// + /// + /// + /// SHFlushSFCache is called when the path to a special folder is changed. This ensures that the updated path stored in the + /// registry is used rather than the cached value. + /// + /// For more information on special folders, see the section of Getting a Folder's ID. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shflushsfcache void SHFlushSFCache( ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "2e39b6b1-e60c-411c-aabc-5a3511f0693b")] + public static extern void SHFlushSFCache(); + + /// + /// + /// [SHFormatDrive is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Opens the Shell's Format dialog box. + /// + /// + /// Type: HWND + /// + /// The handle of the parent window of the dialog box. The Format dialog box must have a parent window; therefore, this + /// parameter cannot be NULL. + /// + /// + /// + /// Type: UINT + /// + /// The drive to format. The value of this parameter represents a letter drive starting at 0 for the A: drive. For example, a value + /// of 2 stands for the C: drive. + /// + /// + /// + /// Type: UINT + /// The ID of the physical format. Only the following flag is currently defined. + /// SHFMT_ID_DEFAULT (0xFFFF) + /// The default format ID. + /// + /// + /// Type: UINT + /// + /// This value must be 0 or one of the following values that alter the default format options in the dialog box. This value is + /// regarded as a bitfield and should be treated accordingly. + /// + /// SHFMT_OPT_FULL (0x0001) + /// 0x001. If this flag is set, then the Quick Format option is selected. + /// This function is included in Shlobj.h only in Windows XP with SP1 and later. + /// Windows XP: Prior to Windows XP with SP1, this function is accessible through Shell32.lib. + /// SHFMT_OPT_SYSONLY (0x0002) + /// 0x002. Selects the Create an MS-DOS startup disk option, creating a system boot disk. + /// + /// + /// Type: DWORD + /// + /// Returns the format ID of the last successful format or one of the following values. The LOWORD of this value can be passed on + /// subsequent calls as the parameter to repeat the last format. + /// + /// + /// + /// Return code + /// Description + /// + /// + /// SHFMT_ERROR + /// An error occurred during the last format. This does not indicate that the drive is unformattable. + /// + /// + /// SHFMT_CANCEL + /// The last format was canceled. + /// + /// + /// SHFMT_NOFORMAT + /// The drive cannot be formatted. + /// + /// + /// + /// + /// + /// The format is controlled by the dialog box interface. That is, the user must click the OK button to actually begin the + /// format—the format cannot be started programmatically. + /// + /// Examples + /// + /// This call to SHFormatDrive brings up the Shell's Format dialog box for a disk in drive A, with the default formatting + /// options selected. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shformatdrive DWORD SHFormatDrive( HWND hwnd, UINT + // drive, UINT fmtID, UINT options ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "4aa255fa-c407-47db-9b1f-d449e0a0e94f")] + public static extern uint SHFormatDrive(HandleRef hwnd, uint drive, SHFMT_ID fmtID, SHFMT_OPT options); + + /// + /// + /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable + /// in subsequent versions of Windows. Use CoTaskMemFree instead.] + /// + /// Frees the memory allocated by SHAlloc. + /// + /// + /// Type: void* + /// A pointer to the memory allocated by SHAlloc. + /// + /// + /// This function does not return a value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shfree void SHFree( void *pv ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "c9a532ad-ae24-4505-9e7b-577b90365441")] + public static extern void SHFree(IntPtr pv); + + /// + /// + /// [SHGetAttributesFromDataObject is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// Retrieves specified pieces of information from a system data object. + /// + /// + /// Type: IDataObject* + /// The data object from which to retrieve the information. + /// + /// + /// Type: DWORD + /// One or more of the SFGAO flags that indicate which pieces of information the calling application wants to retrieve. + /// + /// + /// Type: DWORD* + /// + /// A pointer to a DWORD value that, when this function returns successfully, receives one or more SFGAO flags that indicate + /// the attributes, among those requested, that are common to all items in . This pointer can be NULL if this information is + /// not needed. + /// + /// + /// + /// Type: UINT* + /// + /// A pointer to a UINT that, when this function returns successfully, receives the number of PIDLs in the data object pointed + /// to by . This pointer can be NULL if this information is not needed. + /// + /// + /// + /// Type: HRESULT + /// This function can return one of these values. + /// + /// + /// Return code + /// Description + /// + /// + /// S_OK + /// Success. + /// + /// + /// S_FALSE + /// The object is not a system data object. In this case, is set to 0. + /// + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetattributesfromdataobject HRESULT + // SHGetAttributesFromDataObject( IDataObject *pdo, DWORD dwAttributeMask, DWORD *pdwAttributes, UINT *pcItems ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "bdc583ef-a5b6-4665-949c-50f79ace39dc")] + public static extern HRESULT SHGetAttributesFromDataObject(IDataObject pdo, SFGAO dwAttributeMask, out SFGAO pdwAttributes, out uint pcItems); + /// Retrieves extended property data from a relative identifier list. /// - /// The address of the parent IShellFolder interface. This must be the immediate parent of the ITEMIDLIST structure referenced by the pidl parameter. + /// The address of the parent IShellFolder interface. This must be the immediate parent of the ITEMIDLIST structure referenced by the + /// pidl parameter. /// /// A pointer to an ITEMIDLIST structure that identifies the object relative to the folder specified in psf. /// The format in which the data is being requested. /// - /// A pointer to a buffer that, when this function returns successfully, receives the requested data. The format of this buffer is determined by nFormat. + /// A pointer to a buffer that, when this function returns successfully, receives the requested data. The format of this buffer is + /// determined by nFormat. /// - /// If nFormat is SHGDFIL_NETRESOURCE, there are two possible cases. If the buffer is large enough, the net resource's string information (fields for the - /// network name, local name, provider, and comments) will be placed into the buffer. If the buffer is not large enough, only the net resource structure - /// will be placed into the buffer and the string information pointers will be NULL. + /// If nFormat is SHGDFIL_NETRESOURCE, there are two possible cases. If the buffer is large enough, the net resource's string + /// information (fields for the network name, local name, provider, and comments) will be placed into the buffer. If the buffer is + /// not large enough, only the net resource structure will be placed into the buffer and the string information pointers will be NULL. /// /// /// Size of the buffer at pv, in bytes. /// - /// This function extracts only information that is present in the pointer to an item identifier list (PIDL). Since the content of a PIDL depends on the - /// folder object that created the PIDL, there is no guarantee that all requested information will be available. In addition, the information that is - /// returned reflects the state of the object at the time the PIDL was created. The current state of the object could be different. For example, if you - /// set nFormat to SHGDFIL_FINDDATA, the function might assign meaningful values to only some of the members of the WIN32_FIND_DATA structure. The - /// remaining members will be set to zero. To retrieve complete current information on a file system file or folder, use standard file system functions - /// such as GetFileTime or FindFirstFile. + /// This function extracts only information that is present in the pointer to an item identifier list (PIDL). Since the content of a + /// PIDL depends on the folder object that created the PIDL, there is no guarantee that all requested information will be available. + /// In addition, the information that is returned reflects the state of the object at the time the PIDL was created. The current + /// state of the object could be different. For example, if you set nFormat to SHGDFIL_FINDDATA, the function might assign meaningful + /// values to only some of the members of the WIN32_FIND_DATA structure. The remaining members will be set to zero. To retrieve + /// complete current information on a file system file or folder, use standard file system functions such as GetFileTime or FindFirstFile. /// - /// E_INVALIDARG is returned if the psf, pidl, pv, or cb parameter does not match the nFormat parameter, or if nFormat is not one of the specific - /// SHGDFIL_ values shown above. + /// E_INVALIDARG is returned if the psf, pidl, pv, or cb parameter does not match the nFormat parameter, or if nFormat is not one of + /// the specific SHGDFIL_ values shown above. /// /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] @@ -2105,8 +3410,8 @@ namespace Vanara.PInvoke /// Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace. /// - /// When this method returns, receives an IShellFolder interface pointer for the desktop folder. The calling application is responsible for eventually - /// freeing the interface by calling its IUnknown::Release method. + /// When this method returns, receives an IShellFolder interface pointer for the desktop folder. The calling application is + /// responsible for eventually freeing the interface by calling its IUnknown::Release method. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] @@ -2120,20 +3425,22 @@ namespace Vanara.PInvoke /// A CSIDL value that identifies the folder to be located. The folders associated with the CSIDLs might not exist on a particular system. /// /// - /// An access token that can be used to represent a particular user. It is usually set to NULL, but it may be needed when there are multiple users for - /// those folders that are treated as belonging to a single user. The most commonly used folder of this type is My Documents. The calling application is - /// responsible for correct impersonation when hToken is non-NULL. It must have appropriate security privileges for the particular user, and the user's - /// registry hive must be currently mounted. + /// An access token that can be used to represent a particular user. It is usually set to NULL, but it may be needed when there are + /// multiple users for those folders that are treated as belonging to a single user. The most commonly used folder of this type is My + /// Documents. The calling application is responsible for correct impersonation when hToken is non-NULL. It must have appropriate + /// security privileges for the particular user, and the user's registry hive must be currently mounted. /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetFolderLocation to find folder locations (such as - /// the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as My Documents and Desktop. Any items added to the Default User folder also appear in any new user account. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetFolderLocation to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as My Documents and Desktop. Any items added to the Default User folder + /// also appear in any new user account. /// /// /// Reserved. /// - /// The address of a pointer to an item identifier list structure that specifies the folder's location relative to the root of the namespace (the - /// desktop). The ppidl parameter is set to NULL on failure. The calling application is responsible for freeing this resource by calling CoTaskMemFree. + /// The address of a pointer to an item identifier list structure that specifies the folder's location relative to the root of the + /// namespace (the desktop). The ppidl parameter is set to NULL on failure. The calling application is responsible for freeing this + /// resource by calling CoTaskMemFree. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762180")] @@ -2141,51 +3448,54 @@ namespace Vanara.PInvoke int dwReserved, out PIDL ppidl); /// - /// Deprecated. Gets the path of a folder identified by a CSIDL value. As of Windows Vista, this function is merely a wrapper for - /// SHGetKnownFolderPath. The CSIDL value is translated to its associated KNOWNFOLDERID and then SHGetKnownFolderPath is called. New applications should - /// use the known folder system rather than the older CSIDL system, which is supported only for backward compatibility. + /// Deprecated. Gets the path of a folder identified by a CSIDL value. As of Windows Vista, this function is merely a wrapper + /// for SHGetKnownFolderPath. The CSIDL value is translated to its associated KNOWNFOLDERID and then SHGetKnownFolderPath is called. + /// New applications should use the known folder system rather than the older CSIDL system, which is supported only for backward compatibility. /// /// Reserved. /// - /// A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is specified, this function - /// fails. You can force creation of a folder by combining the folder's CSIDL with CSIDL_FLAG_CREATE. + /// A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is + /// specified, this function fails. You can force creation of a folder by combining the folder's CSIDL with CSIDL_FLAG_CREATE. /// /// - /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder - /// for the current user. + /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function + /// requests the known folder for the current user. /// - /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient - /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also - /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access - /// Control for further discussion of access control issues. + /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has + /// sufficient privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE + /// rights. In some cases, you also need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of + /// that specific user must be mounted. See Access Control for further discussion of access control issues. /// /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. /// /// /// - /// Flags that specify the path to be returned. This value is used in cases where the folder associated with a KNOWNFOLDERID (or CSIDL) can be moved, - /// renamed, redirected, or roamed across languages by a user or administrator. + /// Flags that specify the path to be returned. This value is used in cases where the folder associated with a KNOWNFOLDERID (or + /// CSIDL) can be moved, renamed, redirected, or roamed across languages by a user or administrator. /// - /// The known folder system that underlies SHGetFolderPath allows users or administrators to redirect a known folder to a location that suits their - /// needs. This is achieved by calling IKnownFolderManager::Redirect, which sets the "current" value of the folder associated with the SHGFP_TYPE_CURRENT flag. + /// The known folder system that underlies SHGetFolderPath allows users or administrators to redirect a known folder to a location + /// that suits their needs. This is achieved by calling IKnownFolderManager::Redirect, which sets the "current" value of the folder + /// associated with the SHGFP_TYPE_CURRENT flag. /// /// - /// The default value of the folder, which is the location of the folder if a user or administrator had not redirected it elsewhere, is retrieved by - /// specifying the SHGFP_TYPE_DEFAULT flag. This value can be used to implement a "restore defaults" feature for a known folder. + /// The default value of the folder, which is the location of the folder if a user or administrator had not redirected it elsewhere, + /// is retrieved by specifying the SHGFP_TYPE_DEFAULT flag. This value can be used to implement a "restore defaults" feature for a + /// known folder. /// /// - /// For example, the default value (SHGFP_TYPE_DEFAULT) for FOLDERID_Music (CSIDL_MYMUSIC) is "C:\Users\user name\Music". If the folder was redirected, - /// the current value (SHGFP_TYPE_CURRENT) might be "D:\Music". If the folder has not been redirected, then SHGFP_TYPE_DEFAULT and SHGFP_TYPE_CURRENT - /// retrieve the same path. + /// For example, the default value (SHGFP_TYPE_DEFAULT) for FOLDERID_Music (CSIDL_MYMUSIC) is "C:\Users\user name\Music". If the + /// folder was redirected, the current value (SHGFP_TYPE_CURRENT) might be "D:\Music". If the folder has not been redirected, then + /// SHGFP_TYPE_DEFAULT and SHGFP_TYPE_CURRENT retrieve the same path. /// /// /// - /// A pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, this string will be - /// empty. The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\". + /// A pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, + /// this string will be empty. The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather + /// than "C:\Users\". /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [SecurityCritical, SuppressUnmanagedCodeSecurity] @@ -2194,30 +3504,91 @@ namespace Vanara.PInvoke SHGFP dwFlags, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath); /// - /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This extends SHGetKnownFolderPath by allowing you to set the - /// initial size of the string buffer. + /// Gets the path of a folder and appends a user-provided subfolder path. /// - /// A reference to the KNOWNFOLDERID that identifies the folder. - /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. - /// - /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder - /// for the current user. + /// + /// Type: HWND + /// Reserved. + /// + /// + /// Type: int /// - /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient - /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also - /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access - /// Control for further discussion of access control issues. + /// A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is + /// specified, this function fails. You can force creation of a folder with SHGetFolderPathAndSubDir by combining the folder's + /// CSIDL with CSIDL_FLAG_CREATE. /// + /// + /// + /// Type: HANDLE /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// An access token that represents a particular user. For systems earlier than Windows 2000, set this value to NULL. For + /// later systems, is usually, but not always, set to NULL. You might need to assign a value to for those folders that can + /// have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is My Documents. + /// + /// + /// + /// Type: DWORD + /// + /// Specifies whether the path to be returned is the actual path of the folder or the default path. This value is used in cases where + /// the folder associated with a CSIDL value may be moved or renamed by the user. + /// + /// SHGFP_TYPE_CURRENT + /// Return the folder's current path. + /// SHGFP_TYPE_DEFAULT + /// Return the folder's default path. + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to the subpath to be appended to the folder's path. This is a null-terminated string of length MAX_PATH. If you + /// are not creating a new directory, this must be an existing subdirectory or the function returns an error. This value can be + /// NULL if no subpath is to be appended. /// /// /// - /// A null-terminated, Unicode string. This buffer must be of size cchPath. When SHGetFolderPathEx returns successfully, this parameter contains the path - /// for the known folder. + /// Type: LPTSTR + /// + /// When this function returns, this value points to the directory path and appended subpath. This is a null-terminated string + /// of length MAX_PATH. This string is empty when the function returns an error code. + /// + /// + /// + /// Type: HRESULT + /// If 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-shgetfolderpathandsubdira HRESULT + // 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); + + /// + /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This extends SHGetKnownFolderPath by allowing + /// you to set the initial size of the string buffer. + /// + /// A reference to the KNOWNFOLDERID that identifies the folder. + /// + /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// + /// + /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function + /// requests the known folder for the current user. + /// + /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has + /// sufficient privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE + /// rights. In some cases, you also need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of + /// that specific user must be mounted. See Access Control for further discussion of access control issues. + /// + /// + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. + /// + /// + /// + /// A null-terminated, Unicode string. This buffer must be of size cchPath. When SHGetFolderPathEx returns successfully, this + /// parameter contains the path for the known folder. /// /// The size of the ppszPath buffer, in characters. [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] @@ -2227,6 +3598,56 @@ namespace Vanara.PInvoke Guid rfid, KNOWN_FOLDER_FLAG dwFlags, [In, Optional] SafeTokenHandle hToken, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, uint cchPath); + /// + /// Returns the index of the overlay icon in the system image list. + /// + /// + /// Type: LPCTSTR + /// + /// A pointer to a null-terminated string of maximum length MAX_PATH that contains the fully qualified path of the file that + /// contains the icon. + /// + /// + /// + /// Type: int + /// + /// The icon's index in the file pointed to by . To request a standard overlay icon, set to NULL, and to one of the following: + /// + /// IDO_SHGIOI_SHARE (0x0FFFFFFF) + /// The overlay icon that indicates a shared folder. + /// IDO_SHGIOI_LINK (0x0FFFFFFE) + /// The overlay icon that indicates a linked folder or file. + /// IDO_SHGIOI_SLOWFILE (0x0FFFFFFD) + /// The overlay icon that indicates a slow file. + /// IDO_SHGIOI_DEFAULT (0x0FFFFFFC) + /// + /// Windows 7 and later. The overlay icon that indicates that the item is the default in a set. One example is the default printer. + /// + /// + /// + /// Type: int + /// Returns the index of the overlay icon in the system image list if successful, or -1 otherwise. + /// + /// + /// + /// Icon overlays are part of the system image list. They have two identifiers. The first is a one-based overlay index that + /// identifies the overlay relative to other overlays in the image list. The other is an image index that identifies the actual + /// image. These two indexes are equivalent to the values that you assign to the and parameters, respectively, when you add an icon + /// overlay to a private image list with ImageList_SetOverlayImage. SHGetIconOverlayIndex returns the overlay index. To + /// convert an overlay index to its equivalent image index, call INDEXTOOVERLAYMASK. + /// + /// + /// Note After the image has been loaded into the system image list during initialization, it cannot be changed. The file name + /// and index specified by and are used only to identify the icon overlay. SHGetIconOverlayIndex cannot be used to modify the + /// system image list. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgeticonoverlayindexa int SHGetIconOverlayIndexA( + // LPCSTR pszIconPath, int iIconIndex ); + [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] + [PInvokeData("shlobj_core.h", MSDNShortId = "20001ae0-05d0-46a7-8bb8-9bb722f5d795")] + public static extern int SHGetIconOverlayIndex(string pszIconPath, int iIconIndex); + /// Retrieves the pointer to an item identifier list (PIDL) of an object. /// A pointer to the IUnknown of the object from which to get the PIDL. /// When this function returns, contains a pointer to the PIDL of the given object. @@ -2244,32 +3665,81 @@ namespace Vanara.PInvoke public static extern HRESULT SHGetImageList(SHIL iImageList, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IImageList ppv); + /// + /// + /// Retrieves an interface that allows hosted Shell extensions and other components to prevent their host process from closing + /// prematurely. The host process is typically Windows Explorer or Windows Internet Explorer, but this function can also be used by + /// other applications. + /// + /// + /// + /// Type: IUnknown** + /// + /// When this function returns successfully, contains the address of the host process' IUnknown interface pointer. This is a + /// free-threaded interface used to prevent the host process from terminating. If the function call fails, this value is set to NULL. + /// + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// + /// There are a number of components, such as Shell extension handlers, that are implemented as DLLs and run in a host process such + /// as Windows Explorer (Explorer.exe) or Internet Explorer (Iexplore.exe). Typically, when the user closes the host process, the + /// component is shut down immediately as well. Such an abrupt termination can create problems for some components. For example, if a + /// component is using a background thread to download data or run user-interface functions, it might need additional time to safely + /// shut itself down. + /// + /// + /// SHGetInstanceExplorer allows components that run in a host process to hold a reference on the host process. + /// SHGetInstanceExplorer increments the host's reference count and returns a pointer to the host's IUnknown interface. By + /// holding that reference, a component can prevent the host process from closing prematurely. After the component has completed its + /// necessary processing, it should call (*ppunk)->Release to release the host's reference and allow the process to terminate. + /// + /// + /// Note If SHGetInstanceExplorer is successful, the component must release the host's reference when it is no longer + /// needed. Otherwise, all resources associated with the process will remain in memory. The IUnknown interface pointed to by * can + /// only be used to release this reference. Components cannot use (*ppunk)->QueryInterface to request other interface pointers. + /// + /// SHGetInstanceExplorer + /// succeeds only if it is called from from an application which had previously called + /// SHSetInstanceExplorer + /// to set a process reference. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetinstanceexplorer SHSTDAPI + // SHGetInstanceExplorer( IUnknown **ppunk ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "ac6d8f7d-2eae-4b22-b493-b4ef740e3c95")] + public static extern HRESULT SHGetInstanceExplorer([MarshalAs(UnmanagedType.IUnknown)] out object ppunk); + /// Retrieves the path of a known folder as an ITEMIDLIST structure. /// - /// A reference to the KNOWNFOLDERID that identifies the folder. The folders associated with the known folder IDs might not exist on a particular system. + /// A reference to the KNOWNFOLDERID that identifies the folder. The folders associated with the known folder IDs might not exist on + /// a particular system. /// /// /// Flags that specify special retrieval options. This value can be 0; otherwise, it is one or more of the KNOWN_FOLDER_FLAG values. /// /// - /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to access the current - /// user's instance of the folder. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as - /// belonging to a single user. The most commonly used folder of this type is Documents. + /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to + /// access the current user's instance of the folder. However, you may need to assign a value to hToken for those folders that can + /// have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is Documents. /// - /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security privileges for the - /// particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further - /// discussion of access control issues. + /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security + /// privileges for the particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently + /// mounted. See Access Control for further discussion of access control issues. /// /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. /// /// /// - /// When this method returns, contains a pointer to the PIDL of the folder. This parameter is passed uninitialized. The caller is responsible for freeing - /// the returned PIDL when it is no longer needed by calling ILFree. + /// When this method returns, contains a pointer to the PIDL of the folder. This parameter is passed uninitialized. The caller is + /// responsible for freeing the returned PIDL when it is no longer needed by calling ILFree. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762187")] @@ -2279,23 +3749,23 @@ namespace Vanara.PInvoke /// Retrieves an IShellItem object that represents a known folder. /// A reference to the KNOWNFOLDERID, a GUID that identifies the folder that contains the item. /// - /// Flags that specify special options used in the retrieval of the known folder IShellItem. This value can be KF_FLAG_DEFAULT; otherwise, one or more of - /// the KNOWN_FOLDER_FLAG values. + /// Flags that specify special options used in the retrieval of the known folder IShellItem. This value can be KF_FLAG_DEFAULT; + /// otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// - /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to access the current - /// user's instance of the folder. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as - /// belonging to a single user. The most commonly used folder of this type is Documents. + /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to + /// access the current user's instance of the folder. However, you may need to assign a value to hToken for those folders that can + /// have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is Documents. /// - /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security privileges for the - /// particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further - /// discussion of access control issues. + /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security + /// privileges for the particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently + /// mounted. See Access Control for further discussion of access control issues. /// /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. /// /// /// A reference to the IID of the interface that represents the item, usually IID_IShellItem or IID_IShellItem2. @@ -2309,27 +3779,29 @@ namespace Vanara.PInvoke /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. /// A reference to the KNOWNFOLDERID that identifies the folder. - /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// + /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// /// - /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder - /// for the current user. + /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function + /// requests the known folder for the current user. /// - /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient - /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also - /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access - /// Control for further discussion of access control issues. + /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has + /// sufficient privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE + /// rights. In some cases, you also need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of + /// that specific user must be mounted. See Access Control for further discussion of access control issues. /// /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. /// /// /// - /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder. The - /// calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree. The returned path does not include a - /// trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\". + /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the + /// known folder. The calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree. + /// The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\". /// /// Returns S_OK if successful, or an error value otherwise. /// This function replaces SHGetFolderPath. That older function is now simply a wrapper for SHGetKnownFolderPath. @@ -2340,21 +3812,23 @@ namespace Vanara.PInvoke /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. /// A reference to the KNOWNFOLDERID that identifies the folder. - /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// + /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. + /// /// - /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder - /// for the current user. + /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function + /// requests the known folder for the current user. /// - /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient - /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also - /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access - /// Control for further discussion of access control issues. + /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has + /// sufficient privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE + /// rights. In some cases, you also need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of + /// that specific user must be mounted. See Access Control for further discussion of access control issues. /// /// - /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such - /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special - /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the - /// Default User folders requires administrator privileges. + /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find + /// folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user + /// account is created, and includes special folders such as Documents and Desktop. Any items added to the Default User folder also + /// appear in any new user account. Note that access to the Default User folders requires administrator privileges. /// /// /// String that specifies the path of the known folder. @@ -2369,7 +3843,9 @@ namespace Vanara.PInvoke /// Retrieves the display name of an item identified by its IDList. /// A PIDL that identifies the item. /// A value from the SIGDN enumeration that specifies the type of display name to retrieve. - /// A value that, when this function returns successfully, receives the address of a pointer to the retrieved display name. + /// + /// A value that, when this function returns successfully, receives the address of a pointer to the retrieved display name. + /// [DllImport(Lib.Shell32, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762191")] public static extern HRESULT SHGetNameFromIDList(PIDL pidl, SIGDN sigdnName, out SafeCoTaskMemHandle ppszName); @@ -2378,43 +3854,445 @@ namespace Vanara.PInvoke /// /// The address of an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop). /// - /// The address of a buffer to receive the file system path. This buffer must be at least MAX_PATH characters in size. + /// + /// The address of a buffer to receive the file system path. This buffer must be at least MAX_PATH characters in size. + /// /// Returns TRUE if successful; otherwise, FALSE. [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762194")] public static extern bool SHGetPathFromIDList(PIDL pidl, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszPath); + /// + /// + /// Converts an item identifier list to a file system path. This function extends SHGetPathFromIDList by allowing you to set the + /// initial size of the string buffer and declare the options below. + /// + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// + /// A pointer to an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop). + /// + /// + /// + /// Type: PWSTR + /// + /// When this function is called it is passed a null-terminated, Unicode buffer to receive the file system path. This buffer is of + /// size . + /// + /// + /// When this function returns, contains the address of a null-terminated, Unicode buffer that contains the file system path. This + /// buffer is of size . + /// + /// + /// + /// Type: DWORD + /// The size of the buffer pointed to by , in characters. + /// + /// + /// Type: GPFIDL_FLAGS + /// These flags determine the type of path returned. + /// GPFIDL_DEFAULT (0x0000) + /// Win32 file names, servers, and root drives are included. + /// GPFIDL_ALTNAME (0x0001) + /// Uses short file names. + /// GPFIDL_UNCPRINTER (0x0002) + /// Include UNC printer names items. + /// + /// + /// Type: BOOL + /// Returns TRUE if successful; otherwise, FALSE. + /// + /// + /// + /// Except for UNC printer names, if the location specified by the parameter is not part of the file system, this function fails. + /// + /// If the parameter specifies a shortcut, the contains the path to the shortcut, not to the shortcut's target. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetpathfromidlistex BOOL SHGetPathFromIDListEx( + // PCIDLIST_ABSOLUTE pidl, PWSTR pszPath, DWORD cchPath, GPFIDL_FLAGS uOpts ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "80270c59-275d-4b13-b16c-0c07bb79ed8e")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHGetPathFromIDListEx(PIDL pidl, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, uint cchPath, GPFIDL_FLAGS uOpts); + + /// + /// + /// [SHGetRealIDL is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Converts a simple pointer to an item identifier list (PIDL) into a full PIDL. + /// + /// + /// Type: IShellFolder* + /// A pointer to an instance of IShellFolder whose simple PIDL is to be converted. + /// + /// + /// Type: PCUITEMID_CHILD + /// The simple PIDL to be converted. + /// + /// + /// Type: PITEMID_CHILD* + /// + /// When this method returns, contains a pointer to the full converted PIDL. If the function fails, this parameter is set to NULL. + /// + /// + /// + /// Type: HRESULT + /// If 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-shgetrealidl SHSTDAPI SHGetRealIDL( IShellFolder + // *psf, PCUITEMID_CHILD pidlSimple, PITEMID_CHILD *ppidlReal ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "0c0b63c9-7ca7-4f73-be74-9c492f8506fc")] + public static extern HRESULT SHGetRealIDL(IShellFolder psf, PIDL pidlSimple, out IntPtr ppidlReal); + + /// + /// + /// [SHGetSetFolderCustomSettings is available for use in the operating systems specified in the Requirements section. It may be + /// altered or unavailable in subsequent versions.] + /// + /// Sets or retrieves custom folder settings. This function reads from and writes to Desktop.ini. + /// + /// + /// Type: LPSHFOLDERCUSTOMSETTINGS + /// A pointer to a SHFOLDERCUSTOMSETTINGS structure that provides or receives the custom folder settings. + /// + /// + /// Type: PCTSTR + /// + /// A pointer to a null-terminated Unicode string that contains the path to the folder. The length of pszPath must be MAX_PATH + /// or less, including the terminating null character. + /// + /// + /// + /// Type: DWORD + /// A flag that controls the action of the function. It may be one of the following values. + /// FCS_READ (0x00000001) + /// Retrieve the custom folder settings in . + /// FCS_FORCEWRITE (0x00000002) + /// Use to set the custom folder's settings regardless of whether the values are already present. + /// FCS_WRITE (FCS_READ | FCS_FORCEWRITE) + /// Use to set the custom folder's settings if the values are not already present. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// Only Unicode strings are supported. + /// Windows Server 2003 and Windows XP:SHGetSetFolderCustomSettings supports both ANSI and Unicode strings. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetsetfoldercustomsettings SHSTDAPI + // SHGetSetFolderCustomSettings( LPSHFOLDERCUSTOMSETTINGS pfcs, PCWSTR pszPath, DWORD dwReadWrite ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("shlobj_core.h", MSDNShortId = "38b78a4b-ba68-4dff-812d-d4c7421eb202")] + public static extern HRESULT SHGetSetFolderCustomSettings(ref SHFOLDERCUSTOMSETTINGS pfcs, [MarshalAs(UnmanagedType.LPWStr)] string pszPath, FCS dwReadWrite); + + /// + /// + /// [SHGetSetSettings is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Sets or retrieves Shell state settings. + /// + /// + /// Type: LPSHELLSTATE + /// A pointer to a SHELLSTATE structure that provides or receives the Shell state settings. + /// + /// + /// Type: DWORD + /// One or more of the SSF flags that indicate which settings should be set or retrieved. + /// + /// + /// Type: BOOL + /// + /// TRUE to indicate that the contents of should be used to set the Shell settings, FALSE to indicate that the Shell + /// settings should be retrieved to . + /// + /// + /// + /// This function does not return a value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetsetsettings void SHGetSetSettings( + // LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "d7c2646c-03e0-4d7a-9503-bdf487d43723")] + public static extern void SHGetSetSettings(ref SHELLSTATE lpss, SSF dwMask, [MarshalAs(UnmanagedType.Bool)] bool bSet); + + /// + /// Retrieves the current Shell option settings. + /// + /// + /// TBD + /// + /// + /// Type: DWORD + /// A set of flags that determine which members of are being requested. This can be one or more of the following values. + /// SSF_DESKTOPHTML + /// The fDesktopHTML member is being requested. + /// SSF_DONTPRETTYPATH + /// The fDontPrettyPath member is being requested. + /// SSF_DOUBLECLICKINWEBVIEW + /// The fDoubleClickInWebView member is being requested. + /// SSF_HIDEICONS + /// The fHideIcons member is being requested. + /// SSF_MAPNETDRVBUTTON + /// The fMapNetDrvBtn member is being requested. + /// SSF_NOCONFIRMRECYCLE + /// The fNoConfirmRecycle member is being requested. + /// SSF_SHOWALLOBJECTS + /// The fShowAllObjects member is being requested. + /// SSF_SHOWATTRIBCOL + /// The fShowAttribCol member is being requested. + /// Windows Vista: Not used. + /// SSF_SHOWCOMPCOLOR + /// The fShowCompColor member is being requested. + /// SSF_SHOWEXTENSIONS + /// The fShowExtensions member is being requested. + /// SSF_SHOWINFOTIP + /// The fShowInfoTip member is being requested. + /// SSF_SHOWSYSFILES + /// The fShowSysFiles member is being requested. + /// SSF_WIN95CLASSIC + /// The fWin95Classic member is being requested. + /// + /// + /// This function does not return a value. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shgetsettings void SHGetSettings( SHELLFLAGSTATE + // *psfs, DWORD dwMask ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "728a4004-f35d-4592-baf1-456a613a3344")] + public static extern void SHGetSettings(ref SHELLFLAGSTATE psfs, SSF dwMask); + + /// + /// + /// [SHHandleUpdateImage is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Handles the SHCNE_UPDATEIMAGE Shell change notification. + /// + /// + /// Type: PCIDLIST_ABSOLUTE + /// The index in the system image list that has changed, specified in the parameter of IShellChangeNotify::OnChange. + /// + /// + /// Type: int + /// Returns -1 on failure or the index of the changed image list entry on success. + /// + /// + /// Use SHHandleUpdateImage only when the parameter received by your change notification callback is non- NULL. + /// Examples + /// The following example demonstrates the use of SHHandleUpdateImage in the implementation of IShellChangeNotify::OnChange. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shhandleupdateimage int SHHandleUpdateImage( + // PCIDLIST_ABSOLUTE pidlExtra ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "9d43e28a-bce0-4da4-98c9-5a6a199b4d8e")] + public static extern int SHHandleUpdateImage(PIDL pidlExtra); + + /// + /// + /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable + /// in subsequent versions of Windows.] + /// + /// Sets limits on valid characters for an edit control. + /// + /// + /// Type: HWND + /// The handle of the edit control. + /// + /// + /// Type: IShellFolder* + /// + /// An IShellFolder interface pointer. This object must also implement IItemNameLimits, which supplies a list of invalid characters + /// and a maximum name length. + /// + /// + /// + /// Type: HRESULT + /// If 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-shlimitinputedit SHSTDAPI SHLimitInputEdit( HWND + // hwndEdit, IShellFolder *psf ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "3f03374f-8dfe-4b80-9ecc-12c6548f2865")] + public static extern HRESULT SHLimitInputEdit(HandleRef hwndEdit, IShellFolder psf); + + /// + /// Creates an instance of the specified object class from within the context of the Shell's process. + /// Windows Vista and later: This function has been disabled and returns E_NOTIMPL. + /// + /// + /// Type: REFCLSID + /// The CLSID of the object class to be created. + /// + /// + /// Type: HRESULT + /// Returns S_OK if successful, or an error value otherwise. In Windows Vista and later versions, always returns E_NOTIMPL. + /// + /// + /// + /// Note This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It is not available in + /// later versions of Windows, including Windows Vista. + /// + /// + /// This function creates the requested object instance by calling the CoCreateInstance function and immediately releasing the + /// returned object. The associated DLL is unloaded according to standard Component Object Model (COM) rules when it returns S_OK + /// from its DllCanUnloadNow function. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shloadinproc SHSTDAPI SHLoadInProc( REFCLSID + // rclsid ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj_core.h", MSDNShortId = "307b99d9-2d0a-47c5-8a10-dfdc0a408942")] + public static extern HRESULT SHLoadInProc([MarshalAs(UnmanagedType.LPStruct)] Guid rclsid); + + /// + /// + /// [ SHMapPIDLToSystemImageListIndex is available for use in the operating systems specified in the Requirements section. It + /// may be altered or unavailable in subsequent versions.] + /// + /// Retrieves the icon index from the system image list that is associated with a folder item. + /// + /// + /// Type: IShellFolder* + /// An IShellFolder interface pointer for the folder that contains the item. + /// + /// + /// Type: PCUITEMID_CHILD + /// A pointer to the item's ITEMIDLIST structure. + /// + /// + /// Type: int* + /// + /// A pointer to an int that, when this function returns successfully, receives the index of the item's open icon in + /// the system image list. If the item does not have a special open icon then the index of its normal icon is returned. If the + /// open icon exists and cannot be obtained, then the value pointed to by piIndex is set to -1. This parameter can be + /// NULL if the calling application is not interested in the open icon. + /// + /// + /// + /// Type: int + /// Returns the index of the item's normal icon in the system image list if successful, or -1 otherwise. + /// + // int SHMapPIDLToSystemImageListIndex( _In_ IShellFolder *psf, _In_ PCUITEMID_CHILD pidl, _Out_opt_ int *piIndex); https://msdn.microsoft.com/en-us/library/windows/desktop/bb762219(v=vs.85).aspx + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("Shlobj_core.h", MSDNShortId = "bb762219")] + public static extern int SHMapPIDLToSystemImageListIndex(IShellFolder psf, PIDL pidl, out int piIndex); + + /// + /// + /// Displays a merged property sheet for a set of files. Property values common to all the files are shown while those that differ + /// display the string (multiple values). + /// + /// + /// + /// Type: IDataObject* + /// + /// A pointer to a data object that supplies the PIDLs of all of the files for which to display the merged property sheet. The data + /// object must use the CFSTR_SHELLIDLIST clipboard format. The parent folder's implementation of IShellFolder::GetDisplayNameOf must + /// return a fully qualified file system path for each item in response to the SHGDN_FORPARSING flag. + /// + /// + /// + /// Type: DWORD + /// Reserved. Must be set to 0. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-shmultifileproperties SHSTDAPI SHMultiFileProperties( + // IDataObject *pdtobj, DWORD dwFlags ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] + [PInvokeData("shlobj.h", MSDNShortId = "7c66fd91-4f7a-45f3-b849-bf210c552511")] + public static extern HRESULT SHMultiFileProperties(IDataObject pdtobj, uint dwFlags = 0); + + /// + /// + /// [SHObjectProperties is available for use in the operating systems specified in the Requirements section. It may be altered or + /// unavailable in subsequent versions.] + /// + /// Invokes the Properties context menu command on a Shell object. + /// + /// + /// Type: HWND + /// The handle of the parent window of the dialog box. This value can be NULL. + /// + /// + /// Type: DWORD + /// A flag value that specifies the type of object. + /// SHOP_PRINTERNAME + /// contains the friendly name of a printer. + /// SHOP_FILEPATH + /// contains a fully qualified file name. + /// SHOP_VOLUMEGUID + /// + /// contains either (a) a volume name of the form \?\Volume{GUID}, where {GUID} is a globally unique identifier (for example, + /// "\?\Volume{2eca078d-5cbc-43d3-aff8-7e8511f60d0e})", or (b) a drive path (for example, "C:"). + /// + /// + /// + /// Type: PCWSTR + /// + /// A null-terminated Unicode string that contains the object name. The contents of the string are determined by the flag set in . + /// + /// + /// + /// Type: PCWSTR + /// + /// A null-terminated Unicode string that contains the name of the property sheet page to be opened initially. Set this parameter to + /// NULL to specify the default page. + /// + /// + /// + /// Type: BOOL + /// TRUE if the command is successfully invoked; otherwise, FALSE. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shobjectproperties BOOL SHObjectProperties( HWND + // hwnd, DWORD shopObjectType, PCWSTR pszObjectName, PCWSTR pszPropertyPage ); + [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] + [PInvokeData("shlobj_core.h", MSDNShortId = "7517c461-955b-446e-85d7-a707c9bd183a")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool SHObjectProperties(HandleRef hwnd, SHOP shopObjectType, string pszObjectName, string pszPropertyPage); + /// Opens a Windows Explorer window with specified items in a particular folder selected. /// A pointer to a fully qualified item ID list that specifies the folder. /// - /// A count of items in the selection array, apidl. If cidl is zero, then pidlFolder must point to a fully specified ITEMIDLIST describing a single item - /// to select. This function opens the parent folder and selects that item. + /// A count of items in the selection array, apidl. If cidl is zero, then pidlFolder must point to a fully specified ITEMIDLIST + /// describing a single item to select. This function opens the parent folder and selects that item. + /// + /// + /// A pointer to an array of PIDL structures, each of which is an item to select in the target folder referenced by pidlFolder. + /// + /// + /// The optional flags. Under Windows XP this parameter is ignored. In Windows Vista, the following flags are defined. /// - /// A pointer to an array of PIDL structures, each of which is an item to select in the target folder referenced by pidlFolder. - /// The optional flags. Under Windows XP this parameter is ignored. In Windows Vista, the following flags are defined. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762232")] public static extern HRESULT SHOpenFolderAndSelectItems(PIDL pidlFolder, uint cidl, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr[] apidl, OFASI dwFlags); /// - /// Translates a Shell namespace object's display name into an item identifier list and returns the attributes of the object. This function is the - /// preferred method to convert a string to a pointer to an item identifier list (PIDL). + /// Translates a Shell namespace object's display name into an item identifier list and returns the attributes of the object. This + /// function is the preferred method to convert a string to a pointer to an item identifier list (PIDL). /// /// A pointer to a zero-terminated wide string that contains the display name to parse. /// A bind context that controls the parsing operation. This parameter is normally set to NULL. /// - /// The address of a pointer to a variable of type ITEMIDLIST that receives the item identifier list for the object. If an error occurs, then this - /// parameter is set to NULL. + /// The address of a pointer to a variable of type ITEMIDLIST that receives the item identifier list for the object. If an error + /// occurs, then this parameter is set to NULL. /// /// - /// A ULONG value that specifies the attributes to query. To query for one or more attributes, initialize this parameter with the flags that represent - /// the attributes of interest. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. + /// A ULONG value that specifies the attributes to query. To query for one or more attributes, initialize this parameter with the + /// flags that represent the attributes of interest. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. /// /// - /// A pointer to a ULONG. On return, those attributes that are true for the object and were requested in sfgaoIn are set. An object's attribute flags can - /// be zero or a combination of SFGAO flags. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. + /// A pointer to a ULONG. On return, those attributes that are true for the object and were requested in sfgaoIn are set. An object's + /// attribute flags can be zero or a combination of SFGAO flags. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762236")] @@ -2431,42 +4309,111 @@ namespace Vanara.PInvoke /// and WriteCabinetState functions. /// /// - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-cabinetstate - // typedef struct CABINETSTATE { WORD cLength; WORD nVersion; BOOL fFullPathTitle : 1; BOOL fSaveLocalView : 1; BOOL fNotShell : 1; BOOL fSimpleDefault : 1; BOOL fDontShowDescBar : 1; BOOL fNewWindowMode : 1; BOOL fShowCompColor : 1; BOOL fDontPrettyNames : 1; BOOL fAdminsCreateCommonGroups : 1; UINT fUnusedFlags : 7; UINT fMenuEnumFilter; } *LPCABINETSTATE; + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-cabinetstate typedef struct CABINETSTATE { WORD + // cLength; WORD nVersion; BOOL fFullPathTitle : 1; BOOL fSaveLocalView : 1; BOOL fNotShell : 1; BOOL fSimpleDefault : 1; BOOL + // fDontShowDescBar : 1; BOOL fNewWindowMode : 1; BOOL fShowCompColor : 1; BOOL fDontPrettyNames : 1; BOOL fAdminsCreateCommonGroups + // : 1; UINT fUnusedFlags : 7; UINT fMenuEnumFilter; } *LPCABINETSTATE; [PInvokeData("shlobj_core.h", MSDNShortId = "4b82b6a8-c4c0-4af2-9612-0551376c1c62")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct CABINETSTATE { - /// Type: WORDThe size of the structure, in bytes. + /// + /// Type: WORD + /// The size of the structure, in bytes. + /// public ushort cLength; - /// Type: WORD + + /// + /// Type: WORD + /// public ushort nVersion; + private ushort fFlags; - /// Type: UINTOne or both of the following flags.SHCONTF_FOLDERSDisplay folders.SHCONTF_NONFOLDERSDisplay non-folder items. + + /// + /// Type: UINT + /// One or both of the following flags. + /// SHCONTF_FOLDERS + /// Display folders. + /// SHCONTF_NONFOLDERS + /// Display non-folder items. + /// public SHCONTF fMenuEnumFilter; - /// Type: BOOLTRUEDisplay the full path in the title bar.FALSEDisplay only the file name in the title bar. - public bool fFullPathTitle { get => (fFlags & 1 << 0) != 0; set { if (value) fFlags |= 1 << 0; else { int i = fFlags; i &= ~(1 << 0); fFlags = (ushort)i; } } } - /// Type: BOOLTRUERemember each folder's view settings.FALSEUse global settings for all folders. - public bool fSaveLocalView { get => (fFlags & 1 << 1) != 0; set { if (value) fFlags |= 1 << 1; else { int i = fFlags; i &= ~(1 << 1); fFlags = (ushort)i; } } } - /// Type: BOOLNot used. - public bool fNotShell { get => (fFlags & 1 << 2) != 0; set { if (value) fFlags |= 1 << 2; else { int i = fFlags; i &= ~(1 << 2); fFlags = (ushort)i; } } } - /// Type: BOOLNot used. - public bool fSimpleDefault { get => (fFlags & 1 << 3) != 0; set { if (value) fFlags |= 1 << 3; else { int i = fFlags; i &= ~(1 << 3); fFlags = (ushort)i; } } } - /// Type: BOOLNot used. - public bool fDontShowDescBar { get => (fFlags & 1 << 4) != 0; set { if (value) fFlags |= 1 << 4; else { int i = fFlags; i &= ~(1 << 4); fFlags = (ushort)i; } } } - /// Type: BOOLTRUEDisplay in a new window.FALSEDisplay in the current window. - public bool fNewWindowMode { get => (fFlags & 1 << 5) != 0; set { if (value) fFlags |= 1 << 5; else { int i = fFlags; i &= ~(1 << 5); fFlags = (ushort)i; } } } - /// Type: BOOLTRUEShow encrypted or compressed NTFS files in color.FALSEDo not show encrypted or compressed NTFS files in color. - public bool fShowCompColor { get => (fFlags & 1 << 6) != 0; set { if (value) fFlags |= 1 << 6; else { int i = fFlags; i &= ~(1 << 6); fFlags = (ushort)i; } } } - /// Type: BOOLNot used. - public bool fDontPrettyNames { get => (fFlags & 1 << 7) != 0; set { if (value) fFlags |= 1 << 7; else { int i = fFlags; i &= ~(1 << 7); fFlags = (ushort)i; } } } - /// Type: BOOLUsed when an administrator installs an application that places an icon in the Start menu.TRUEAdd the icon to the Start menu for all users (CSIDL_COMMON_STARTMENU). This is the default value.FALSEAdd the icon to only the current user (CSIDL_STARTMENU). - public bool fAdminsCreateCommonGroups { get => (fFlags & 1 << 8) != 0; set { if (value) fFlags |= 1 << 8; else { int i = fFlags; i &= ~(1 << 8); fFlags = (ushort)i; } } } + /// + /// Type: BOOL + /// TRUE + /// Display the full path in the title bar. + /// FALSE + /// Display only the file name in the title bar. + /// + public bool fFullPathTitle { get => GetBit(ref fFlags, 0); set => SetBit(ref fFlags, 0, value); } + + /// + /// Type: BOOL + /// TRUE + /// Remember each folder's view settings. + /// FALSE + /// Use global settings for all folders. + /// + public bool fSaveLocalView { get => GetBit(ref fFlags, 1); set => SetBit(ref fFlags, 1, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fNotShell { get => GetBit(ref fFlags, 2); set => SetBit(ref fFlags, 2, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fSimpleDefault { get => GetBit(ref fFlags, 3); set => SetBit(ref fFlags, 3, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fDontShowDescBar { get => GetBit(ref fFlags, 4); set => SetBit(ref fFlags, 4, value); } + + /// + /// Type: BOOL + /// TRUE + /// Display in a new window. + /// FALSE + /// Display in the current window. + /// + public bool fNewWindowMode { get => GetBit(ref fFlags, 5); set => SetBit(ref fFlags, 5, value); } + + /// + /// Type: BOOL + /// TRUE + /// Show encrypted or compressed NTFS files in color. + /// FALSE + /// Do not show encrypted or compressed NTFS files in color. + /// + public bool fShowCompColor { get => GetBit(ref fFlags, 6); set => SetBit(ref fFlags, 6, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fDontPrettyNames { get => GetBit(ref fFlags, 7); set => SetBit(ref fFlags, 7, value); } + + /// + /// Type: BOOL + /// Used when an administrator installs an application that places an icon in the Start menu. + /// TRUE + /// Add the icon to the Start menu for all users (CSIDL_COMMON_STARTMENU). This is the default value. + /// FALSE + /// Add the icon to only the current user (CSIDL_STARTMENU). + /// + public bool fAdminsCreateCommonGroups { get => GetBit(ref fFlags, 8); set => SetBit(ref fFlags, 8, value); } } /// - /// Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, left cell of the buffer. + /// Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, + /// left cell of the buffer. /// [PInvokeData("wincon.h")] [StructLayout(LayoutKind.Sequential, Pack = 2)] @@ -2479,6 +4426,59 @@ namespace Vanara.PInvoke public short Y; } + /// + /// Used with the SHCreateShellFolderViewEx function. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-_csfv typedef struct _CSFV { UINT cbSize; + // IShellFolder *pshf; IShellView *psvOuter; PCIDLIST_ABSOLUTE pidl; LONG lEvents; LPFNVIEWCALLBACK pfnCallback; FOLDERVIEWMODE fvm; + // } CSFV, *LPCSFV; + [PInvokeData("shlobj_core.h", MSDNShortId = "9ec22fd4-1562-4ef0-b932-ebbf06082807")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct CSFV + { + /// + /// Type: UINT + /// The size of the CSFV structure, in bytes. + /// + public uint cbSize; + + /// + /// Type: IShellFolder* + /// A pointer to the IShellFolder object for which to create the view. + /// + public IShellFolder pshf; + + /// + /// Type: IShellView* + /// A pointer to the parent IShellView interface. This parameter can be NULL. + /// + public IShellView psvOuter; + + /// + /// Type: PCIDLIST_ABSOLUTE + /// Ignored. + /// + public IntPtr pidl; + + /// + /// Type: LONG + /// + public int lEvents; + + /// + /// Type: LPFNVIEWCALLBACK + /// + /// A pointer to the LPFNVIEWCALLBACK function used by this folder view to handle callback messages. This parameter can be NULL. + /// + /// + public LPFNVIEWCALLBACK pfnCallback; + + /// + /// Type: FOLDERVIEWMODE + /// + public FOLDERVIEWMODE fvm; + } + /// Serves as the header for some of the extra data structures used by IShellLinkDataList. [StructLayout(LayoutKind.Sequential, Pack = 4)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773249")] @@ -2556,7 +4556,8 @@ namespace Vanara.PInvoke public struct EXP_DARWIN_LINK { /// - /// DATABLOCK_HEADER structure stating the size and signature of the EXP_DARWIN_LINK structure. The following is the only recognized signature value: EXP_DARWIN_ID_SIG + /// DATABLOCK_HEADER structure stating the size and signature of the EXP_DARWIN_LINK structure. The following is the only + /// recognized signature value: EXP_DARWIN_ID_SIG /// public DATABLOCKHEADER dbh; @@ -2596,8 +4597,8 @@ namespace Vanara.PInvoke public uint cbSize; /// - /// The structure's signature. It can have one of the following values: EXP_SZ_LINK_SIG = Contains the link's target path; EXP_SZ_ICON_SIG = Contains - /// the links icon path. + /// The structure's signature. It can have one of the following values: EXP_SZ_LINK_SIG = Contains the link's target path; + /// EXP_SZ_ICON_SIG = Contains the links icon path. /// public ShellDataBlockSignature dwSignature; @@ -2616,7 +4617,8 @@ namespace Vanara.PInvoke public struct NT_CONSOLE_PROPS { /// - /// The DATABLOCK_HEADER structure with the NT_CONSOLE_PROPS structure's size and signature. The signature for an NT_CONSOLE_PROPS structure is NT_CONSOLE_PROPS_SIG. + /// The DATABLOCK_HEADER structure with the NT_CONSOLE_PROPS structure's size and signature. The signature for an + /// NT_CONSOLE_PROPS structure is NT_CONSOLE_PROPS_SIG. /// public DATABLOCKHEADER dbh; @@ -2689,7 +4691,8 @@ namespace Vanara.PInvoke public struct NT_FE_CONSOLE_PROPS { /// - /// The DATABLOCK_HEADER structure with the NT_FE_CONSOLE_PROPS structure's size and signature. The signature for an NT_FE_CONSOLE_PROPS structure is NT_FE_CONSOLE_PROPS_SIG. + /// The DATABLOCK_HEADER structure with the NT_FE_CONSOLE_PROPS structure's size and signature. The signature for an + /// NT_FE_CONSOLE_PROPS structure is NT_FE_CONSOLE_PROPS_SIG. /// public DATABLOCKHEADER dbh; @@ -2697,9 +4700,13 @@ namespace Vanara.PInvoke public uint uCodePage; } - /// This structure contains information from a .pif file. It is used by PifMgr_GetProperties. - // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-propprg - // typedef struct PROPPRG { WORD flPrg; WORD flPrgInit; CHAR achTitle[PIFNAMESIZE]; CHAR achCmdLine[PIFSTARTLOCSIZE + PIFPARAMSSIZE + 1]; CHAR achWorkDir[PIFDEFPATHSIZE]; WORD wHotKey; CHAR achIconFile[PIFDEFFILESIZE]; WORD wIconIndex; DWORD dwEnhModeFlags; DWORD dwRealModeFlags; CHAR achOtherFile[PIFDEFFILESIZE]; CHAR achPIFFile[PIFMAXFILEPATH]; }; + /// + /// This structure contains information from a .pif file. It is used by PifMgr_GetProperties. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-propprg typedef struct PROPPRG { WORD flPrg; WORD + // flPrgInit; CHAR achTitle[PIFNAMESIZE]; CHAR achCmdLine[PIFSTARTLOCSIZE + PIFPARAMSSIZE + 1]; CHAR achWorkDir[PIFDEFPATHSIZE]; WORD + // wHotKey; CHAR achIconFile[PIFDEFFILESIZE]; WORD wIconIndex; DWORD dwEnhModeFlags; DWORD dwRealModeFlags; CHAR + // achOtherFile[PIFDEFFILESIZE]; CHAR achPIFFile[PIFMAXFILEPATH]; }; [PInvokeData("shlobj_core.h", MSDNShortId = "603f990b-efb8-4d72-bc96-27bda4ffcbd8")] [StructLayout(LayoutKind.Sequential)] public struct PROPPRG @@ -2713,37 +4720,123 @@ namespace Vanara.PInvoke private const int PIFDEFFILESIZE = 80; private const int PIFMAXFILEPATH = 260; - /// Type: WORDFlags that describe how the program will run.PRG_DEFAULTUse the default options.PRG_CLOSEONEXITClose the application on exit. + /// + /// Type: WORD + /// Flags that describe how the program will run. + /// PRG_DEFAULT + /// Use the default options. + /// PRG_CLOSEONEXIT + /// Close the application on exit. + /// public ushort flPrg; - /// Type: WORDFlags that specify the initial conditions for the application.PRGINIT_DEFAULTUse the default options.PRGINIT_MINIMIZEDThe application should be minimized.PRGINIT_MAXIMIZEDThe application should be maximized.PRGINIT_REALMODEThe application should run in real mode.PRGINIT_REALMODESILENTThe application should run in real mode without being prompted.PRGINIT_AMBIGUOUSPIFThe data is ambiguous.PRGINIT_NOPIFNo .pif file was found.PRGINIT_DEFAULTPIFA default .pif was found.PRGINIT_INFSETTINGSA .inf file was found.PRGINIT_INHIBITPIFThe .inf file indicates that a .pif file should not be created. + + /// + /// Type: WORD + /// Flags that specify the initial conditions for the application. + /// PRGINIT_DEFAULT + /// Use the default options. + /// PRGINIT_MINIMIZED + /// The application should be minimized. + /// PRGINIT_MAXIMIZED + /// The application should be maximized. + /// PRGINIT_REALMODE + /// The application should run in real mode. + /// PRGINIT_REALMODESILENT + /// The application should run in real mode without being prompted. + /// PRGINIT_AMBIGUOUSPIF + /// The data is ambiguous. + /// PRGINIT_NOPIF + /// No .pif file was found. + /// PRGINIT_DEFAULTPIF + /// A default .pif was found. + /// PRGINIT_INFSETTINGS + /// A .inf file was found. + /// PRGINIT_INHIBITPIF + /// The .inf file indicates that a .pif file should not be created. + /// public ushort flPrgInit; - /// Type: __wchar_tA null-terminated string that contains the title. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the title. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFNAMESIZE)] public byte[] achTitle; - /// Type: __wchar_tA null-terminated string that contains the command line, including arguments. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the command line, including arguments. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFSTARTLOCSIZE + PIFPARAMSSIZE + 1)] public byte[] achCmdLine; - /// Type: __wchar_tA null-terminated string that contains the working directory. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the working directory. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFPATHSIZE)] public byte[] achWorkDir; - /// Type: WORDThe key code of the .pif file's hotkey. + + /// + /// Type: WORD + /// The key code of the .pif file's hotkey. + /// public ushort wHotKey; - /// Type: __wchar_tA null-terminated string that contains the name of the file that contains the icon. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the name of the file that contains the icon. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFFILESIZE)] public byte[] achIconFile; - /// Type: WORDThe index of the icon in the file specified by achIconFile. + + /// + /// Type: WORD + /// The index of the icon in the file specified by achIconFile. + /// public ushort wIconIndex; - /// Type: DWORDReserved. + + /// + /// Type: DWORD + /// Reserved. + /// public uint dwEnhModeFlags; - /// Type: DWORDFlags that specify the real mode options.RMOPT_MOUSERequires a real-mode mouse.RMOPT_EMSRequires expanded memory.RMOPT_CDROMRequires CD-ROM support.RMOPT_NETWORKRequires network support.RMOPT_DISKLOCKRequires disk locking.RMOPT_PRIVATECFGUse a private config.sys or autoexec.bat file.RMOPT_VESARequires a VESA driver. + + /// + /// Type: DWORD + /// Flags that specify the real mode options. + /// RMOPT_MOUSE + /// Requires a real-mode mouse. + /// RMOPT_EMS + /// Requires expanded memory. + /// RMOPT_CDROM + /// Requires CD-ROM support. + /// RMOPT_NETWORK + /// Requires network support. + /// RMOPT_DISKLOCK + /// Requires disk locking. + /// RMOPT_PRIVATECFG + /// Use a private config.sys or autoexec.bat file. + /// RMOPT_VESA + /// Requires a VESA driver. + /// public uint dwRealModeFlags; - /// Type: __wchar_tA null-terminated string that contains the name of the "other" file in the directory. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the name of the "other" file in the directory. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFFILESIZE)] public byte[] achOtherFile; - /// Type: __wchar_tA null-terminated string that contains the name of the .pif file in the directory. + + /// + /// Type: __wchar_t + /// A null-terminated string that contains the name of the .pif file in the directory. + /// [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFMAXFILEPATH)] public byte[] achPIFFile; } + /// This structure is used with the SHCreateShellFolderView function. [StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h")] @@ -2751,19 +4844,50 @@ namespace Vanara.PInvoke { /// The size of the SFV_CREATE structure, in bytes. public uint cbSize; + /// The IShellFolder interface of the folder for which to create the view. public IShellFolder pshf; + /// - /// A pointer to the parent IShellView interface. This parameter may be NULL. This parameter is used only when the view created by - /// SHCreateShellFolderView is hosted in a common dialog box. + /// A pointer to the parent IShellView interface. This parameter may be NULL. This parameter is used only when the view created + /// by SHCreateShellFolderView is hosted in a common dialog box. /// public IShellView psvOuter; + /// - /// A pointer to the IShellFolderViewCB interface that handles the view's callbacks when various events occur. This parameter may be NULL. + /// A pointer to the IShellFolderViewCB interface that handles the view's callbacks when various events occur. This parameter may + /// be NULL. /// public IShellFolderViewCB psfvcb; } + /// + /// Contains and receives information for change notifications. This structure is used with the SHChangeNotifyRegister function and + /// the SFVM_QUERYFSNOTIFY notification. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-_shchangenotifyentry typedef struct + // _SHChangeNotifyEntry { PCIDLIST_ABSOLUTE pidl; BOOL fRecursive; } SHChangeNotifyEntry; + [PInvokeData("shlobj_core.h", MSDNShortId = "cb11435a-86f0-4b06-bfc6-e0417f2897a1")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct SHChangeNotifyEntry + { + /// + /// Type: PCIDLIST_ABSOLUTE + /// PIDL for which to receive notifications. + /// + public IntPtr pidl; + + /// + /// Type: BOOL + /// + /// A flag indicating whether to post notifications for children of this PIDL. For example, if the PIDL points to a folder, then + /// file notifications would come from the folder's children if this flag was TRUE. + /// + /// + [MarshalAs(UnmanagedType.Bool)] + public bool fRecursive; + } + /// Receives item data in response to a call to SHGetDataFromIDList. [StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h", MSDNShortId = "bb759775")] @@ -2776,6 +4900,476 @@ namespace Vanara.PInvoke public Guid clsid; } + /// + /// Contains a set of flags that indicate the current Shell settings. This structure is used with the SHGetSettings function. + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-shellflagstate typedef struct SHELLFLAGSTATE { + // BOOL fShowAllObjects : 1; BOOL fShowExtensions : 1; BOOL fNoConfirmRecycle : 1; BOOL fShowSysFiles : 1; BOOL fShowCompColor : 1; + // BOOL fDoubleClickInWebView : 1; BOOL fDesktopHTML : 1; BOOL fWin95Classic : 1; BOOL fDontPrettyPath : 1; BOOL fShowAttribCol : 1; + // BOOL fMapNetDrvBtn : 1; BOOL fShowInfoTip : 1; BOOL fHideIcons : 1; BOOL fAutoCheckSelect : 1; BOOL fIconsOnly : 1; UINT + // fRestFlags : 1; UINT fRestFlags : 3; } *LPSHELLFLAGSTATE; + [PInvokeData("shlobj_core.h", MSDNShortId = "9968c7c9-79d9-4fb1-bda2-d6a2504cd3a3")] + [StructLayout(LayoutKind.Sequential)] + public struct SHELLFLAGSTATE + { + private uint bits1; + + /// + /// Type: BOOL + /// TRUE to show all objects, including hidden files and folders. FALSE to hide hidden files and folders. + /// + public bool fShowAllObjects { get => GetBit(ref bits1, 0); set => SetBit(ref bits1, 0, value); } + + /// + /// Type: BOOL + /// TRUE to show file name extensions, FALSE to hide them. + /// + public bool fShowExtensions { get => GetBit(ref bits1, 1); set => SetBit(ref bits1, 1, value); } + + /// + /// Type: BOOL + /// + /// TRUE to show no confirmation dialog box when deleting items to the Recycle Bin, FALSE to display the + /// confirmation dialog box. + /// + /// + public bool fNoConfirmRecycle { get => GetBit(ref bits1, 2); set => SetBit(ref bits1, 2, value); } + + /// + /// Type: BOOL + /// TRUE to show system files, FALSE to hide them. + /// + public bool fShowSysFiles { get => GetBit(ref bits1, 3); set => SetBit(ref bits1, 3, value); } + + /// + /// Type: BOOL + /// TRUE to show encrypted or compressed NTFS files in color. + /// + public bool fShowCompColor { get => GetBit(ref bits1, 4); set => SetBit(ref bits1, 4, value); } + + /// + /// Type: BOOL + /// TRUE to require a double-click to open an item when in web view. + /// + public bool fDoubleClickInWebView { get => GetBit(ref bits1, 5); set => SetBit(ref bits1, 5, value); } + + /// + /// Type: BOOL + /// TRUE to use Active Desktop, FALSE otherwise. + /// + public bool fDesktopHTML { get => GetBit(ref bits1, 6); set => SetBit(ref bits1, 6, value); } + + /// + /// Type: BOOL + /// TRUE to enforce Windows 95 Shell behavior and restrictions. + /// + public bool fWin95Classic { get => GetBit(ref bits1, 7); set => SetBit(ref bits1, 7, value); } + + /// + /// Type: BOOL + /// TRUE to prevent the conversion of the path to all lowercase characters. + /// + public bool fDontPrettyPath { get => GetBit(ref bits1, 8); set => SetBit(ref bits1, 8, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fShowAttribCol { get => GetBit(ref bits1, 9); set => SetBit(ref bits1, 9, value); } + + /// + /// Type: BOOL + /// TRUE to display a Map Network Drive button. + /// + public bool fMapNetDrvBtn { get => GetBit(ref bits1, 10); set => SetBit(ref bits1, 10, value); } + + /// + /// Type: BOOL + /// TRUE to show a pop-up description for folders and files. + /// + public bool fShowInfoTip { get => GetBit(ref bits1, 11); set => SetBit(ref bits1, 11, value); } + + /// + /// Type: BOOL + /// TRUE to hide desktop icons, FALSE to show them. + /// + public bool fHideIcons { get => GetBit(ref bits1, 12); set => SetBit(ref bits1, 12, value); } + + /// + /// Type: BOOL + /// + /// Introduced in Windows Vista. TRUE to use the Windows Vista-style checkbox folder views, FALSE to use the + /// classic views. + /// + /// + public bool fAutoCheckSelect { get => GetBit(ref bits1, 13); set => SetBit(ref bits1, 13, value); } + + /// + /// Type: BOOL + /// + /// Introduced in Windows Vista. TRUE to show generic icons only, FALSE to show thumbnail-style icons in folders. + /// + /// + public bool fIconsOnly { get => GetBit(ref bits1, 14); set => SetBit(ref bits1, 14, value); } + } + + /// Contains settings for the Shell's state. This structure is used with the SHGetSetSettings function. + // typedef struct { BOOL fShowAllObjects :1; BOOL fShowExtensions :1; BOOL fNoConfirmRecycle :1; BOOL fShowSysFiles :1; BOOL + // fShowCompColor :1; BOOL fDoubleClickInWebView :1; BOOL fDesktopHTML :1; BOOL fWin95Classic :1; BOOL fDontPrettyPath :1; BOOL + // fShowAttribCol :1; BOOL fMapNetDrvBtn :1; BOOL fShowInfoTip :1; BOOL fHideIcons :1; BOOL fWebView :1; BOOL fFilter :1; BOOL + // fShowSuperHidden :1; BOOL fNoNetCrawling :1; DWORD dwWin95Unused; UINT uWin95Unused; LONG lParamSort; int iSortDirection; UINT + // version; UINT uNotUsed; BOOL fSepProcess :1; BOOL fStartPanelOn :1; BOOL fShowStartPage :1; BOOL fAutoCheckSelect :1; BOOL + // fIconsOnly :1; BOOL fShowTypeOverlay :1; BOOL fShowStatusBar :1; UINT fSpareFlags :9;} SHELLSTATE, *LPSHELLSTATE; https://msdn.microsoft.com/en-us/library/windows/desktop/bb759788(v=vs.85).aspx + [PInvokeData("Shlobj.h", MSDNShortId = "bb759788")] + [StructLayout(LayoutKind.Sequential)] + public struct SHELLSTATE + { + private uint bits1; + + /// + /// Type: DWORD + /// Not used. + /// + public uint dwWin95Unused; + + /// + /// Type: UINT + /// Not used. + /// + public uint uWin95Unused; + + /// + /// Type: LONG + /// The column to sort by. + /// + public int lParamSort; + + /// + /// Type: int + /// + /// Alphabetical sort direction for the column specified by lParamSort. Use 1 for an ascending sort, -1 for a descending sort. + /// + /// + public int iSortDirection; + + /// + /// Type: UINT + /// Not used. + /// + public uint version; + + /// + /// Type: UINT + /// Not used. + /// + public uint uNotUsed; + + private uint bits2; + + /// + /// Type: BOOL + /// TRUE to show all objects, including hidden files and folders. FALSE to hide hidden files and folders. + /// + public bool fShowAllObjects { get => GetBit(ref bits1, 0); set => SetBit(ref bits1, 0, value); } + + /// + /// Type: BOOL + /// TRUE to show file name extensions, FALSE to hide them. + /// + public bool fShowExtensions { get => GetBit(ref bits1, 1); set => SetBit(ref bits1, 1, value); } + + /// + /// Type: BOOL + /// + /// TRUE to show no confirmation dialog box when deleting items to the Recycle Bin, FALSE to display the + /// confirmation dialog box. + /// + /// + public bool fNoConfirmRecycle { get => GetBit(ref bits1, 2); set => SetBit(ref bits1, 2, value); } + + /// + /// Type: BOOL + /// TRUE to show system files, FALSE to hide them. + /// + public bool fShowSysFiles { get => GetBit(ref bits1, 3); set => SetBit(ref bits1, 3, value); } + + /// + /// Type: BOOL + /// TRUE to show encrypted or compressed NTFS files in color. + /// + public bool fShowCompColor { get => GetBit(ref bits1, 4); set => SetBit(ref bits1, 4, value); } + + /// + /// Type: BOOL + /// TRUE to require a double-click to open an item when in web view. + /// + public bool fDoubleClickInWebView { get => GetBit(ref bits1, 5); set => SetBit(ref bits1, 5, value); } + + /// + /// Type: BOOL + /// TRUE to use Active Desktop, FALSE otherwise. + /// + public bool fDesktopHTML { get => GetBit(ref bits1, 6); set => SetBit(ref bits1, 6, value); } + + /// + /// Type: BOOL + /// TRUE to enforce Windows 95 Shell behavior and restrictions. + /// + public bool fWin95Classic { get => GetBit(ref bits1, 7); set => SetBit(ref bits1, 7, value); } + + /// + /// Type: BOOL + /// TRUE to prevent the conversion of the path to all lowercase characters. + /// + public bool fDontPrettyPath { get => GetBit(ref bits1, 8); set => SetBit(ref bits1, 8, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fShowAttribCol { get => GetBit(ref bits1, 9); set => SetBit(ref bits1, 9, value); } + + /// + /// Type: BOOL + /// TRUE to display a Map Network Drive button. + /// + public bool fMapNetDrvBtn { get => GetBit(ref bits1, 10); set => SetBit(ref bits1, 10, value); } + + /// + /// Type: BOOL + /// TRUE to show a pop-up description for folders and files. + /// + public bool fShowInfoTip { get => GetBit(ref bits1, 11); set => SetBit(ref bits1, 11, value); } + + /// + /// Type: BOOL + /// TRUE to hide desktop icons, FALSE to show them. + /// + public bool fHideIcons { get => GetBit(ref bits1, 12); set => SetBit(ref bits1, 12, value); } + + /// + /// Type: BOOL + /// TRUE to display as a web view. + /// + public bool fWebView { get => GetBit(ref bits1, 13); set => SetBit(ref bits1, 13, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fFilter { get => GetBit(ref bits1, 14); set => SetBit(ref bits1, 14, value); } + + /// + /// Type: BOOL + /// TRUE to show operating system files. + /// + public bool fShowSuperHidden { get => GetBit(ref bits1, 15); set => SetBit(ref bits1, 15, value); } + + /// + /// Type: BOOL + /// TRUE to disable automatic searching for network folders and printers. + /// + public bool fNoNetCrawling { get => GetBit(ref bits1, 16); set => SetBit(ref bits1, 16, value); } + + /// + /// Type: BOOL + /// TRUE to launch folder windows in separate processes, FALSE to launch in the same process. + /// + public bool fSepProcess { get => GetBit(ref bits2, 0); set => SetBit(ref bits2, 0, value); } + + /// + /// Type: BOOL + /// + /// Windows XP only. TRUE to use the Windows XP-style Start menu, FALSE to use the classic Start menu. + /// + /// + public bool fStartPanelOn { get => GetBit(ref bits2, 1); set => SetBit(ref bits2, 1, value); } + + /// + /// Type: BOOL + /// Not used. + /// + public bool fShowStartPage { get => GetBit(ref bits2, 2); set => SetBit(ref bits2, 2, value); } + + /// + /// Type: BOOL + /// + /// Introduced in Windows Vista. TRUE to use the Windows Vista-style checkbox folder views, FALSE to use the + /// classic views. + /// + /// + public bool fAutoCheckSelect { get => GetBit(ref bits2, 3); set => SetBit(ref bits2, 3, value); } + + /// + /// Type: BOOL + /// + /// Introduced in Windows Vista. TRUE to show generic icons only, FALSE to show thumbnail-style icons in folders. + /// + /// + public bool fIconsOnly { get => GetBit(ref bits2, 4); set => SetBit(ref bits2, 4, value); } + + /// + /// Type: BOOL + /// + /// Introduced in Windows Vista. TRUE indicates a thumbnail should show the application that would be invoked when + /// opening the item, FALSE indicates that no application will be shown. + /// + /// + public bool fShowTypeOverlay { get => GetBit(ref bits2, 5); set => SetBit(ref bits2, 5, value); } + + /// + /// Type: BOOL + /// Introduced in Windows 8. TRUE to show the status bar; otherwise, FALSE. + /// + public bool fShowStatusBar { get => GetBit(ref bits2, 6); set => SetBit(ref bits2, 6, value); } + } + + /// + /// Holds custom folder settings. This structure is used with the SHGetSetFolderCustomSettings function. + /// + /// + /// + /// In Windows XP Service Pack 2 (SP2) and earlier versions, this structure supported both ANSI and Unicode strings. In Windows Vista + /// and later versions, only Unicode strings are supported. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-shfoldercustomsettings typedef struct + // SHFOLDERCUSTOMSETTINGS { DWORD dwSize; DWORD dwMask; SHELLVIEWID *pvid; LPWSTR pszWebViewTemplate; DWORD cchWebViewTemplate; + // LPWSTR pszWebViewTemplateVersion; LPWSTR pszInfoTip; DWORD cchInfoTip; CLSID *pclsid; DWORD dwFlags; LPWSTR pszIconFile; DWORD + // cchIconFile; int iIconIndex; LPWSTR pszLogo; DWORD cchLogo; } *LPSHFOLDERCUSTOMSETTINGS; + [PInvokeData("shlobj_core.h", MSDNShortId = "a6357372-80ef-4719-b53f-87eb3fdc1b0d")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct SHFOLDERCUSTOMSETTINGS + { + /// + /// Type: DWORD + /// The size of the structure, in bytes. + /// + public uint dwSize; + + /// + /// Type: DWORD + /// + /// A DWORD value specifying which folder attributes to read or write from this structure. Use one or more of the + /// following values to indicate which structure members are valid: + /// + /// FCSM_VIEWID + /// Deprecated. pvid contains the folder's GUID. + /// FCSM_WEBVIEWTEMPLATE + /// + /// Deprecated. pszWebViewTemplate contains a pointer to a buffer containing the path to the folder's WebView template. + /// + /// FCSM_INFOTIP + /// pszInfoTip contains a pointer to a buffer containing the folder's info tip. + /// FCSM_CLSID + /// pclsid contains the folder's CLSID. + /// FCSM_ICONFILE + /// pszIconFile contains the path to the file containing the folder's icon. + /// FCSM_LOGO + /// pszLogo contains the path to the file containing the folder's thumbnail icon. + /// FCSM_FLAGS + /// Not used. + /// + public FOLDERCUSTOMSETTINGSMASK dwMask; + + /// + /// Type: SHELLVIEWID* + /// The folder's GUID. + /// + public IntPtr pvid; + + /// + /// Type: LPTSTR + /// A pointer to a null-terminated string containing the path to the folder's WebView template. + /// + public string pszWebViewTemplate; + + /// + /// Type: DWORD + /// + /// If the SHGetSetFolderCustomSettings parameter is FCS_READ, this is the size of the pszWebViewTemplate buffer, + /// in characters. If not, this is the number of characters to write from that buffer. Set this parameter to 0 to write the + /// entire string. + /// + /// + public uint cchWebViewTemplate; + + /// + /// Type: LPTSTR + /// A pointer to a null-terminated buffer containing the WebView template version. + /// + public string pszWebViewTemplateVersion; + + /// + /// Type: LPTSTR + /// A pointer to a null-terminated buffer containing the text of the folder's infotip. + /// + public string pszInfoTip; + + /// + /// Type: DWORD + /// + /// If the SHGetSetFolderCustomSettings parameter is FCS_READ, this is the size of the pszInfoTip buffer, in + /// characters. If not, this is the number of characters to write from that buffer. Set this parameter to 0 to write the entire string. + /// + /// + public uint cchInfoTip; + + /// + /// Type: CLSID* + /// + /// A pointer to a CLSID used to identify the folder in the Windows registry. Further folder information is stored in the + /// registry under that CLSID entry. + /// + /// + public IntPtr pclsid; + + /// + /// Type: DWORD + /// Not used. + /// + public uint dwFlags; + + /// + /// Type: LPTSTR + /// A pointer to a null-terminated buffer containing the path to file containing the folder's icon. + /// + public string pszIconFile; + + /// + /// Type: DWORD + /// + /// If the SHGetSetFolderCustomSettings parameter is FCS_READ, this is the size of the pszIconFile buffer, in + /// characters. If not, this is the number of characters to write from that buffer. Set this parameter to 0 to write the entire string. + /// + /// + public uint cchIconFile; + + /// + /// Type: int + /// The index of the icon within the file named in pszIconFile. + /// + public int iIconIndex; + + /// + /// Type: LPTSTR + /// + /// A pointer to a null-terminated buffer containing the path to the file containing the folder's logo image. This is the image + /// used in thumbnail views. + /// + /// + public string pszLogo; + + /// + /// Type: DWORD + /// + /// If the SHGetSetFolderCustomSettings parameter is FCS_READ, this is the size of the pszLogo buffer, in + /// characters. If not, this is the number of characters to write from that buffer. Set this parameter to 0 to write the entire string. + /// + /// + public uint cchLogo; + } + /*[StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773399")] public struct SFV_CREATE