using System; using System.IO; using System.Runtime.InteropServices; using System.Text; using Vanara.InteropServices; using static Vanara.PInvoke.ComCtl32; using static Vanara.PInvoke.Kernel32; using static Vanara.PInvoke.PropSys; using static Vanara.PInvoke.User32_Gdi; namespace Vanara.PInvoke { /// Interfaces, functions, enumerated types and structures for Shell32.dll. public static partial class Shell32 { /// Values used in APPBARDATA. [PInvokeData("shellapi.h", MSDNShortId = "cf86fe15-4beb-49b7-b73e-2ad61cedc3f8")] public enum ABE { /// Left edge. ABE_LEFT = 0, /// Top edge. ABE_TOP = 1, /// Right edge. ABE_RIGHT = 2, /// Bottom edge. ABE_BOTTOM = 3, } /// Values used by SHAppBarMessage. [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. /// ABM_NEW = 0x00000000, /// Unregisters an appbar, removing the bar from the system's internal list. ABM_REMOVE = 0x00000001, /// Requests a size and screen position for an appbar. ABM_QUERYPOS = 0x00000002, /// Sets the size and screen position of an appbar. ABM_SETPOS = 0x00000003, /// 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. /// 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. /// ABM_ACTIVATE = 0x00000006, /// Retrieves the handle to the autohide appbar associated with a particular edge of the screen. ABM_GETAUTOHIDEBAR = 0x00000007, /// Registers or unregisters an autohide appbar for an edge of the screen. ABM_SETAUTOHIDEBAR = 0x00000008, /// Notifies the system when an appbar's position has changed. ABM_WINDOWPOSCHANGED = 0x00000009, /// 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. /// ABM_GETAUTOHIDEBAREX = 0x0000000B, /// Windows XP and later: Registers or unregisters an autohide appbar for an edge of a particular monitor. ABM_SETAUTOHIDEBAREX = 0x0000000C, } /// Where to obtain association data and the form the data is stored in. [PInvokeData("shellapi.h", MSDNShortId = "1d1a963f-7ebb-4ba6-9a97-795c8ef11ae4")] public enum ASSOCCLASS { /// 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. /// 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. /// /// Because an application cannot predict when it might encounter quiet time, we recommended that this flag always be set on all /// appropriate notifications by any application that means to honor quiet 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 } /// A value that specifies the action to be taken by Shell_NotifyIcon. public enum NIM { /// /// Adds an icon to the status area. The icon is given an identifier in the NOTIFYICONDATA structure pointed to by lpdata—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_ADD = 0x00000000, /// /// Modifies an icon in the status area. NOTIFYICONDATA structure pointed to by lpdata 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_MODIFY = 0x00000001, /// /// Deletes an icon from the status area. NOTIFYICONDATA structure pointed to by lpdata 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_DELETE = 0x00000002, /// /// 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_SETFOCUS = 0x00000003, /// /// 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 lpdata. 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. /// /// NIM_SETVERSION = 0x00000004, } /// 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, } /// /// /// Specifies the state of the machine for the current user in relation to the propriety of sending a notification. Used by SHQueryUserNotificationState. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ne-shellapi-query_user_notification_state typedef enum // QUERY_USER_NOTIFICATION_STATE { QUNS_NOT_PRESENT , QUNS_BUSY , QUNS_RUNNING_D3D_FULL_SCREEN , QUNS_PRESENTATION_MODE , // QUNS_ACCEPTS_NOTIFICATIONS , QUNS_QUIET_TIME , QUNS_APP } ; [PInvokeData("shellapi.h", MSDNShortId = "b26439dd-6695-45d8-8c7f-5bbd5eaf5b54")] public enum QUERY_USER_NOTIFICATION_STATE { /// A screen saver is displayed, the machine is locked, or a nonactive Fast User Switching session is in progress. QUNS_NOT_PRESENT = 1, /// /// A full-screen application is running or Presentation Settings are applied. Presentation Settings allow a user to put their /// machine into a state fit for an uninterrupted presentation, such as a set of PowerPoint slides, with a single click. /// QUNS_BUSY, /// A full-screen (exclusive mode) Direct3D application is running. QUNS_RUNNING_D3D_FULL_SCREEN, /// The user has activated Windows presentation settings to block notifications and pop-up messages. QUNS_PRESENTATION_MODE, /// None of the other states are found, notifications can be freely sent. QUNS_ACCEPTS_NOTIFICATIONS, /// /// Introduced in Windows 7. 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. Applications should set the NIIF_RESPECT_QUIET_TIME flag in their notifications or /// balloon tooltip, which prevents those items from being displayed while the current user is in the quiet-time state. Note that /// during quiet time, if the user is in one of the other blocked modes (QUNS_NOT_PRESENT, QUNS_BUSY, QUNS_PRESENTATION_MODE, or /// QUNS_RUNNING_D3D_FULL_SCREEN) SHQueryUserNotificationState returns only that value, and does not report QUNS_QUIET_TIME. /// QUNS_QUIET_TIME, /// Introduced in Windows 8. A Windows Store app is running. QUNS_APP, } /// Flags that indicate the content and validity of the other structure members in . [PInvokeData("Shellapi.h", MSDNShortId = "bb759784")] [Flags] public enum ShellExecuteMaskFlags : uint { /// 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. /// 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. /// 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. /// 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. /// SEE_MASK_ICON = 0x00000010, /// Use the keyboard shortcut given by the dwHotKey member. 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. /// 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. /// 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. /// /// 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. /// SEE_MASK_NOASYNC = 0x00000100, /// Do not use; use SEE_MASK_NOASYNC instead. SEE_MASK_FLAG_DDEWAIT = SEE_MASK_NOASYNC, /// Expand any environment variables specified in the string given by the lpDirectory or lpFile member. SEE_MASK_DOENVSUBST = 0x00000200, /// Do not display an error message box if an error occurs. SEE_MASK_FLAG_NO_UI = 0x00000400, /// Use this flag to indicate a Unicode application. 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. /// 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. /// 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. /// 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. /// SEE_MASK_NOZONECHECKS = 0x00800000, /// Not used. 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. /// 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. /// 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. /// SEE_MASK_FLAG_HINST_IS_SITE = 0x08000000 } /// A value that indicates which operation to perform. [PInvokeData("Shellapi.h")] public enum ShellFileOperation { /// 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. /// FO_RENAME = 0x0004 } /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// 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. /// SHGFI_SHELLICONSIZE = 0x000000004, /// Indicate that pszPath is the address of an ITEMIDLIST structure rather than a path name. 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. /// SHGFI_USEFILEATTRIBUTES = 0x000000010, /// Apply the appropriate overlays to the file's icon. The SHGFI_ICON flag must also be set. 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. /// 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. /// /// /// Type: const ASSOCIATIONELEMENT* /// A pointer to an array of ASSOCIATIONELEMENT structures. /// /// /// Type: ULONG /// The number of elements in the array pointed to by . /// /// /// Type: REFIID /// Reference to the desired IID, normally IID_IQueryAssociations. /// /// /// Type: void** /// When this method returns, contains the interface pointer requested in . This is normally IQueryAssociations. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// 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 ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "43257507-dd5e-4622-8445-c132187fd1e5")] public static extern HRESULT AssocCreateForClasses([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ASSOCIATIONELEMENT[] rgClasses, uint cClasses, in Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Retrieves an object that implements an IQueryAssociations interface. /// Reference to the desired IID type, normally IQueryAssociations. /// Type: const ASSOCIATIONELEMENT* /// A pointer to an array of ASSOCIATIONELEMENT structures. /// /// When this method returns, contains the interface pointer requested in . This is normally IQueryAssociations. /// /// 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 ); [PInvokeData("shellapi.h", MSDNShortId = "43257507-dd5e-4622-8445-c132187fd1e5")] public static TIntf AssocCreateForClasses(ASSOCIATIONELEMENT[] rgClasses) where TIntf : class => IidGetObj((in Guid g, out object o) => AssocCreateForClasses(rgClasses, (uint)(rgClasses?.Length ?? 0), g, out o)); /// /// /// Parses a Unicode command line string and returns an array of pointers to the command line arguments, along with a count of such /// arguments, in a way that is similar to the standard C run-time and values. /// /// /// /// Type: LPCWSTR /// /// Pointer to a null-terminated Unicode string that contains the full command line. If this parameter is an empty string the /// function returns the path to the current executable file. /// /// /// /// Type: int* /// Pointer to an int that receives the number of array elements returned, similar to . /// /// /// Type: LPWSTR* /// A pointer to an array of LPWSTR values, similar to . /// If the function fails, the return value is NULL. To get extended error information, call GetLastError. /// /// /// /// The address returned by CommandLineToArgvW is the address of the first element in an array of LPWSTR values; the /// number of pointers in this array is indicated by . Each pointer to a null-terminated Unicode string represents an /// individual argument found on the command line. /// /// /// CommandLineToArgvW allocates a block of contiguous memory for pointers to the argument strings, and for the argument /// strings themselves; the calling application must free the memory used by the argument list when it is no longer needed. To free /// the memory, use a single call to the LocalFree function. /// /// For more information about the and argument convention, see Argument Definitions and Parsing C++ Command-Line Arguments. /// The GetCommandLineW function can be used to get a command line string that is suitable for use as the parameter. /// /// This function accepts command lines that contain a program name; the program name can be enclosed in quotation marks or not. /// /// /// CommandLineToArgvW has a special interpretation of backslash characters when they are followed by a quotation mark /// character ("). This interpretation assumes that any preceding argument is a valid file system path, or else it may behave unpredictably. /// /// /// This special interpretation controls the "in quotes" mode tracked by the parser. When this mode is off, whitespace terminates the /// current argument. When on, whitespace is added to the argument like all other characters. /// /// /// /// 2 backslashes followed by a quotation mark produce backslashes followed by begin/end quote. This does not become part of the /// parsed argument, but toggles the "in quotes" mode. /// /// /// (2) + 1 backslashes followed by a quotation mark again produce backslashes followed by a quotation mark literal ("). This does /// not toggle the "in quotes" mode. /// /// backslashes not followed by a quotation mark simply produce backslashes. /// /// /// ImportantCommandLineToArgvW treats whitespace outside of quotation marks as argument delimiters. However, if starts /// with any amount of whitespace, CommandLineToArgvW will consider the first argument to be an empty string. Excess /// whitespace at the end of is ignored. /// /// Examples /// // 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)] public static extern string[] CommandLineToArgvW(string lpCmdLine, out int pNumArgs); /// /// Registers whether a window accepts dropped files. /// /// /// Type: HWND /// The identifier of the window that is registering whether it will accept dropped files. /// /// /// Type: BOOL /// /// A value that indicates if the window identified by the parameter accepts dropped files. This value is TRUE to accept /// dropped files or FALSE to discontinue accepting dropped files. /// /// /// /// No return value. /// /// /// /// An application that calls DragAcceptFiles with the parameter set to TRUE has identified itself as able to process /// 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 ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "1f16f6e4-7847-4bc7-adce-995876db24bd")] public static extern void DragAcceptFiles(HWND hWnd, [MarshalAs(UnmanagedType.Bool)] bool fAccept); /// /// Releases memory that the system allocated for use in transferring file names to the application. /// /// /// Type: HDROP /// /// Identifier of the structure that describes dropped files. This handle is retrieved from the parameter of the WM_DROPFILES message. /// /// /// /// No return value. /// // 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(HDROP hDrop); /// /// Retrieves the names of dropped files that result from a successful drag-and-drop operation. /// /// /// Type: HDROP /// Identifier of the structure that contains the file names of the dropped files. /// /// /// Type: UINT /// /// Index of the file to query. If the value of this parameter is 0xFFFFFFFF, DragQueryFile returns a count of the files /// dropped. If the value of this parameter is between zero and the total number of files dropped, DragQueryFile copies the /// file name with the corresponding value to the buffer pointed to by the parameter. /// /// /// /// Type: LPTSTR /// /// The address of a buffer that receives the file name of a dropped file when the function returns. This file name is a /// null-terminated string. If this parameter is NULL, DragQueryFile returns the required size, in characters, of this buffer. /// /// /// /// Type: UINT /// The size, in characters, of the buffer. /// /// /// Type: UINT /// A nonzero value indicates a successful call. /// /// When the function copies a file name to the buffer, the return value is a count of the characters copied, not including the /// terminating null character. /// /// /// If the index value is 0xFFFFFFFF, the return value is a count of the dropped files. Note that the index variable itself returns /// unchanged, and therefore remains 0xFFFFFFFF. /// /// /// If the index value is between zero and the total number of dropped files, and the buffer address is NULL, the return value /// 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 ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "93fab381-9035-46c4-ba9d-efb2d0801d84")] public static extern uint DragQueryFile(HDROP hDrop, uint iFile, string lpszFile, uint cch); /// /// Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation. /// /// /// Type: HDROP /// Handle of the drop structure that describes the dropped file. /// /// /// TBD /// /// /// Type: BOOL /// TRUE if the drop occurred in the client area of the window; otherwise FALSE. /// /// /// 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 ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "87794ab0-a075-4a1f-869f-5998bdc57a1d")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool DragQueryPoint(HDROP hDrop, ref System.Drawing.Point ppt); /// Creates a duplicate of a specified icon. /// Type: HINSTANCE /// /// Type: HICON /// Handle to the icon to be duplicated. /// /// /// 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 [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776411")] public static extern SafeHICON DuplicateIcon(HINSTANCE hInst, HICON 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. /// 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 [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776414")] public static extern SafeHICON ExtractAssociatedIcon(HINSTANCE hInst, StringBuilder lpIconPath, ref ushort lpiIcon); /// /// /// Gets a handle to an icon stored as a resource in a file or an icon stored in a file's associated executable file. It extends the /// ExtractAssociatedIcon function by retrieving the icon's ID when that icon is extracted from an executable file. /// /// /// /// Type: HINSTANCE /// The handle of the module from which to extract the icon. /// /// /// TBD /// /// /// TBD /// /// /// TBD /// /// /// Type: HICON /// Returns the icon's handle if successful, otherwise NULL. /// /// /// 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 ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "f32260b0-917b-4406-aeee-34f71a7c7309")] public static extern SafeHICON ExtractAssociatedIconEx(HINSTANCE hInst, StringBuilder pszIconPath, ref ushort piIconIndex, ref ushort piIconId); /// /// Gets a handle to an icon from the specified executable file, DLL, or icon file. /// To retrieve an array of handles to large or small icons, use the ExtractIconEx function. /// /// /// Type: HINSTANCE /// Handle to the instance of the application that calls the function. /// /// /// Type: LPCTSTR /// Pointer to a null-terminated string that specifies the name of an executable file, DLL, or icon file. /// /// /// Type: UINT /// /// Specifies the zero-based index of the icon to retrieve. For example, if this value is 0, the function returns a handle to the /// first icon in the specified file. /// /// /// If this value is -1, 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 not equal to –1, the function returns a handle to the icon in the specified file whose /// resource identifier is equal to the absolute value of nIconIndex. For example, you should use –3 to extract the icon whose /// resource identifier is 3. To extract the icon whose resource identifier is 1, use the ExtractIconEx function. /// /// /// /// Type: HICON /// /// The return value is a handle to an icon. If the file specified was not an executable file, DLL, or icon file, the return is 1. If /// 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 [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "bb776416")] public static extern SafeHICON ExtractIcon(HINSTANCE 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. /// /// 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. /// /// 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. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "ms648069")] public static extern int ExtractIconEx([MarshalAs(UnmanagedType.LPTStr)] string lpszFile, int nIconIndex, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SafeHICON[] phIconLarge, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] SafeHICON[] phIconSmall, int nIcons); /// /// Retrieves the name of and handle to the executable (.exe) file associated with a specific document file. /// /// /// Type: LPCTSTR /// The address of a null-terminated string that specifies a file name. This file should be a document. /// /// /// Type: LPCTSTR /// The address of a null-terminated string that specifies the default directory. This value can be NULL. /// /// /// Type: LPTSTR /// /// The address of a buffer that receives the file name of the associated executable file. This file name is a null-terminated /// string that specifies the executable file started when an "open" by association is run on the file specified in the parameter. /// Put simply, this is the application that is launched when the document file is directly double-clicked or when Open is /// chosen from the file's shortcut menu. This parameter must contain a valid non- null value and is assumed to be of length /// MAX_PATH. Responsibility for validating the value is left to the programmer. /// /// /// /// Type: HINSTANCE /// Returns a value greater than 32 if successful, or a value less than or equal to 32 representing an error. /// The following table lists possible error values. /// /// /// Return code/value /// Description /// /// /// SE_ERR_FNF 2 /// The specified file was not found. /// /// /// SE_ERR_PNF 3 /// The specified path is invalid. /// /// /// SE_ERR_ACCESSDENIED 5 /// The specified file cannot be accessed. /// /// /// SE_ERR_OOM 8 /// The system is out of memory or resources. /// /// /// SE_ERR_NOASSOC 31 /// There is no association for the specified file type with an executable file. /// /// /// /// /// 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. /// /// /// 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 ); [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); /// /// Initializes the network address control window class. /// /// /// Type: BOOL /// TRUE if the initialization succeeded; or FALSE otherwise. /// /// /// /// The network address control looks like an edit control and offers the additional functionality of network address verification. /// The control uses a balloon tip to display error messages. /// /// 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( ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "52b475e3-7335-4c34-80d7-ccd81af0e0ec")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool InitNetworkAddressControl(); /// /// Adds default properties to the property store as registered for the specified file extension. /// /// /// Type: PCWSTR /// A pointer to a null-terminated, Unicode string that specifies the extension. /// /// /// Type: IPropertyStore* /// A pointer to the IPropertyStore interface that defines the default properties to add. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// The list of properties used to set a default value comes from the registry value of the ProgID for the file association of the /// specified file extension. The list is prefixed by "" and contains the canonical names of the properties to set the default value, /// such as: "". The possible properties for this list are System.Author, System.Document.DateCreated, and /// System.Photo.DateTaken. If the value does not exist on the ProgID, this function uses the default found on the value of HKEY_CLASSES_ROOT*. /// /// /// System.Author has the value of the user that performed the action. System.Document.DateCreated and /// System.Photo.DateTaken use the current date. These three properties are the only ones for which the system provides /// special defaults. /// /// Note that there are several types of properties: /// /// Properties that derive from the file system (such as, size and date created) /// Properties that derive from the file (such as, dimensions and number of pages) /// Properties that are placed in the file (such as, author and tags) /// /// /// When creating a new file, types one and two are provided just by creating the file. But properties of type three must be set /// explicitly by a program. The system provides /// /// SHAddDefaultPropertiesByExt /// /// to provide values for up to three specific properties of type three. Sometimes Windows Explorer uses this API when saving a file /// for the first time, or when creating a new file after the menu choice /// /// 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 ); [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); /// /// /// [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.] /// /// Adds pages to a property sheet extension array created by SHCreatePropSheetExtArray. /// /// /// Type: HPSXA /// The array of property sheet handlers returned by SHCreatePropSheetExtArray. /// /// /// Type: LPFNADDPROPSHEETPAGE /// /// A pointer to an AddPropSheetPageProc callback function. It is called once for each property sheet handler. The callback function /// then returns the information needed to add a page to the handler's property sheet. /// /// /// /// Type: LPARAM /// A pointer to application-defined data. This data is passed to the callback function specified by . /// /// /// Type: UINT /// Returns the number of pages actually added. /// /// /// 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 ); [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); /// /// /// [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 CoTaskMemAlloc instead.] /// /// Allocates memory from the Shell's heap. /// /// /// Type: SIZE_T /// The number of bytes of memory to allocate. /// /// /// Type: LPVOID /// A pointer to the allocated memory. /// /// /// You can free this memory by calling SHFree. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shalloc [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "621e4335-1484-4111-9cfe-7ae5c6d5c609")] public static extern IntPtr SHAlloc(SizeT cb); /// /// Sends an appbar message to the system. /// /// /// Type: DWORD /// Appbar message value to send. This parameter can be one of the following values. /// ABM_NEW (0x00000000) /// /// Registers a new appbar and specifies the message identifier that the system should use to send notification messages to the appbar. /// /// ABM_REMOVE (0x00000001) /// Unregisters an appbar, removing the bar from the system's internal list. /// ABM_QUERYPOS (0x00000002) /// Requests a size and screen position for an appbar. /// ABM_SETPOS (0x00000003) /// Sets the size and screen position of an appbar. /// ABM_GETSTATE (0x00000004) /// Retrieves the autohide and always-on-top states of the Windows taskbar. /// ABM_GETTASKBARPOS (0x00000005) /// /// 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_ACTIVATE (0x00000006) /// /// Notifies the system to activate or deactivate an appbar. The lParam member of the APPBARDATA pointed to by is set to /// TRUE to activate or FALSE to deactivate. /// /// ABM_GETAUTOHIDEBAR (0x00000007) /// Retrieves the handle to the autohide appbar associated with a particular edge of the screen. /// ABM_SETAUTOHIDEBAR (0x00000008) /// Registers or unregisters an autohide appbar for an edge of the screen. /// ABM_WINDOWPOSCHANGED (0x00000009) /// Notifies the system when an appbar's position has changed. /// ABM_SETSTATE (0x0000000A) /// Windows XP and later: Sets the state of the appbar's autohide and always-on-top attributes. /// ABM_GETAUTOHIDEBAREX (0x0000000B) /// /// Windows XP and later: Retrieves the handle to the autohide appbar associated with a particular edge of a particular monitor. /// /// ABM_SETAUTOHIDEBAREX (0x0000000C) /// Windows XP and later: Registers or unregisters an autohide appbar for an edge of a particular monitor. /// /// /// Type: PAPPBARDATA /// /// A pointer to an APPBARDATA structure. The content of the structure on entry and on exit depends on the value set in the /// parameter. See the individual message pages for specifics. /// /// /// /// Type: UINT_PTR /// /// This function returns a message-dependent value. For more information, see the Windows SDK documentation for the specific appbar /// 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 ); [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); /// /// Sends a message to the taskbar's status area. /// /// /// 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 /// lpdata—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 lpdata 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 lpdata 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 lpdata. 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. /// /// /// Type: PNOTIFYICONDATA /// /// A pointer to a NOTIFYICONDATA structure. The content of the structure depends on the value of dwMessage. It can define an icon to /// add to the notification area, cause that icon to display a notification, or identify an icon to modify or delete. /// /// /// /// Type: BOOL /// /// Returns TRUE if successful, or FALSE otherwise. If dwMessage 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 /// lpdata 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 lParam value of the /// application-defined message that is specified in the uCallbackMessage member of the NOTIFYICONDATA structure pointed to by /// lpdata, when Shell_NotifyIcon is called with the NIM_ADD flag set in dwMessage. /// /// /// 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(NIM dwMessage, in 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(in NOTIFYICONIDENTIFIER identifier, out 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(HWND hWnd, string szApp, string szOtherStuff, HICON 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(HWND 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); /// /// 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(HWND 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 SHEnumerateUnreadMailAccounts(HKEY 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(ref SHFILEOPSTRUCT lpFileOp); /// /// Frees a file name mapping object that was retrieved by the SHFileOperation function. /// /// /// 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. /// 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. /// /// [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. /// /// 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. /// 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. /// /// [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(HWND hwnd, in Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// /// Retrieves an object that represents a specific window's collection of properties, which allows those properties to be queried or set. /// /// The type of the property store object to retrieve. This is typically IPropertyStore. /// Type: HWND /// A handle to the window whose properties are being retrieved. /// /// When this function returns, contains the interface pointer requested in . This is typically IPropertyStore. /// /// /// /// 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 ); [PInvokeData("shellapi.h", MSDNShortId = "772aa2c8-6dd1-480c-a008-58f30902cb80")] public static TIntf SHGetPropertyStoreForWindow(HWND hwnd) where TIntf : class => IidGetObj((in Guid g, out object o) => SHGetPropertyStoreForWindow(hwnd, g, out o)); /// /// 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(HKEY 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(HWND 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(); /// /// Retrieves the size of the Recycle Bin and the number of items in it, for a specified drive. /// /// /// Type: LPCTSTR /// /// The address of a null-terminated string of maximum length MAX_PATH to contain 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 (C:\Windows\System...). /// /// /// /// Type: LPSHQUERYRBINFO /// /// The address of a SHQUERYRBINFO structure that receives the Recycle Bin information. The cbSize member of the structure /// must be set to the size of the structure before calling this API. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// With Windows 2000, if NULL is passed in the parameter, the function fails and returns an E_INVALIDARG error code. In /// earlier versions of the operating system, you can pass an empty string or NULL. If contains an empty string or /// NULL, information is retrieved for all Recycle Bins on all drives. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shqueryrecyclebina SHSTDAPI SHQueryRecycleBinA( LPCSTR // pszRootPath, LPSHQUERYRBINFO pSHQueryRBInfo ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shellapi.h", MSDNShortId = "a9a80486-2c99-4916-af25-10b00573456b")] public static extern HRESULT SHQueryRecycleBin(string pszRootPath, ref SHQUERYRBINFO pSHQueryRBInfo); /// /// Checks the state of the computer for the current user to determine whether sending a notification is appropriate. /// /// /// Type: QUERY_USER_NOTIFICATION_STATE* /// When this function returns, contains a pointer to one of the values of the QUERY_USER_NOTIFICATION_STATE enumeration. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// Applications should call SHQueryUserNotificationState and test the return value before displaying any notification UI that /// is similar to the balloon notifications generated by Shell_NotifyIcon. Notifications should only be displayed if this API returns /// QNS_ACCEPTS_NOTIFICATIONS. This informs the application whether the user is running processes that should not be interrupted. /// Top-level windows receive a WM_SETTINGCHANGE message when the user turns presentation settings on or off, and also when the /// user's session is locked or unlocked. Note that there are no notifications sent when the user starts or stops a full-screen application. /// /// If this function returns QUNS_QUIET_TIME, notifications should be displayed only if critical. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shqueryusernotificationstate SHSTDAPI // SHQueryUserNotificationState( QUERY_USER_NOTIFICATION_STATE *pquns ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "da6b3915-f4fe-4bab-9bae-9bff0b97b5a0")] public static extern HRESULT SHQueryUserNotificationState(out QUERY_USER_NOTIFICATION_STATE pquns); /// /// Removes the localized name of a file in a Shell folder. /// /// /// Type: PCWSTR /// A pointer to a null-terminated, Unicode string that specifies the fully qualified path of the target file. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// When a display name string is set by SHSetLocalizedName, Windows Explorer uses that string for display instead of the file name. /// The path to the file is unchanged. /// /// /// Applications can use the IShellFolder::GetDisplayNameOf method to get the display (localized) name through with the /// SIGDN_NORMALDISPLAY flag and the parsing (non-localized) name with SIGDN_DESKTOPABSOLUTEPARSING. /// /// Calling SHRemoveLocalizedName makes the display name identical to the parsing name. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shremovelocalizedname SHSTDAPI SHRemoveLocalizedName( // PCWSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "ed30546f-3531-42df-9018-1a24a79a0b79")] public static extern HRESULT SHRemoveLocalizedName([MarshalAs(UnmanagedType.LPWStr)] string pszPath); /// /// Sets 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 target file. /// /// /// Type: PCWSTR /// A pointer to a string resource that specifies the localized version of the file name. /// /// /// Type: int /// An integer ID that specifies the localized file name in the string resource. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// When this string is set, Explorer displays this string instead of the file name. The path to the file is unchanged. /// /// Applications can get the display (localized) name with IShellFolder::GetDisplayNameOf with the SIGDN_NORMALDISPLAY flag and the /// parsing (non-localized) name with IShellItem::GetDisplayName using the SIGDN_DESKTOPABSOLUTEPARSING flag. /// /// Calling SHRemoveLocalizedName makes the display name identical to the parsing name. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shsetlocalizedname SHSTDAPI SHSetLocalizedName( PCWSTR // pszPath, PCWSTR pszResModule, int idsRes ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shellapi.h", MSDNShortId = "35b83fc8-3dad-4f08-a3fe-ce047b2ca3a2")] public static extern HRESULT SHSetLocalizedName(string pszPath, string pszResModule, int idsRes); /// /// Stores the current user's unread message count for a specified email account in the registry. /// /// /// Type: LPCTSTR /// A pointer to a string in Unicode that contains the current user's full email address. /// /// /// Type: DWORD /// The number of unread messages. /// /// /// Type: LPCTSTR /// /// A pointer to a string in Unicode that contains the full text of a command that can be passed to ShellExecute. This command should /// start the email application that owns the account referenced by . /// /// /// /// Type: HRESULT /// HRESULT, which includes the following possible values. /// /// /// Return code /// Description /// /// /// S_OK /// The call completed successfully. /// /// /// E_OUTOFMEMORY /// Insufficient memory available. /// /// /// E_INVALIDARG /// Invalid string argument in either the or parameters. /// /// /// /// /// When this function updates the registry, the new registry entry is automatically stamped with the current time and date. /// /// If this function is called by different independent software vendors (ISVs) that specify the same email name, only the last call /// is saved. That is, calls to this function overwrite any previously saved value for the same email address, even if the calls are /// made by different ISVs. /// /// /// It is recommended that the count of unread messages be set only for the main Inbox of the users account. Mail in sub-folders such /// as Drafts or Deleted Items should be ignored. /// /// /// It is important that email clients do not set the number of unread messages to 0 when the application exits, because this causes /// the number of unread messages to be erroneously reported as 0. /// /// Because this function uses HKEY_CURRENT_USER, it should not be called by a system process impersonating a user. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shsetunreadmailcountw HRESULT SHSetUnreadMailCountW( // LPCWSTR pszMailAddress, DWORD dwCount, LPCWSTR pszShellExecuteCommand ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shellapi.h", MSDNShortId = "4a0e1ade-8df1-41b5-b6ea-dad427b50f5a")] public static extern HRESULT SHSetUnreadMailCountW(string pszMailAddress, uint dwCount, string pszShellExecuteCommand); /// /// Uses CheckTokenMembership to test whether the given token is a member of the local group with the specified RID. /// /// /// Type: HANDLE /// A handle to the token. This value can be NULL. /// /// /// Type: ULONG /// The RID of the local group for which membership is tested. /// /// /// Type: BOOL /// Returns TRUE on success, FALSE on failure. /// /// /// This function wraps CheckTokenMembership and only checks local groups. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/nf-shellapi-shtesttokenmembership BOOL SHTestTokenMembership( HANDLE // hToken, ULONG ulRID ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shellapi.h", MSDNShortId = "ac2d591a-f431-4da7-aa9f-0476634ec9cf")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SHTestTokenMembership(HTOKEN hToken, uint ulRID); /// /// Contains information about a system appbar message. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_appbardata typedef struct _AppBarData { DWORD cbSize; // HWND hWnd; UINT uCallbackMessage; UINT uEdge; RECT rc; LPARAM lParam; } APPBARDATA, *PAPPBARDATA; [PInvokeData("shellapi.h", MSDNShortId = "cf86fe15-4beb-49b7-b73e-2ad61cedc3f8")] public struct APPBARDATA { /// /// Type: DWORD /// The size of the structure, in bytes. /// public uint cbSize; /// /// Type: HWND /// /// The handle to the appbar window. Not all messages use this member. See the individual message page to see if you need to /// provide an hWind value. /// /// public HWND hWnd; /// /// Type: LPARAM /// A message-dependent value. This member is used with these messages: /// ABM_SETAUTOHIDEBAR /// ABM_SETAUTOHIDEBAREX /// ABM_SETSTATE /// See the individual message pages for details. /// public IntPtr lParam; /// /// Type: RECT /// A RECT structure whose use varies depending on the message: /// /// /// ABM_GETTASKBARPOS, ABM_QUERYPOS, ABM_SETPOS: The bounding rectangle, in screen coordinates, of an appbar or the Windows taskbar. /// /// /// ABM_GETAUTOHIDEBAREX, ABM_SETAUTOHIDEBAREX: The monitor on which the operation is being performed. This information can be /// retrieved through the GetMonitorInfo function. /// /// /// public RECT rc; /// /// Type: UINT /// /// An application-defined message identifier. The application uses the specified identifier for notification messages that it /// sends to the appbar identified by the hWnd member. This member is used when sending the ABM_NEW message. /// /// public uint uCallbackMessage; /// /// Type: UINT /// A value that specifies an edge of the screen. This member is used when sending one of these messages: /// ABM_GETAUTOHIDEBAR /// ABM_SETAUTOHIDEBAR /// ABM_GETAUTOHIDEBAREX /// ABM_SETAUTOHIDEBAREX /// ABM_QUERYPOS /// ABM_SETPOS /// This member can be one of the following values. /// ABE_BOTTOM /// Bottom edge. /// ABE_LEFT /// Left edge. /// ABE_RIGHT /// Right edge. /// ABE_TOP /// Top edge. /// public ABE uEdge; } /// Defines information used by AssocCreateForClasses to retrieve an IQueryAssociations interface for a given file association. [PInvokeData("shellapi.h", MSDNShortId = "1d1a963f-7ebb-4ba6-9a97-795c8ef11ae4")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct ASSOCIATIONELEMENT { /// /// 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 HKEY hkClass; /// A pointer to the name of a class that contains association information. public string pszClass; } /// /// Contains information that the system needs to display notifications in the notification area. Used by Shell_NotifyIcon. /// /// /// /// 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 { /// Size of this structure, in bytes. public uint cbSize; /// /// 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 HWND hwnd; /// /// 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 HICON 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. /// 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 HICON 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 HWND 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 HWND 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: /// /// /// 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. /// [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. /// [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. /// [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. /// 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. /// public HINSTANCE 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. /// 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. /// /// /// /// 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. /// public HKEY 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. /// 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. /// 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. /// /// public HICON 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. /// public HPROCESS hProcess; /// Initializes a new instance of the struct. /// Name of the file. /// The parameters. public SHELLEXECUTEINFO(string fileName, string parameters = null) : this() { cbSize = Marshal.SizeOf(this); lpFile = fileName; lpParameters = parameters; nShellExecuteShow = ShowWindowCommand.SW_NORMAL; } } /// Contains information about a file object. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] [PInvokeData("Shellapi.h", MSDNShortId = "bb759792")] 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. /// public HICON hIcon; /// The index of the icon image within the system image list. 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. /// 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. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; /// A string that describes the type of file. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; /// Gets the size of this structure. /// The structure size in bytes. public static int Size => Marshal.SizeOf(typeof(SHFILEINFO)); } /// Contains information that the SHFileOperation function uses to perform file operations. [PInvokeData("Shellapi.h")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct SHFILEOPSTRUCT { /// A window handle to the dialog box to display information about the status of the file operation. public HWND hwnd; /// A value that indicates which operation to perform. public ShellFileOperation wFunc; /// /// 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. /// /// [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: /// /// /// /// 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. /// [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. /// 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. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpszProgressTitle; } /// /// Contains the size and item count information retrieved by the SHQueryRecycleBin function. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shellapi/ns-shellapi-_shqueryrbinfo typedef struct _SHQUERYRBINFO { DWORD // cbSize; __int64 i64Size; __int64 i64NumItems; DWORDLONG i64Size; DWORDLONG i64NumItems; } SHQUERYRBINFO, *LPSHQUERYRBINFO; [PInvokeData("shellapi.h", MSDNShortId = "7e9bc7e9-5712-45e7-a424-0afb62f26450")] [StructLayout(LayoutKind.Sequential)] public struct SHQUERYRBINFO { /// The size of the structure, in bytes. This member must be filled in prior to calling the function. public uint cbSize; /// The total size, in bytes, of all the items currently in the Recycle Bin. public long i64Size; /// The total number of items currently in the Recycle Bin. public long i64NumItems; } /// /// 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 HICON 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; } } }