using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Security; using System.Text; using Vanara.InteropServices; using static Vanara.PInvoke.AdvApi32; using static Vanara.PInvoke.ComCtl32; using static Vanara.PInvoke.Kernel32; using static Vanara.PInvoke.Ole32; using static Vanara.PInvoke.ShlwApi; // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedParameter.Global // ReSharper disable UnusedMember.Global // ReSharper disable FieldCanBeMadeReadOnly.Global // ReSharper disable InconsistentNaming // ReSharper disable MemberHidesStaticFromOuterClass // ReSharper disable UnusedMethodReturnValue.Global namespace Vanara.PInvoke { [SuppressUnmanagedCodeSecurity] public static partial class Shell32 { // Defined in wingdi.h private const int LF_FACESIZE = 32; /// A flag that controls how PifMgr_CloseProperties operates. [PInvokeData("shlobj_core.h", MSDNShortId = "fd50d4f8-87c8-4162-9e88-3c8592b929fa")] public enum CLOSEPROPS { /// No options specified. CLOSEPROPS_NONE = 0x0000, /// Abandon cached data. CLOSEPROPS_DISCARD = 0x0001 } /// Used for options in SHOpenFolderAndSelectItems. [PInvokeData("Shlobj.h", MSDNShortId = "bb762232")] public enum OFASI : uint { /// No options. OFASI_NONE = 0, /// /// Select an item and put its name in edit mode. This flag can only be used when a single item is being selected. For multiple item selections, it /// is ignored. /// OFASI_EDIT = 1, /// /// Select the item or items on the desktop rather than in a Windows Explorer window. Note that if the desktop is obscured behind open windows, it /// will not be made visible. /// OFASI_OPENDESKTOP = 2 } /// A flag that controls how PifMgr_OpenProperties operates. [PInvokeData("shlobj_core.h", MSDNShortId = "0bc11528-7278-4765-b3cb-671ba82c9155")] public enum OPENPROPS { /// No options specified. OPENPROPS_NONE = 0x0000, /// /// Ignore any existing .pif files and get the properties from win.ini or _Default.pif. This flag is ignored on Windows NT, /// Windows 2000, and Windows XP. /// OPENPROPS_INHIBITPIF = 0x8000 } /// Return values for PathCleanupSpec. [PInvokeData("shlobj_core.h", MSDNShortId = "593fd2b7-44ae-4309-a185-97e42f3cc0fa")] [Flags] public enum PCS : uint { /// The cleaned path is not a valid file name. This flag is always returned in conjunction with PCS_PATHTOOLONG. PCS_FATAL = 0x80000000, /// Replaced one or more invalid characters. PCS_REPLACEDCHAR = 0x00000001, /// Removed one or more invalid characters. PCS_REMOVEDCHAR = 0x00000002, /// The returned path is truncated. PCS_TRUNCATED = 0x00000004, /// /// The function failed because the input path specified at is too long to allow the formation of a valid file name from . When this /// flag is returned, it is always accompanied by the PCS_FATAL flag. /// PCS_PATHTOOLONG = 0x00000008, } /// Flags for PathResolve. [PInvokeData("shlobj_core.h", MSDNShortId = "84bf0b56-513f-4ac6-b2cf-11f0c471da1e")] [Flags] public enum PRF { /// Return TRUE if the file's existence is verified; otherwise FALSE. PRF_VERIFYEXISTS = 0x0001, /// Look for the specified path with the following extensions appended: .pif, .com, .bat, .cmd, .lnk, and .exe. PRF_TRYPROGRAMEXTENSIONS = 0x0002 | PRF_VERIFYEXISTS, /// Look first in the directory or directories specified by dirs. PRF_FIRSTDIRDEF = 0x0004, /// Ignore .lnk files. PRF_DONTFINDLNK = 0x0008, /// Require an absolute (full) path. PRF_REQUIREABSOLUTE = 0x0010 } /// Flags that direct the handling of the item from which you're retrieving the info tip text. This value is commonly zero (QITIPF_DEFAULT). [PInvokeData("Shlobj.h", MSDNShortId = "bb761357")] public enum QITIP { /// No special handling. QITIPF_DEFAULT = 0x00000000, /// Provide the name of the item in ppwszTip rather than the info tip text. QITIPF_USENAME = 0x00000001, /// If the item is a shortcut, retrieve the info tip text of the shortcut rather than its target. QITIPF_LINKNOTARGET = 0x00000002, /// If the item is a shortcut, retrieve the info tip text of the shortcut's target. QITIPF_LINKUSETARGET = 0x00000004, /// Search the entire namespace for the information. This value can result in a delayed response time. QITIPF_USESLOWTIP = 0x00000008, // Flag says it's OK to take a long time generating tip /// Windows Vista and later. Put the info tip on a single line. QITIPF_SINGLELINE = 0x00000010, } /// Indicates whether to enable or disable Async Register and Deregister for SHChangeNotifyRegisterThread. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ne-shlobj_core-scnrt_status // typedef enum SCNRT_STATUS { SCNRT_ENABLE , SCNRT_DISABLE } ; [PInvokeData("shlobj_core.h", MSDNShortId = "31fd993b-d8cb-40cc-9f31-15711dba1b10")] public enum SCNRT_STATUS { /// Enable Async Register and Deregister for SHChangeNotifyRegisterThread. SCNRT_ENABLE, /// Disable Async Register and Deregister for SHChangeNotifyRegisterThread. SCNRT_DISABLE, } /// /// Indicates the interpretation of the data passed by SHAddToRecentDocs in its pv parameter to identify the item whose usage statistics are being tracked. /// [PInvokeData("Shlobj.h", MSDNShortId = "dd378453")] public enum SHARD { /// /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFO structure that pairs an IShellItem that identifies the item with an /// AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFO = 4, /// /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOIDLIST structure that pairs an absolute PIDL that identifies the item with /// an AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFOIDLIST = 5, /// /// Windows 7 and later. The pv parameter points to a SHARDAPPIDINFOLINK structure that pairs an IShellLink that identifies the item with an /// AppUserModelID that associates it with a particular process or application. /// SHARD_APPIDINFOLINK = 7, /// Windows 7 and later. The pv parameter is an interface pointer to an IShellLink object. SHARD_LINK = 6, /// The pv parameter points to a null-terminated ANSI string with the path and file name of the object. SHARD_PATHA = 2, /// The pv parameter points to a null-terminated Unicode string with the path and file name of the object. SHARD_PATHW = 3, /// The pv parameter points to a PIDL that identifies the document's file object. PIDLs that identify non-file objects are not accepted. SHARD_PIDL = 1, /// Windows 7 and later. The pv parameter is an interface pointer to an IShellItem object. SHARD_SHELLITEM = 8 } /// Events used in SHChangeNotify. [PInvokeData("Shlobj_core.h")] [Flags] public enum SHCNE : uint { /// /// The name of a nonfolder item has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// previous PIDL or name of the item. dwItem2 contains the new PIDL or name of the item. /// SHCNE_RENAMEITEM = 0x00000001, /// /// A nonfolder item has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was /// created. dwItem2 is not used and should be NULL. /// SHCNE_CREATE = 0x00000002, /// /// A nonfolder item has been deleted. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that was /// deleted. dwItem2 is not used and should be NULL. /// SHCNE_DELETE = 0x00000004, /// /// A folder has been created. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was /// created. dwItem2 is not used and should be NULL. /// SHCNE_MKDIR = 0x00000008, /// /// A folder has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that was /// removed. dwItem2 is not used and should be NULL. /// SHCNE_RMDIR = 0x00000010, /// /// Storage media has been inserted into a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive that contains the new media. dwItem2 is not used and should be NULL. /// SHCNE_MEDIAINSERTED = 0x00000020, /// /// Storage media has been removed from a drive. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive from which the media was removed. dwItem2 is not used and should be NULL. /// SHCNE_MEDIAREMOVED = 0x00000040, /// /// A drive has been removed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was removed. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEREMOVED = 0x00000080, /// /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was added. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEADD = 0x00000100, /// /// A folder on the local computer is being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. /// dwItem1 contains the folder that is being shared. dwItem2 is not used and should be NULL. /// SHCNE_NETSHARE = 0x00000200, /// /// A folder on the local computer is no longer being shared via the network. SHCNF_IDLIST or SHCNF_PATH must be specified in /// uFlags. dwItem1 contains the folder that is no longer being shared. dwItem2 is not used and should be NULL. /// SHCNE_NETUNSHARE = 0x00000400, /// /// The attributes of an item or folder have changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains /// the item or folder that has changed. dwItem2 is not used and should be NULL. /// SHCNE_ATTRIBUTES = 0x00000800, /// /// The contents of an existing folder have changed, but the folder still exists and has not been renamed. SHCNF_IDLIST or /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the folder that has changed. dwItem2 is not used and should be NULL. /// If a folder has been created, deleted, or renamed, use SHCNE_MKDIR, SHCNE_RMDIR, or SHCNE_RENAMEFOLDER, respectively. /// SHCNE_UPDATEDIR = 0x00001000, /// /// An existing item (a folder or a nonfolder) has changed, but the item still exists and has not been renamed. SHCNF_IDLIST or /// SHCNF_PATH must be specified in uFlags. dwItem1 contains the item that has changed. dwItem2 is not used and should be NULL. /// If a nonfolder item has been created, deleted, or renamed, use SHCNE_CREATE, SHCNE_DELETE, or SHCNE_RENAMEITEM, respectively, instead. /// SHCNE_UPDATEITEM = 0x00002000, /// /// The computer has disconnected from a server. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// server from which the computer was disconnected. dwItem2 is not used and should be NULL. /// SHCNE_SERVERDISCONNECT = 0x00004000, /// /// An image in the system image list has changed. SHCNF_DWORD must be specified in uFlags. dwItem2 contains the index in the /// system image list that has changed. dwItem1 is not used and should be NULL. /// SHCNE_UPDATEIMAGE = 0x00008000, /// /// A drive has been added. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the root of the drive that /// was added. dwItem2 is not used and should be NULL. /// SHCNE_DRIVEADDGUI = 0x00010000, /// /// The name of a folder has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the previous PIDL /// or name of the folder. dwItem2 contains the new PIDL or name of the folder. /// SHCNE_RENAMEFOLDER = 0x00020000, /// /// The amount of free space on a drive has changed. SHCNF_IDLIST or SHCNF_PATH must be specified in uFlags. dwItem1 contains the /// root of the drive on which the free space changed. dwItem2 is not used and should be NULL. /// SHCNE_FREESPACE = 0x00040000, /// Not currently used. SHCNE_EXTENDED_EVENT = 0x04000000, /// /// A file type association has changed. SHCNF_IDLIST must be specified in the uFlags parameter. dwItem1 and dwItem2 are not used /// and must be NULL. This event should also be sent for registered protocols. /// SHCNE_ASSOCCHANGED = 0x08000000, /// All disk related events. SHCNE_DISKEVENTS = 0x0002381F, /// All global events. SHCNE_GLOBALEVENTS = 0x0C0581E0, /// All events. SHCNE_ALLEVENTS = 0x7FFFFFFF, /// /// The presence of this flag indicates that the event was generated by an interrupt. It is stripped out before the clients of /// SHCNNotify_ see it. /// SHCNE_INTERRUPT = 0x80000000, } /// Flags used in SHChangeNotify. [PInvokeData("Shlobj_core.h")] [Flags] public enum SHCNF : uint { /// /// dwItem1 and dwItem2 are the addresses of ITEMIDLIST structures that represent the item(s) affected by the change. Each /// ITEMIDLIST must be relative to the desktop folder. /// SHCNF_IDLIST = 0x0000, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHA = 0x0001, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected /// by the change. /// SHCNF_PRINTERA = 0x0002, /// The dwItem1 and dwItem2 parameters are DWORD values. SHCNF_DWORD = 0x0003, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings of maximum length MAX_PATH that contain the full path names /// of the items affected by the change. /// SHCNF_PATHW = 0x0005, /// /// dwItem1 and dwItem2 are the addresses of null-terminated strings that represent the friendly names of the printer(s) affected /// by the change. /// SHCNF_PRINTERW = 0x0006, /// Indicates that a type is defined. SHCNF_TYPE = 0x00FF, /// /// The function should not return until the notification has been delivered to all affected components. As this flag modifies /// other data-type flags, it cannot be used by itself. /// SHCNF_FLUSH = 0x1000, /// /// The function should begin delivering notifications to all affected components but should return as soon as the notification /// process has begun. As this flag modifies other data-type flags, it cannot by used by itself. This flag includes SHCNF_FLUSH. /// SHCNF_FLUSHNOWAIT = 0x3000, /// Notify clients registered for all children. SHCNF_NOTIFYRECURSIVE = 0x10000 } /// Receives a value that determines what type the item is in . [PInvokeData("Shlobj_core.h", MSDNShortId = "bb759775")] public enum SHDID { /// The item is a registered item on the desktop. SHDID_ROOT_REGITEM = 1, /// The item is a file. SHDID_FS_FILE = 2, /// The item is a folder. SHDID_FS_DIRECTORY = 3, /// The item is an unidentified item in the file system. SHDID_FS_OTHER = 4, /// The item is a 3.5-inch floppy drive. SHDID_COMPUTER_DRIVE35 = 5, /// The item is a 5.25-inch floppy drive. SHDID_COMPUTER_DRIVE525 = 6, /// The item is a removable disk. SHDID_COMPUTER_REMOVABLE = 7, /// The item is a fixed hard disk. SHDID_COMPUTER_FIXED = 8, /// The item is a drive that is mapped to a network share. SHDID_COMPUTER_NETDRIVE = 9, /// The item is a CD-ROM drive. SHDID_COMPUTER_CDROM = 10, /// The item is a RAM disk. SHDID_COMPUTER_RAMDISK = 11, /// The item is an unidentified system device. SHDID_COMPUTER_OTHER = 12, /// The item is a network domain. SHDID_NET_DOMAIN = 13, /// The item is a network server. SHDID_NET_SERVER = 14, /// The item is a network share. SHDID_NET_SHARE = 15, /// Not currently used. SHDID_NET_RESTOFNET = 16, /// The item is an unidentified network resource. SHDID_NET_OTHER = 17, /// Windows XP and later. Not currently used. SHDID_COMPUTER_IMAGING = 18, /// Windows XP and later. Not currently used. SHDID_COMPUTER_AUDIO = 19, /// Windows XP and later. The item is the system shared documents folder. SHDID_COMPUTER_SHAREDDOCS = 20, /// Windows Vista and later. The item is a mobile device, such as a personal digital assistant (PDA). SHDID_MOBILE_DEVICE = 21, } /// The format in which the data is being requested. [PInvokeData("Shlobj.h", MSDNShortId = "bb762174")] public enum SHGetDataFormat { /// Format used for file system objects. The pv parameter is the address of a WIN32_FIND_DATA structure. [CorrespondingType(typeof(WIN32_FIND_DATA), CorrepsondingAction.Get)] SHGDFIL_FINDDATA = 1, /// Format used for network resources. The pv parameter is the address of a NETRESOURCE structure. // TODO: Define NETRESOURCE (https://msdn.microsoft.com/en-us/library/windows/desktop/aa385353(v=vs.85).aspx) //[CorrespondingType(typeof(NETRESOURCE), CorrepsondingAction.Get)] SHGDFIL_NETRESOURCE = 2, /// Version 4.71. Format used for network resources. The pv parameter is the address of an SHDESCRIPTIONID structure. [CorrespondingType(typeof(SHDESCRIPTIONID), CorrepsondingAction.Get)] SHGDFIL_DESCRIPTIONID = 3 } /// Flags used by . [PInvokeData("Shlobj.h", MSDNShortId = "bb762181")] public enum SHGFP { /// Retrieve the folder's current path. SHGFP_TYPE_CURRENT = 0, /// Retrieve the folder's default path. SHGFP_TYPE_DEFAULT = 1 } /// Used by SHGetImageList. [PInvokeData("Shlobj.h", MSDNShortId = "bb762185")] public enum SHIL { /// /// The image size is normally 32x32 pixels. However, if the Use large icons option is selected from the Effects section of the Appearance tab in /// Display Properties, the image is 48x48 pixels. /// SHIL_LARGE = 0, /// These images are the Shell standard small icon size of 16x16, but the size can be customized by the user. SHIL_SMALL = 1, /// These images are the Shell standard extra-large icon size. This is typically 48x48, but the size can be customized by the user. SHIL_EXTRALARGE = 2, /// These images are the size specified by GetSystemMetrics called with SM_CXSMICON and GetSystemMetrics called with SM_CYSMICON. SHIL_SYSSMALL = 3, /// Windows Vista and later. The image is normally 256x256 pixels. SHIL_JUMBO = 4, } /// /// CSIDL (constant special item ID list) values provide a unique system-independent way to identify special folders used frequently by applications, but /// which may not have the same name or location on any given system. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on /// another. These constants are defined in Shlobj.h. /// [PInvokeData("Shlobj.h", MSDNShortId = "bb762494")] internal enum CSIDL { CSIDL_ADMINTOOLS = 0x0030, CSIDL_CDBURN_AREA = 0x003b, CSIDL_COMMON_ADMINTOOLS = 0x002f, CSIDL_COMMON_DESKTOPDIRECTORY = 0x0019, CSIDL_COMMON_DOCUMENTS = 0x002e, CSIDL_COMMON_MUSIC = 0x0035, CSIDL_COMMON_OEM_LINKS = 0x003a, CSIDL_COMMON_PICTURES = 0x0036, CSIDL_COMMON_PROGRAMS = 0X0017, CSIDL_COMMON_STARTMENU = 0x0016, CSIDL_COMMON_STARTUP = 0x0018, CSIDL_COMMON_TEMPLATES = 0x002d, CSIDL_COMMON_VIDEO = 0x0037, CSIDL_FLAG_CREATE = 0x8000, // force folder creation in SHGetFolderPath CSIDL_FLAG_DONT_VERIFY = 0x4000, // return an unverified folder path CSIDL_FONTS = 0x0014, // windows\fonts CSIDL_MYVIDEO = 0x000e, // "My Videos" folder CSIDL_NETHOOD = 0x0013, // %APPDATA%\Microsoft\Windows\Network Shortcuts CSIDL_PRINTHOOD = 0x001b, // %APPDATA%\Microsoft\Windows\Printer Shortcuts CSIDL_PROFILE = 0x0028, // %USERPROFILE% (%SystemDrive%\Users\%USERNAME%) CSIDL_PROGRAM_FILES_COMMONX86 = 0x002c, // x86 Program Files\Common on RISC CSIDL_PROGRAM_FILESX86 = 0x002a, // x86 C:\Program Files on RISC CSIDL_RESOURCES = 0x0038, // %windir%\Resources CSIDL_RESOURCES_LOCALIZED = 0x0039, // %windir%\resources\0409 (code page) CSIDL_SYSTEMX86 = 0x0029, // %windir%\system32 CSIDL_WINDOWS = 0x0024, // GetWindowsDirectory() } /// /// Retrieves the value for a given property key using the file association information provided by the Namespace Extensions. /// /// /// Type: IShellFolder* /// A pointer to the shell folder for which the details of the property key of the file association are being retrieved. /// /// /// Type: PCUITEMID_CHILD /// The PIDL of the child item for which the file associations are being requested. /// /// /// Type: PROPERTYKEY* /// A pointer to the property key that is being retrieved. /// /// /// Type: VARIANT* /// When this function returns, contains the details of the given property key. /// /// /// Type: BOOL* /// When this function returns, contains a flag that is TRUE if the property key was found, otherwise FALSE. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// This function is to be used only by implementers of IShellFolder Namespace Extensions. Other calling applications should use /// IShellFolder2::GetDetailsEx to get a value for a PROPERTYKEY. This function is to be used by implementers of IShellFolder /// Namespace Extensions. /// /// The provided namespace extension must support the use of this API in one of the following three ways. /// /// /// If the provided Namespace Extensions supports retrieving an IQueryAssociations interface for the item by implementing /// IShellFolder::GetUIObjectOf(..., IID_IQueryAssociations, ...), then AssocGetDetailsOfPropKey will use the provided /// file associations API to retrieve the value for the property key. /// /// /// If the provided namespace extension returns SFGAO_FILESYSTEM for the item from IShellFolder::GetAttributesOf and provides /// a parsing name for the item, then AssocGetDetailsOfPropKey will use the standard file system associations to retrieve the /// value for the property key. /// /// /// If the provided namespace extension returns SFGAO_FOLDER | SFGAO_BROWSABLE for the item from /// IShellFolder::GetAttributesOf, then AssocGetDetailsOfPropKey will use the file association for folders ( /// ASSOCCLASS_FOLDER) to retrieve the value for the property key. /// /// /// /// If the ShellFolder being implemented contains items that are extensible through the file associations mechanism, then you can use /// this function to retrieve /// /// PropertyKeys /// /// that are declared for a given file association. For example, if a given Shell folder drives a details pane and you want the /// properties displayed in that pane to be governed by third party file name extensions, then you can use this function to return /// /// PKEY_PropList_PreviewDetails /// /// . This key has a value that is declared in the registry for that file name extension with a semicolon delimited list of /// properties. There is a list of file name extension defined properties in the registry. This list includes but is not limited to /// the following: /// /// /// PKEY_PropList_PreviewDetails /// PKEY_PropList_PreviewTitle /// PKEY_PropList_FullDetails /// PKEY_PropList_TileInfo /// PKEY_PropList_ExtendedTileInfo /// PKEY_PropList_InfoTip /// PKEY_PropList_QuickTip /// PKEY_PropList_FileOperationPrompt /// PKEY_PropList_ConflictPrompt /// PKEY_PropList_SetDefaultsFor /// PKEY_PropList_NonPersonal /// PKEY_NewMenuPreferredTypes /// PKEY_NewMenuAllowedTypes /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-assocgetdetailsofpropkey // SHSTDAPI AssocGetDetailsOfPropKey( IShellFolder *psf, PCUITEMID_CHILD pidl, const PROPERTYKEY *pkey, VARIANT *pv, BOOL *pfFoundPropKey ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "f13af5f4-1b6a-419c-a042-e05c9ec51d02")] public static extern HRESULT AssocGetDetailsOfPropKey(IShellFolder psf, PIDL pidl, ref PROPERTYKEY pkey, ref object pv, [MarshalAs(UnmanagedType.Bool)] ref bool pfFoundPropKey); /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable in subsequent versions of Windows.]Creates an Open dialog box so that the user can specify the drive, directory, and name of a file to open.Type: HWNDA handle to the window that owns the dialog box. This member can be any valid window handle, or it can be NULL if the dialog box has no owner.Type: PWSTRA null-terminated Unicode string that contains a file name used to initialize the File Name edit control. This string corresponds to the OPENFILENAME structure's lpstrFile member and is used in exactly the same way.Type: UINTThe number of characters in , including the terminating null character.Type: PCWSTRThe fully qualified file path of the initial directory. This string corresponds to the OPENFILENAME structure's lpstrInitialDir member and is used in exactly the same way.Type: PCWSTRA null-terminated Unicode string that contains the default file name extension. This extension is added to if the user does not specify an extension. The string should not contain any '.' characters. If this string is NULL and the user fails to type an extension, no extension is appended.Type: PCWSTRA null-terminated Unicode string that defines the filter. This string corresponds to the OPENFILENAME structure's lpstrFilter member and is used in exactly the same way.TBDType: BOOLIf the user specifies a file name and clicks OK, the return value is TRUE. The buffer that points to contains the full path and file name that the user specifies. If the user cancels or closes the Open dialog box or an error occurs, the return value is FALSE. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-getfilenamefrombrowse // BOOL GetFileNameFromBrowse( HWND hwnd, PWSTR pszFilePath, UINT cchFilePath, PCWSTR pszWorkingDir, PCWSTR pszDefExt, PCWSTR pszFilters, PCWSTR pszTitle ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj.h", MSDNShortId = "1f075051-18c8-4ec2-b010-f983ba2d3303")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool GetFileNameFromBrowse(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint cchFilePath, [MarshalAs(UnmanagedType.LPWStr)] string pszWorkingDir, [MarshalAs(UnmanagedType.LPWStr)] string pszDefExt, [MarshalAs(UnmanagedType.LPWStr)] string pszFilters, [MarshalAs(UnmanagedType.LPWStr)] string pszTitle); /// /// Appends or prepends an SHITEMID structure to an ITEMIDLIST structure. /// /// /// Type: PIDLIST_RELATIVE /// A pointer to an ITEMIDLIST structure. When the function returns, the SHITEMID structure specified by is appended or prepended. /// /// /// Type: LPSHITEMID /// A pointer to a SHITEMID structure to be appended or prepended to . /// /// /// Type: BOOL /// Value that is set to TRUE to append to . Set this value to FALSE to prepend to . /// /// /// Type: PIDLIST_RELATIVE /// Returns the ITEMIDLIST structure specified by , with appended or prepended. Returns NULL on failure. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilappendid // PIDLIST_RELATIVE ILAppendID( PIDLIST_RELATIVE pidl, LPCSHITEMID pmkid, BOOL fAppend ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "d1bb5993-fe23-42d4-a2c5-8e54e6e37d09")] public static extern IntPtr ILAppendID(IntPtr pidl, ref SHITEMID pmkid, [MarshalAs(UnmanagedType.Bool)] bool fAppend); /// Determines whether a specified ITEMIDLIST structure is the child of another ITEMIDLIST structure.Type: PCIDLIST_ABSOLUTEA pointer to the parent ITEMIDLIST structure.Type: PCIDLIST_ABSOLUTEA pointer to the child ITEMIDLIST structure.Type: PUIDLIST_RELATIVEReturns a pointer to the child's simple ITEMIDLIST structure if is a child of . The returned structure consists of , minus the SHITEMID structures that make up . Returns NULL if is not a child of .Note The returned pointer is a pointer into the existing parent structure. It is an alias for . No new memory is allocated in association with the returned pointer. It is not the caller's responsibility to free the returned value. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilfindchild // PUIDLIST_RELATIVE ILFindChild( PIDLIST_ABSOLUTE pidlParent, PCIDLIST_ABSOLUTE pidlChild ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4f07e989-ae74-4cf4-b3d9-0f59f2653095")] public static extern IntPtr ILFindChild(IntPtr pidlParent, IntPtr pidlChild); /// /// [ /// ILLoadFromStreamEx(IStream*, PIDLIST_ABSOLUTE*) /// /// is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in /// subsequent versions.] /// /// Loads an absolute ITEMIDLIST from an IStream. /// /// /// Type: IStream* /// A pointer to the IStream interface from which the absolute ITEMIDLIST loads. /// /// /// TBD /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// For use where STRICT_TYPED_ITEMIDS is defined. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-illoadfromstreamex // SHSTDAPI ILLoadFromStreamEx( IStream *pstm, PIDLIST_RELATIVE *pidl ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "6fb735b6-a8c3-439e-9f20-4fda8f008b28")] public static extern HRESULT ILLoadFromStreamEx(IStream pstm, out IntPtr pidl); /// /// Saves an ITEMIDLIST structure to a stream. /// /// /// Type: IStream * /// A pointer to the IStream interface where the ITEMIDLIST is saved. /// /// /// Type: PCUIDLIST_RELATIVE /// A pointer to the ITEMIDLIST structure to be saved. /// /// /// Type: HRESULT /// Returns S_OK if successful, or a COM error value otherwise. /// /// /// The stream must be opened for writing, or ILSaveToStream returns an error. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-ilsavetostream // SHSTDAPI ILSaveToStream( IStream *pstm, PCUIDLIST_RELATIVE pidl ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "40d5ce57-58dc-4c79-8fe6-5412e3d7dc64")] public static extern HRESULT ILSaveToStream(IStream pstm, IntPtr pidl); /// /// /// [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 /// /// GetDriveType /// or /// WNetGetConnection /// instead.] /// Tests whether a drive is a network drive. /// /// /// Type: int /// An integer that indicates which drive letter you want to test. Set it to 0 for A:, 1 for B:, and so on. /// /// /// Type: int /// This function returns one of the following values. /// /// /// Return value /// Description /// /// /// 0 /// The specified drive is not a network drive. /// /// /// 1 /// The specified drive is a network drive that is properly connected. /// /// /// 2 /// The specified drive is a network drive that is disconnected or in an error state. /// /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isnetdrive // int IsNetDrive( int iDrive ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "44e02665-648a-4cf0-9dc0-038e54d08a49")] public static extern int IsNetDrive(int iDrive); /// /// [IsUserAnAdmin is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in /// subsequent versions.] /// /// Tests whether the current user is a member of the Administrator's group. /// /// /// Type: BOOL /// Returns TRUE if the user is a member of the Administrator's group; otherwise, FALSE. /// /// /// /// This function is a wrapper for CheckTokenMembership. It is recommended to call that function directly to determine Administrator /// group status rather than calling IsUserAnAdmin. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-isuseranadmin // BOOL IsUserAnAdmin( ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "fe698d32-32f6-4b2b-ad0c-5d9ec815177f")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool IsUserAnAdmin(); /// /// /// [OpenRegStream is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions. Instead, use SHOpenRegStream2 or SHOpenRegStream.] /// /// Opens a registry value and supplies an IStream interface that can be used to read from or write to the value. /// /// /// Type: HKEY /// A handle to the key that is currently open. /// /// /// Type: PCWSTR /// A null-terminated Unicode string that specifies the name of the subkey. /// /// /// Type: PCWSTR /// A null-terminated Unicode string that specifies the value to be accessed. /// /// /// Type: DWORD /// The type of access for the stream. This can be one of the following values. /// STGM_READ /// Open the stream for reading. /// STGM_WRITE /// Open the stream for writing. /// STGM_READWRITE /// Open the stream for reading and writing. /// /// /// Type: IStream* /// Returns the address of an IStream interface if successful, or NULL otherwise. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-openregstream // IStream * OpenRegStream( HKEY hkey, PCWSTR pszSubkey, PCWSTR pszValue, DWORD grfMode ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "e1e35c94-84ac-4aa1-b2a1-47b37a7f224e")] public static extern IStream OpenRegStream(IntPtr hkey, [MarshalAs(UnmanagedType.LPWStr)] string pszSubkey, [MarshalAs(UnmanagedType.LPWStr)] string pszValue, STGM grfMode); /// /// [PathCleanupSpec is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in /// subsequent versions.] /// /// /// Removes illegal characters from a file or directory name. Enforces the 8.3 filename format on drives that do not support long /// file names. /// /// /// /// Type: PCWSTR /// /// A pointer to a null-terminated buffer that contains the fully qualified path of the directory that will contain the file or /// directory named at . The path must not exceed MAX_PATH characters in length, including the terminating null character. This path /// is not altered. /// /// This value can be NULL. /// /// /// Type: PWSTR /// /// A pointer to a null-terminated buffer that contains the file or directory name to be cleaned. In the case of a file, include the /// file's extension. Note that because '' is considered an invalid character and will be removed, this buffer cannot contain a path /// more than one directory deep. /// /// On exit, the buffer contains a null-terminated string that includes the cleaned name. /// This buffer should be at least MAX_PATH characters in length to avoid the possibility of a buffer overrun. /// /// /// Type: int /// Returns one or more of the following values. /// /// /// Return code /// Description /// /// /// PCS_REPLACEDCHAR /// Replaced one or more invalid characters. /// /// /// PCS_REMOVEDCHAR /// Removed one or more invalid characters. /// /// /// PCS_TRUNCATED /// The returned path is truncated. /// /// /// PCS_PATHTOOLONG /// /// The function failed because the input path specified at is too long to allow the formation of a valid file name from . When this /// flag is returned, it is always accompanied by the PCS_FATAL flag. /// /// /// /// PCS_FATAL /// The cleaned path is not a valid file name. This flag is always returned in conjunction with PCS_PATHTOOLONG. /// /// /// /// /// The following are considered invalid characters in all names. /// /// Control characters are also considered invalid. If long file names are not supported, the semi-colon (;) and comma (,) characters /// are also invalid. /// /// /// The drive named in is checked to determine whether its file system supports long file names. If it does not, the name at is /// truncated to the 8.3 format and the PCS_TRUNCATED value returned. If is NULL, the drive on which Windows is installed is /// used to determine long file name support. /// /// /// If the full path—the number of characters in the path at plus the number of characters in the cleaned name at —exceeds MAX_PATH – /// 1 (to account for the terminating null character), the function returns PCS_PATHTOOLONG. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathcleanupspec // int PathCleanupSpec( PCWSTR pszDir, PWSTR pszSpec ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "593fd2b7-44ae-4309-a185-97e42f3cc0fa")] public static extern PCS PathCleanupSpec([MarshalAs(UnmanagedType.LPWStr)] string pszDir, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszSpec); /// /// [PathGetShortPath is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in /// subsequent versions.] /// /// Retrieves the short path form of a specified input path. /// /// /// Type: PWSTR /// /// A pointer to a null-terminated, Unicode string that contains the long path. When the function returns, it contains the equivalent /// short path. /// /// /// /// This function does not return a value. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathgetshortpath // void PathGetShortPath( PWSTR pszLongPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "f374a575-3fbf-4bed-aa76-76ed81e01d60")] public static extern void PathGetShortPath([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszLongPath); /// /// /// [PathIsExe is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable /// in subsequent versions.] /// /// Determines whether a file is an executable by examining the file name extension. /// /// /// TBD /// /// /// Type: BOOL /// Returns TRUE if the file name extension is .cmd, .bat, .pif, .scf, .exe, .com, or .scr; otherwise, FALSE. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathisexe // BOOL PathIsExe( PCWSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "54e9dae7-f9c4-48b8-9b91-32ed21365fb7")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathIsExe([MarshalAs(UnmanagedType.LPWStr)] string pszPath); /// /// /// [PathIsSlow is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable /// in subsequent versions.] /// /// Determines whether a file path is a high-latency network connection. /// /// /// Type: LPCTSTR /// A pointer to a null-terminated string that contains the fully qualified path of the file. /// /// /// TBD /// /// /// Type: BOOL /// Returns TRUE if the connection is high-latency; otherwise, FALSE. /// /// /// /// A path is considered slow if the MultinetGetConnectionPerformance function returns a dwSpeed of 400 or less in its /// NETCONNECTINFOSTRUCT structure—this is the speed of the media to the network resource, in 100 bits-per-second (bps)—or if /// FILE_ATTRIBUTE_OFFLINE is set on the file. /// /// Note that network conditions can impact function performance time. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-pathisslowa // BOOL PathIsSlowA( LPCSTR pszFile, DWORD dwAttr ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj.h", MSDNShortId = "f848a098-9248-453b-a957-77c35d70e528")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathIsSlow(string pszFile, uint dwAttr); /// /// Creates a unique path name from a template. /// /// /// Type: PWSTR /// /// A buffer that receives a null-terminated Unicode string that contains the unique path name. It should be at least MAX_PATH /// characters in length. /// /// /// /// Type: UINT /// The number of characters in the buffer pointed to by . /// /// /// Type: PCWSTR /// /// A null-terminated Unicode string that contains a template that is used to construct the unique name. This template is used for /// drives that require file names with the 8.3 format. This string should be no more than MAX_PATH characters in length, including /// the terminating null character. /// /// /// /// Type: PCWSTR /// /// A null-terminated Unicode string that contains a template that is used to construct the unique name. This template is used for /// drives that support long file names. This string should be no more than MAX_PATH characters in length, including the terminating /// null character. /// /// /// /// Type: PCWSTR /// /// A null-terminated string that contains the directory in which the new file resides. This string should be no more than MAX_PATH /// characters in length, including the terminating null character. /// /// /// /// Type: BOOL /// Returns TRUE if successful; otherwise, FALSE. /// /// /// /// This function generates a new unique file name based on the templates specified by , for drives that require the 8.3 format, and /// for drives that support long file names. For example, if you specify "My New Filename" for , PathMakeUniqueName returns /// names such as "My New Filename (1)", "My New Filename (2)", and so on. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathmakeuniquename // BOOL PathMakeUniqueName( PWSTR pszUniqueName, UINT cchMax, PCWSTR pszTemplate, PCWSTR pszLongPlate, PCWSTR pszDir ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "8456ae0c-e83c-43d0-a86a-1861a373d237")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathMakeUniqueName([MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszUniqueName, uint cchMax, [MarshalAs(UnmanagedType.LPWStr)] string pszTemplate, [MarshalAs(UnmanagedType.LPWStr)] string pszLongPlate, [MarshalAs(UnmanagedType.LPWStr)] string pszDir); /// /// /// [PathResolve is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// Converts a relative or unqualified path name to a fully qualified path name. /// /// /// Type: PWSTR /// /// A null-terminated Unicode string that contains the path to resolve. When the function returns, the string contains the /// corresponding fully qualified path. This buffer should be at least MAX_PATH characters long. /// /// /// /// Type: PZPCWSTR /// /// A pointer to an optional null-terminated array of directories to be searched first in the case that the path cannot be resolved /// from . This value can be NULL. /// /// /// /// Type: UINT /// Flags that specify how the function operates. /// PRF_VERIFYEXISTS /// Return TRUE if the file's existence is verified; otherwise FALSE. /// PRF_TRYPROGRAMEXTENSIONS /// Look for the specified path with the following extensions appended: .pif, .com, .bat, .cmd, .lnk, and .exe. /// PRF_FIRSTDIRDEF /// Look first in the directory or directories specified by . /// PRF_DONTFINDLNK /// Ignore .lnk files. /// PRF_REQUIREABSOLUTE /// Require an absolute (full) path. /// /// /// Type: int /// /// Returns TRUE, unless PRF_VERIFYEXISTS is set. If that flag is set, the function returns TRUE if the file is /// verified to exist and FALSE otherwise. It also sets an ERROR_FILE_NOT_FOUND error code that you can retrieve by calling GetLastError. /// /// /// /// /// A FALSE return value does not necessarily mean that the file does not exist. It might mean that the function is simply /// unable to find the file from the supplied information. /// /// If PathResolve cannot resolve the path specified in , it calls PathFindOnPath using and as the parameters. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathresolve // int PathResolve( PWSTR pszPath, PZPCWSTR dirs, UINT fFlags ); [DllImport(Lib.Shell32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shlobj_core.h", MSDNShortId = "84bf0b56-513f-4ac6-b2cf-11f0c471da1e")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathResolve(StringBuilder pszPath, string[] dirs, PRF fFlags); /// /// Creates a unique filename based on an existing filename. /// /// /// Type: PWSTR /// /// A string buffer that receives a null-terminated Unicode string that contains the fully qualified path of the unique file name. /// This buffer should be at least MAX_PATH characters long to avoid causing a buffer overrun. /// /// /// /// Type: PCWSTR /// /// A null-terminated Unicode string that contains the fully qualified path of folder that will contain the new file. If is set to /// NULL, this string must contain a full destination path, ending with the long file name that the new file name will be base on. /// /// /// /// Type: PCWSTR /// /// A null-terminated Unicode string that contains the short file name that the unique name will be based on. Set this value to /// NULL to create a name based on the long file name. /// /// /// /// Type: PCWSTR /// A null-terminated Unicode string that contains the long file name that the unique name will be based on. /// /// /// Type: BOOL /// Returns TRUE if a unique name was successfully created; otherwise FALSE. /// /// /// /// If the generated path exceeds MAX_PATH characters, this function may return a truncated string in /// PathYetAnotherMakeUniqueName. In that case, the function returns FALSE. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pathyetanothermakeuniquename // BOOL PathYetAnotherMakeUniqueName( PWSTR pszUniqueName, PCWSTR pszPath, PCWSTR pszShort, PCWSTR pszFileSpec ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("shlobj_core.h", MSDNShortId = "1f76ecfa-6f2f-4dde-b05e-4252c92660d9")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PathYetAnotherMakeUniqueName(StringBuilder pszUniqueName, string pszPath, string pszShort, string pszFileSpec); /// /// /// [PickIconDlg is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// /// Displays a dialog box that allows the user to choose an icon from the selection available embedded in a resource such as an /// executable or DLL file. /// /// /// /// Type: HWND /// The handle of the parent window. This value can be NULL. /// /// /// Type: PWSTR /// /// A pointer to a string that contains the null-terminated, fully qualified path of the default resource that contains the icons. If /// the user chooses a different resource in the dialog, this buffer contains the path of that file when the function returns. This /// buffer should be at least MAX_PATH characters in length, or the returned path may be truncated. You should verify that the path /// is valid before using it. /// /// /// /// Type: UINT /// The number of characters in , including the terminating NULL character. /// /// /// Type: int* /// /// A pointer to an integer that on entry specifies the index of the initial selection and, when this function returns successfully, /// receives the index of the icon that was selected. /// /// /// /// Type: int /// Returns 1 if successful; otherwise, 0. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pickicondlg // int PickIconDlg( HWND hwnd, PWSTR pszIconPath, UINT cchIconPath, int *piIconIndex ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "3dfcda10-26d8-495d-8c92-7ff16da098c1")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool PickIconDlg(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, uint cchIconPath, ref int piIconIndex); /// /// [PifMgr_CloseProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] /// Closes application properties that were opened with PifMgr_OpenProperties. /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. /// A flag that specifies how the function operates. /// Returns NULL if successful. If unsuccessful, the functions returns the handle to the application properties that was passed as hProps. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_closeproperties // HANDLE PifMgr_CloseProperties(HANDLE hProps, UINT flOpt); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "fd50d4f8-87c8-4162-9e88-3c8592b929fa")] public static extern IntPtr PifMgr_CloseProperties(IntPtr hProps, CLOSEPROPS flOpt); /// /// [PifMgr_GetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] /// Returns a specified block of data from a .pif file. /// A handle to an application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. /// A null-terminated string that contains the property group name. It can be one of the following, or any other name that corresponds to a valid .pif extension. /// When this function returns, contains a pointer to a PROPPRG structure. /// The size of the buffer, in bytes, pointed to by lpProps. /// Set this parameter to GETPROPS_NONE. /// Returns NULL if successful. If unsuccessful, the function returns the handle to the application properties that were passed as hProps. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_getproperties // int PifMgr_GetProperties( HANDLE hProps, PCSTR pszGroup, void* lpProps, int cbProps, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Ansi)] [PInvokeData("shlobj_core.h")] public static extern int PifMgr_GetProperties(IntPtr hProps, string pszGroup, IntPtr lpProps, int cbProps, uint flOpt = 0); /// /// /// [PifMgr_OpenProperties is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// Opens the .pif file associated with a Microsoft MS-DOS application, and returns a handle to the application's properties. /// /// /// Type: PCWSTR /// A null-terminated Unicode string that contains the application's name. /// /// /// TBD /// /// /// Type: UINT /// /// A handle to the application's .inf file. Set this value to zero if there is no .inf file. Set this value to -1 to prevent the /// .inf file from being processed. /// /// /// /// Type: UINT /// A flag that controls how the function operates. /// OPENPROPS_INHIBITPIF /// /// Ignore any existing .pif files and get the properties from win.ini or _Default.pif. This flag is ignored on Windows NT, Windows /// 2000, and Windows XP. /// /// OPENPROPS_NONE /// No options specified. /// /// /// Type: HANDLE /// Returns a handle to the application's properties. Use this handle when you call the related .pif functions. /// /// /// /// You should not think of PifMgr_OpenProperties as a function that opens a file somewhere. The .pif file does not remain /// open after this call. It is more useful to think of the function as a property structure allocator that you can initialize using /// disk data. The primary reason why this function fails is because of low memory or inability to open the specified .pif file. /// /// /// If no .pif file exists, the function still allocates a data block in memory and initializes it with data from _Default.pif or its /// internal defaults. If the function looks for a .pif file name but does not find it, it constructs a name and saves it in its /// internal .pif data structure. This guarantees that if PifMgr_SetProperties is called, the data is saved to disk. /// /// If the function does not find the .pif file, it searches for it in the following order. /// /// Searches the current directory. /// Searches the specified directory. /// Searches in .pif directory. /// Searches the folders specified by the PATH environment variable. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_openproperties // HANDLE PifMgr_OpenProperties( PCWSTR pszApp, PCWSTR pszPIF, UINT hInf, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "0bc11528-7278-4765-b3cb-671ba82c9155")] public static extern IntPtr PifMgr_OpenProperties([MarshalAs(UnmanagedType.LPWStr)] string pszApp, [MarshalAs(UnmanagedType.LPWStr)] string pszPIF, uint hInf, OPENPROPS flOpt); /// /// [PifMgr_SetProperties is available for use in the operating systems specified in the Requirements section.It may be altered or unavailable in subsequent versions.] /// Assigns values to a block of data from a .pif file. /// A handle to the application's properties. This parameter should be set to the value that is returned by PifMgr_OpenProperties. /// A null-terminated ANSI string containing the property group name. It can be one of the following, or any other name that corresponds to a valid .pif extension. /// A property group record buffer that holds the data. /// The size of the buffer, in bytes, pointed to by lpProps. /// Always SETPROPS_NONE. /// Returns the amount of information transferred, in bytes. Returns zero if the group cannot be found or an error occurs. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-pifmgr_setproperties // int PifMgr_SetProperties(HANDLE hProps, PCSTR pszGroup, const void* lpProps, int cbProps, UINT flOpt ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Ansi)] [PInvokeData("shlobj_core.h")] public static extern int PifMgr_SetProperties(IntPtr hProps, string pszGroup, IntPtr lpProps, int cbProps, uint flOpt = 0); /// [ReadCabinetState is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]Fills a CABINETSTATE structure with information from the registry.Type: CABINETSTATE*When this function returns, contains a pointer to a CABINETSTATE structure that contains either information pulled from the registry or default information.Type: intThe size of the structure pointed to by , in bytes.Type: BOOLReturns TRUE if the returned structure contains information from the registry. Returns FALSE if the structure contains default information. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-readcabinetstate // BOOL ReadCabinetState( CABINETSTATE *pcs, int cLength ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "0f0c6a10-588f-4c79-b73b-cf0bf9336ffc")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool ReadCabinetState(ref CABINETSTATE pcs, int cLength); /// /// /// [RealDriveType is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// Determines the drive type based on the drive number. /// /// /// Type: int /// The number of the drive that you want to test. "A:" corresponds to 0, "B:" to 1, and so on. /// /// /// Type: BOOL /// Reserved. Must be set to 0. /// /// /// Type: int /// Returns one of the following values. /// /// /// Return code /// Description /// /// /// DRIVE_UNKNOWN /// The drive type cannot be determined. /// /// /// DRIVE_NO_ROOT_DIR /// The root path is invalid. For example, no volume is mounted at the path. /// /// /// DRIVE_REMOVABLE /// The disk can be removed from the drive. /// /// /// DRIVE_FIXED /// The disk cannot be removed from the drive. /// /// /// DRIVE_REMOTE /// The drive is a remote (network) drive. /// /// /// DRIVE_CDROM /// The drive is a CD-ROM drive. /// /// /// DRIVE_RAMDISK /// The drive is a RAM disk. /// /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-realdrivetype // int RealDriveType( int iDrive, BOOL fOKToHitNet ); // public static extern int RealDriveType(int iDrive, [MarshalAs(UnmanagedType.Bool)] bool fOKToHitNet); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "c4e55b50-637a-446f-aa9c-7d8c71d8071c")] public static extern DRIVE_TYPE RealDriveType(int iDrive, [MarshalAs(UnmanagedType.Bool)] bool fOKToHitNet); /// /// /// [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.] /// /// /// Displays a dialog box that prompts the user to restart Windows. When the user clicks the button, the function calls ExitWindowsEx /// to attempt to restart Windows. /// /// /// /// TBD /// /// /// Type: PCWSTR /// A null-terminated Unicode string that contains the text that displays in the dialog box which prompts the user. /// /// /// TBD /// /// /// Type: int /// Returns the identifier of the button that was pressed to close the dialog box. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialog // int RestartDialog( HWND hwnd, PCWSTR pszPrompt, DWORD dwReturn ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "ec1e3c11-9960-482c-8461-72c4d41dff3c")] public static extern int RestartDialog(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPrompt, uint dwReturn); /// /// /// [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.] /// /// /// Displays a dialog box that asks the user to restart Windows. When the user clicks the button, the function calls ExitWindowsEx to /// attempt to restart Windows. /// /// /// /// TBD /// /// /// Type: PCWSTR /// A null-terminated string that contains the text that displays in the dialog box to prompt the user. /// /// /// TBD /// /// /// Type: DWORD /// /// Windows XP: Specifies the reason for initiating the shutdown. For more information, see System Shutdown Reason Codes. /// /// Windows 2000: This parameter is ignored. /// /// /// Type: int /// Returns the identifier of the button that was pressed to close the dialog box. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-restartdialogex // int RestartDialogEx( HWND hwnd, PCWSTR pszPrompt, DWORD dwReturn, DWORD dwReasonCode ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "32bc232f-6cc4-4f19-9d33-ba7ad28dfd59")] public static extern int RestartDialogEx(HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPrompt, uint dwReturn, uint dwReasonCode); /// /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function /// can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// /// Set this parameter to NULL to clear all usage data on all items. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762105")] public static extern void SHAddToRecentDocs(SHARD uFlags, IShellLinkW pv); /// /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function /// can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// /// Set this parameter to NULL to clear all usage data on all items. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762105")] public static extern void SHAddToRecentDocs(SHARD uFlags, [MarshalAs(UnmanagedType.LPWStr)] string pv); /// /// Notifies the system that an item has been accessed, for the purposes of tracking those items used most recently and most frequently. This function /// can also be used to clear all usage data. /// /// A value from the SHARD enumeration that indicates the form of the information pointed to by the pv parameter. /// /// A pointer to data that identifies the item that has been accessed. The item can be specified in this parameter in one of the following forms: /// /// A null-terminated string that contains the path and file name of the item. /// A PIDL that identifies the item's file object. /// /// Windows 7 and later only. A SHARDAPPIDINFO, SHARDAPPIDINFOIDLIST, or SHARDAPPIDINFOLINK structure that identifies the item through an /// AppUserModelID. See Application User Model IDs (AppUserModelIDs) for more information. /// /// Windows 7 and later only. An IShellLink object that identifies the item through a shortcut. /// /// Set this parameter to NULL to clear all usage data on all items. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762105")] public static extern void SHAddToRecentDocs(SHARD uFlags, PIDL pv); /// /// /// Given a Shell namespace item specified in the form of a folder, and an item identifier list relative to that folder, this /// function binds to the parent of the namespace item and optionally returns a pointer to the final component of the item identifier list. /// /// /// /// Type: IShellFolder* /// A pointer to a Shell folder object. If is NULL, indicates that the IDList passed is relative to the desktop. /// /// /// Type: PCUIDLIST_RELATIVE /// A PIDL to bind to, relative to . If is NULL, this is an absolute IDList relative to the desktop folder. /// /// /// Type: REFIID /// /// Reference to the desired interface ID. This is typically IID_IShellFolder or IID_IShellFolder2, but can be anything supported by /// the target folder. /// /// /// /// Type: void** /// /// When this function returns, contains the interface pointer requested in . This is typically IShellFolder or IShellFolder2, but /// can be anything supported by the target folder. /// /// /// /// Type: PCUITEMID_CHILD* /// /// A pointer to the last ID of the parameter, and is a child ID relative to the parent folder returned in . This value can be NULL. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// Note Calling the SHBindToFolderIDListParent function is equivalent to calling the SHBindToFolderIDListParentEx /// function with NULL as the bind context. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtofolderidlistparent // SHSTDAPI SHBindToFolderIDListParent( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "72a79d1b-15ed-475e-9ebd-03345579a06a")] public static extern HRESULT SHBindToFolderIDListParent(IShellFolder psfRoot, PIDL pidl, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv, IntPtr ppidlLast); /// /// Extends the SHBindToFolderIDListParent function by allowing the caller to specify a bind context. /// /// /// Type: IShellFolder* /// A pointer to a Shell folder object. If is NULL, indicates that the IDList passed is relative to the desktop. /// /// /// Type: PCUIDLIST_RELATIVE /// A PIDL to bind to, relative to . If is NULL, this is an absolute IDList relative to the desktop folder. /// /// /// Type: IBindCtx* /// /// A pointer to IBindCtx interface on a bind context object to be used during this operation. If this parameter is not used, set it /// to NULL, which is equivalent to calling the SHBindToFolderIDListParent function. Because support for is optional for /// folder object implementations, some folders may not support the use of bind contexts. /// /// /// /// Type: REFIID /// /// Reference to the desired interface ID. This is typically IID_IShellFolder or IID_IShellFolder2, but can be anything supported by /// the target folder. /// /// /// /// Type: void** /// /// When this function returns, contains the interface pointer requested in . This is typically IShellFolder or IShellFolder2, but /// can be anything supported by the target folder. /// /// /// /// Type: PCUITEMID_CHILD* /// /// A pointer to the last ID of the parameter, and is a child ID relative to the parent folder returned in . This value can be NULL. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtofolderidlistparentex // SHSTDAPI SHBindToFolderIDListParentEx( IShellFolder *psfRoot, PCUIDLIST_RELATIVE pidl, IBindCtx *ppbc, REFIID riid, void **ppv, PCUITEMID_CHILD *ppidlLast ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4f9b68cb-d0ae-45f7-90f5-2db1da3ab599")] public static extern HRESULT SHBindToFolderIDListParentEx(IShellFolder psfRoot, PIDL pidl, IBindCtx ppbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv, IntPtr ppidlLast); /// /// Retrieves and binds to a specified object by using the Shell namespace IShellFolder::BindToObject method. /// /// /// Type: IShellFolder* /// /// A pointer to IShellFolder. This parameter can be NULL. If is NULL, this indicates parameter is relative to the /// desktop. In this case, must specify an absolute ITEMIDLIST. /// /// /// /// Type: PCUIDLIST_RELATIVE /// /// A pointer to a constant ITEMIDLIST to bind to that is relative to . If is NULL, this is an absolute ITEMIDLIST /// relative to the desktop folder. /// /// /// /// Type: IBindCtx* /// /// A pointer to IBindCtx interface on a bind context object to be used during this operation. If this parameter is not used, set it /// to NULL. Because support for is optional for folder object implementations, some folders may not support the use of bind contexts. /// /// /// /// Type: REFIID /// Identifier of the interface to return. /// /// /// Type: void** /// /// When this method returns, contains the interface pointer as specified in to the bound object. If an error occurs, contains a /// NULL pointer. /// /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// Note This is a helper function that gets the desktop object by calling SHGetDesktopFolder. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shbindtoobject // SHSTDAPI SHBindToObject( IShellFolder *psf, PCUIDLIST_RELATIVE pidl, IBindCtx *pbc, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "acc16097-8301-4118-8cb5-00aa2705306a")] public static extern HRESULT SHBindToObject(IShellFolder psf, PIDL pidl, IBindCtx pbc, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Displays a dialog box that enables the user to select a Shell folder. /// A pointer to a BROWSEINFO structure that contains information used to display the dialog box. /// /// Returns a PIDL that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the Cancel button in the /// dialog box, the return value is NULL. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762115")] public static extern PIDL SHBrowseForFolder(ref BROWSEINFO lpbi); /// /// Locks the shared memory associated with a Shell change notification event. /// /// /// Type: HANDLE /// A handle to a window received as a in the specified Shell change notification message. /// /// /// Type: DWORD /// The process ID ( in the message callback). /// /// /// Type: PIDLIST_ABSOLUTE** /// /// The address of a pointer to a PIDLIST_ABSOLUTE that, when this function returns successfully, receives the list of affected PIDLs. /// /// /// /// Type: LONG* /// /// A pointer to a LONG value that, when this function returns successfully, receives the Shell change notification ID of the event /// that took place. /// /// /// /// Type: HANDLE /// Returns a handle (HLOCK) to the locked memory. Pass this value to SHChangeNotification_Unlock when finished. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_lock // HANDLE SHChangeNotification_Lock( HANDLE hChange, DWORD dwProcId, PIDLIST_ABSOLUTE **pppidl, LONG *plEvent ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "8e22d5d0-64be-403c-982d-c23705d85223")] public static extern IntPtr SHChangeNotification_Lock(IntPtr hChange, uint dwProcId, IntPtr pppidl, ref int plEvent); /// /// Unlocks shared memory for a change notification. /// /// /// Type: HANDLE /// A handle to the memory lock. This is the handle returned by SHChangeNotification_Lock when it locked the memory. /// /// /// Type: BOOL /// Returns TRUE on success; otherwise, FALSE. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotification_unlock // BOOL SHChangeNotification_Unlock( HANDLE hLock ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "967ede1f-ee9c-46ee-a371-dcfc3a57d824")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SHChangeNotification_Unlock(IntPtr hLock); /// /// Notifies the system of an event that an application has performed. An application should use this function if it performs an /// action that may affect the Shell. /// /// /// Describes the event that has occurred. Typically, only one event is specified at a time. If more than one event is specified, the /// values contained in the dwItem1 and dwItem2 parameters must be the same, respectively, for all specified events. /// /// Flags that, when combined bitwise with SHCNF_TYPE, indicate the meaning of the dwItem1 and dwItem2 parameters. /// Optional. First event-dependent value. /// Optional. Second event-dependent value. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h")] public static extern void SHChangeNotify(SHCNE wEventId, SHCNF uFlags, [Optional] IntPtr dwItem1, [Optional] IntPtr dwItem2); /// /// Unregisters the client's window process from receiving SHChangeNotify messages. /// /// /// Type: ULONG /// A value of type ULONG that specifies the registration ID returned by SHChangeNotifyRegister. /// /// /// Type: BOOL /// Returns TRUE if the specified client was found and removed; otherwise FALSE. /// /// /// /// See the Change Notify Watcher Sample in the Windows Software Development Kit (SDK) for a full example that demonstrates the use /// of this function. /// /// /// The NTSHChangeNotifyDeregister function, which is no longer available for use as of Windows Vista, was equivalent to SHChangeNotifyDeregister. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shchangenotifyderegister // BOOL SHChangeNotifyDeregister( ULONG ulID ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj_core.h", MSDNShortId = "fad021dc-8199-4384-b623-c98bc618799f")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SHChangeNotifyDeregister(uint ulID); /// /// Enables asynchronous register and deregister of a thread. /// /// /// Type: SCNRT_STATUS /// Indicates whether the function is being used to register or deregister the thread. One of the values of SCNRT_STATUS. /// /// /// This function does not return a value. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj/nf-shlobj-shchangenotifyregisterthread // void SHChangeNotifyRegisterThread( SCNRT_STATUS status ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj.h", MSDNShortId = "170afefc-b4de-4661-9c12-1341656b0fdb")] public static extern void SHChangeNotifyRegisterThread(SCNRT_STATUS status); /// /// Creates a data object in a parent folder. /// /// /// Type: PCIDLIST_ABSOLUTE /// A pointer to an ITEMIDLIST (PIDL) of the parent folder that contains the data object. /// /// /// Type: UINT /// The number of file objects or subfolders specified in the parameter. /// /// /// Type: PCUITEMID_CHILD_ARRAY /// /// An array of pointers to constant ITEMIDLIST structures, each of which uniquely identifies a file object or subfolder relative to /// the parent folder. Each item identifier list must contain exactly one SHITEMID structure followed by a terminating zero. /// /// /// /// Type: IDataObject* /// /// A pointer to interface IDataObject. This parameter can be NULL. Specify only if the data object created needs to support /// additional FORMATETC clipboard formats beyond the default formats it is assigned at creation. Alternatively, provide support for /// populating the created data object using non-default clipboard formats by calling method IDataObject::SetData and specifying the /// format in the FORMATETC structure passed in parameter . /// /// /// /// Type: REFIID /// A reference to the IID of the interface to retrieve through . This must be IID_IDataObject. /// /// /// Type: void** /// When this method returns successfully, contains the IDataObject interface pointer requested in . /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// This function is typically called when implementing method IShellFolder::GetUIObjectOf. When an interface pointer of interface ID /// IID_IDataObject is requested (using parameter ), the implementer can return the interface pointer on the object created with /// SHCreateDataObject in response. /// /// /// This function supports the CFSTR_SHELLIDLIST (also known as HIDA) clipboard format and also has generic support for arbitrary /// clipboard formats through IDataObject::SetData. For more information on clipboard formats, see Shell Clipboard Formats. /// /// /// The new data object is intended to be used in operations such as drag-and-drop, in which the data is stored in the clipboard with /// a given format. /// /// /// We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the and parameters. This macro provides the /// correct IID based on the interface pointed to by the value in , which eliminates the possibility of a coding error in that could /// lead to unexpected results. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedataobject // SHSTDAPI SHCreateDataObject( PCIDLIST_ABSOLUTE pidlFolder, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, IDataObject *pdtInner, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "d56cdafe-9463-43a5-8ef0-6cfaf0c524a8")] public static extern HRESULT SHCreateDataObject(PIDL pidlFolder, uint cidl, [In, MarshalAs(UnmanagedType.LPArray)] PIDL[] apidl, IDataObject pdtInner, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IDataObject ppv); /// /// Creates an object that represents the Shell's default context menu implementation. /// /// /// Type: const DEFCONTEXTMENU* /// A pointer to a constant DEFCONTEXTMENU structure. /// /// /// Type: REFIID /// /// Reference to the interface ID of the interface on which to base the object. This is typically the IID of IContextMenu, /// IContextMenu2, or IContextMenu3. /// /// /// /// Type: void** /// When this method returns, contains the interface pointer requested in riid. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// /// /// /// This function is typically used in the implementation of IShellFolder::GetUIObjectOf. GetUIObjectOf creates a context menu /// that merges IContextMenu handlers specified by the DEFCONTEXTMENU structure, and can optionally provide default context menu verb /// implementations such as open, explore, delete, and copy. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedefaultcontextmenu // SHSTDAPI SHCreateDefaultContextMenu( const DEFCONTEXTMENU *pdcm, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "055ff0a0-9ba7-463d-9684-3fd072b190da")] public static extern HRESULT SHCreateDefaultContextMenu(ref DEFCONTEXTMENU pdcm, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// /// /// [SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// Creates a new file system folder. /// /// /// Type: HWND /// A handle to a parent window. This parameter can be set to NULL if no user interface is displayed. /// /// /// Type: PCWSTR /// /// A pointer to a null-terminated Unicode string that contains the fully qualified path of the directory. This string should have no /// more than MAX_PATH characters, including the terminating null character. /// /// /// /// Type: int /// /// Returns ERROR_SUCCESS if successful. If the operation fails, other error codes can be returned, including those listed /// here. For values not specifically listed, see System Error Codes. /// /// /// /// Return code /// Description /// /// /// ERROR_BAD_PATHNAME /// The parameter was set to a relative path. /// /// /// ERROR_FILENAME_EXCED_RANGE /// The path pointed to by is too long. /// /// /// ERROR_FILE_EXISTS /// The directory exists. /// /// /// ERROR_ALREADY_EXISTS /// The directory exists. /// /// /// ERROR_CANCELLED /// The user canceled the operation. /// /// /// /// /// /// This function creates a file system folder whose fully qualified path is given by . If one or more of the intermediate folders do /// not exist, it creates them. /// /// To set security attributes on a new folder, use SHCreateDirectoryEx. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectory // int SHCreateDirectory( HWND hwnd, PCWSTR pszPath ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "4927429c-f457-4dda-aa0d-236eb236795c")] public static extern Win32Error SHCreateDirectory([Optional] HandleRef hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszPath); /// /// /// [This function is available through Windows XP Service Pack 2 (SP2) and Windows Server 2003. It might be altered or unavailable /// in subsequent versions of Windows.] /// /// Creates a new file system folder, with optional security attributes. /// /// /// Type: HWND /// A handle to a parent window. This parameter can be set to NULL if no user interface will be displayed. /// /// /// Type: LPCTSTR /// /// A pointer to a null-terminated string specifying the fully qualified path of the directory. This string is of maximum length of /// 248 characters, including the terminating null character. /// /// /// /// Type: const SECURITY_ATTRIBUTES* /// /// A pointer to a SECURITY_ATTRIBUTES structure with the directory's security attribute. Set this parameter to NULL if no /// security attributes need to be set. /// /// /// /// Type: int /// /// Returns ERROR_SUCCESS if successful. If the operation fails, other error codes can be returned, including those listed /// here. For values not specifically listed, see System Error Codes. /// /// /// /// Return code /// Description /// /// /// ERROR_BAD_PATHNAME /// The parameter was set to a relative path. /// /// /// ERROR_FILENAME_EXCED_RANGE /// The path pointed to by is too long. /// /// /// ERROR_PATH_NOT_FOUND /// The system cannot find the path pointed to by . The path may contain an invalid entry. /// /// /// ERROR_FILE_EXISTS /// The directory exists. /// /// /// ERROR_ALREADY_EXISTS /// The directory exists. /// /// /// ERROR_CANCELLED /// The user canceled the operation. /// /// /// /// /// /// This function creates a file system folder whose fully qualified path is given by . If one or more of the intermediate folders do /// not exist, they are created as well. SHCreateDirectoryEx also verifies that the files are visible. If they are not /// visible, expect one of the following: /// /// /// /// If is set to a valid window handle, a message box is displayed warning the user that he or she might not be able to access the /// files. If the user chooses not to proceed, the function returns ERROR_CANCELLED. /// /// If is set to NULL, no user interface is displayed and the function returns ERROR_CANCELLED. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatedirectoryexa // int SHCreateDirectoryEx( HWND hwnd, LPCTSTR pszPath, const SECURITY_ATTRIBUTES *psa ); [DllImport(Lib.Shell32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("shlobj_core.h", MSDNShortId = "7f44f907-cd12-4156-91c0-76e577ae25f6")] public static extern Win32Error SHCreateDirectoryEx([Optional] HandleRef hwnd, string pszPath, [In] SECURITY_ATTRIBUTES psa); /// /// [ /// SHCreateFileExtractIcon /// /// is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in /// subsequent versions.] /// /// /// Creates a default IExtractIcon handler for a file system object. Namespace extensions that display file system objects typically /// use this function. The extension and file attributes derive all that is needed for a simple icon extractor. /// /// /// /// Type: LPCTSTR /// /// A pointer to a null-terminated string that specifies the file system object. The buffer must not exceed MAX_PATH characters in length. /// /// /// /// Type: DWORD /// /// A combination of one or more file attribute flags (FILE_ATTRIBUTE_* values as defined in Winnt.h) that specify the type of object. /// /// /// /// Type: REFIID /// /// Reference to the desired interface ID of the icon extractor interface to create. This must be either IID_IExtractIconA or IID_IExtractIconW. /// /// /// /// Type: void** /// When this function returns, contains the interface pointer requested in . This is typically IExtractIcon. /// /// /// Type: HRESULT /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/nf-shlobj_core-shcreatefileextracticonw // SHSTDAPI SHCreateFileExtractIconW( LPCWSTR pszFile, DWORD dwFileAttributes, REFIID riid, void **ppv ); [DllImport(Lib.Shell32, SetLastError = false, ExactSpelling = true)] [PInvokeData("shlobj_core.h", MSDNShortId = "af3beb0a-892b-43e5-b5b8-8005f497b6e5")] public static extern HRESULT SHCreateFileExtractIconW([MarshalAs(UnmanagedType.LPWStr)] string pszFile, FileFlagsAndAttributes dwFileAttributes, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); /// Creates a new instance of the default Shell folder view object (DefView). /// Pointer to a SFV_CREATE structure that describes the particulars used in creating this instance of the Shell folder view object. /// When this function returns successfully, contains an interface pointer to the new IShellView object. On failure, this value is NULL. /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h")] public static extern HRESULT SHCreateShellFolderView(ref SFV_CREATE pcsfv, out IShellView ppsv); /// Provides a default handler to extract an icon from a file. /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. /// /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position of the icon in the /// file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a negative number, it refers to the icon's /// resource ID. /// /// A flag that controls the icon extraction. /// /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon specified in the LOWORD of /// nIconSize. This value can be NULL. /// /// /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon specified in the HIWORD of nIconSize. /// /// /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 to specify default /// large and small sizes. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762149")] public static extern HRESULT SHDefExtractIcon(string pszIconFile, int iIndex, uint uFlags, ref IntPtr phiconLarge, ref IntPtr phiconSmall, uint nIconSize); /// Provides a default handler to extract an icon from a file. /// A pointer to a null-terminated buffer that contains the path and name of the file from which the icon is extracted. /// /// The location of the icon within the file named in pszIconFile. If this is a positive number, it refers to the zero-based position of the icon in the /// file. For instance, 0 refers to the 1st icon in the resource file and 2 refers to the 3rd. If this is a negative number, it refers to the icon's /// resource ID. /// /// A flag that controls the icon extraction. /// /// A pointer to an HICON that, when this function returns successfully, receives the handle of the large version of the icon specified in the LOWORD of /// nIconSize. This value can be NULL. /// /// /// A pointer to an HICON that, when this function returns successfully, receives the handle of the small version of the icon specified in the HIWORD of nIconSize. /// /// /// A value that contains the large icon size in its LOWORD and the small icon size in its HIWORD. Size is measured in pixels. Pass 0 to specify default /// large and small sizes. /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762149")] public static extern HRESULT SHDefExtractIcon(string pszIconFile, int iIndex, uint uFlags, IntPtr phiconLarge, ref IntPtr phiconSmall, uint nIconSize); /// Retrieves extended property data from a relative identifier list. /// /// The address of the parent IShellFolder interface. This must be the immediate parent of the ITEMIDLIST structure referenced by the pidl parameter. /// /// A pointer to an ITEMIDLIST structure that identifies the object relative to the folder specified in psf. /// The format in which the data is being requested. /// /// A pointer to a buffer that, when this function returns successfully, receives the requested data. The format of this buffer is determined by nFormat. /// /// If nFormat is SHGDFIL_NETRESOURCE, there are two possible cases. If the buffer is large enough, the net resource's string information (fields for the /// network name, local name, provider, and comments) will be placed into the buffer. If the buffer is not large enough, only the net resource structure /// will be placed into the buffer and the string information pointers will be NULL. /// /// /// Size of the buffer at pv, in bytes. /// /// This function extracts only information that is present in the pointer to an item identifier list (PIDL). Since the content of a PIDL depends on the /// folder object that created the PIDL, there is no guarantee that all requested information will be available. In addition, the information that is /// returned reflects the state of the object at the time the PIDL was created. The current state of the object could be different. For example, if you /// set nFormat to SHGDFIL_FINDDATA, the function might assign meaningful values to only some of the members of the WIN32_FIND_DATA structure. The /// remaining members will be set to zero. To retrieve complete current information on a file system file or folder, use standard file system functions /// such as GetFileTime or FindFirstFile. /// /// E_INVALIDARG is returned if the psf, pidl, pv, or cb parameter does not match the nFormat parameter, or if nFormat is not one of the specific /// SHGDFIL_ values shown above. /// /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762174")] public static extern HRESULT SHGetDataFromIDList([In, MarshalAs(UnmanagedType.Interface)] IShellFolder psf, [In] PIDL pidl, SHGetDataFormat nFormat, [In, Out] IntPtr pv, int cb); /// Retrieves the IShellFolder interface for the desktop folder, which is the root of the Shell's namespace. /// /// When this method returns, receives an IShellFolder interface pointer for the desktop folder. The calling application is responsible for eventually /// freeing the interface by calling its IUnknown::Release method. /// /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762175")] public static extern HRESULT SHGetDesktopFolder([MarshalAs(UnmanagedType.Interface)] out IShellFolder ppv); /// Deprecated. Retrieves the path of a folder as an ITEMIDLIST structure. /// Reserved. /// /// A CSIDL value that identifies the folder to be located. The folders associated with the CSIDLs might not exist on a particular system. /// /// /// An access token that can be used to represent a particular user. It is usually set to NULL, but it may be needed when there are multiple users for /// those folders that are treated as belonging to a single user. The most commonly used folder of this type is My Documents. The calling application is /// responsible for correct impersonation when hToken is non-NULL. It must have appropriate security privileges for the particular user, and the user's /// registry hive must be currently mounted. /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetFolderLocation to find folder locations (such as /// the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as My Documents and Desktop. Any items added to the Default User folder also appear in any new user account. /// /// /// Reserved. /// /// The address of a pointer to an item identifier list structure that specifies the folder's location relative to the root of the namespace (the /// desktop). The ppidl parameter is set to NULL on failure. The calling application is responsible for freeing this resource by calling CoTaskMemFree. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762180")] public static extern HRESULT SHGetFolderLocation(IntPtr hwndOwner, int nFolder, SafeTokenHandle hToken, int dwReserved, out PIDL ppidl); /// /// Deprecated. Gets the path of a folder identified by a CSIDL value. As of Windows Vista, this function is merely a wrapper for /// SHGetKnownFolderPath. The CSIDL value is translated to its associated KNOWNFOLDERID and then SHGetKnownFolderPath is called. New applications should /// use the known folder system rather than the older CSIDL system, which is supported only for backward compatibility. /// /// Reserved. /// /// A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is specified, this function /// fails. You can force creation of a folder by combining the folder's CSIDL with CSIDL_FLAG_CREATE. /// /// /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder /// for the current user. /// /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access /// Control for further discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// /// Flags that specify the path to be returned. This value is used in cases where the folder associated with a KNOWNFOLDERID (or CSIDL) can be moved, /// renamed, redirected, or roamed across languages by a user or administrator. /// /// The known folder system that underlies SHGetFolderPath allows users or administrators to redirect a known folder to a location that suits their /// needs. This is achieved by calling IKnownFolderManager::Redirect, which sets the "current" value of the folder associated with the SHGFP_TYPE_CURRENT flag. /// /// /// The default value of the folder, which is the location of the folder if a user or administrator had not redirected it elsewhere, is retrieved by /// specifying the SHGFP_TYPE_DEFAULT flag. This value can be used to implement a "restore defaults" feature for a known folder. /// /// /// For example, the default value (SHGFP_TYPE_DEFAULT) for FOLDERID_Music (CSIDL_MYMUSIC) is "C:\Users\user name\Music". If the folder was redirected, /// the current value (SHGFP_TYPE_CURRENT) might be "D:\Music". If the folder has not been redirected, then SHGFP_TYPE_DEFAULT and SHGFP_TYPE_CURRENT /// retrieve the same path. /// /// /// /// A pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, this string will be /// empty. The returned path does not include a trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\". /// [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "bb762181")] public static extern HRESULT SHGetFolderPath(IntPtr hwndOwner, int nFolder, [In, Optional] SafeTokenHandle hToken, SHGFP dwFlags, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath); /// /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. This extends SHGetKnownFolderPath by allowing you to set the /// initial size of the string buffer. /// /// A reference to the KNOWNFOLDERID that identifies the folder. /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder /// for the current user. /// /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access /// Control for further discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// /// A null-terminated, Unicode string. This buffer must be of size cchPath. When SHGetFolderPathEx returns successfully, this parameter contains the path /// for the known folder. /// /// The size of the ppszPath buffer, in characters. [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [SecurityCritical, SuppressUnmanagedCodeSecurity] [PInvokeData("Shlobj.h", MSDNShortId = "mt757093")] public static extern HRESULT SHGetFolderPathEx([In, MarshalAs(UnmanagedType.LPStruct)] Guid rfid, KNOWN_FOLDER_FLAG dwFlags, [In, Optional] SafeTokenHandle hToken, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszPath, uint cchPath); /// Retrieves the pointer to an item identifier list (PIDL) of an object. /// A pointer to the IUnknown of the object from which to get the PIDL. /// When this function returns, contains a pointer to the PIDL of the given object. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762184")] public static extern HRESULT SHGetIDListFromObject([MarshalAs(UnmanagedType.IUnknown)] object iUnknown, out PIDL ppidl); /// Retrieves an image list. /// The image type contained in the list. /// Reference to the image list interface identifier, normally IID_IImageList. /// When this method returns, contains the interface pointer requested in riid. This is typically IImageList. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762185")] public static extern HRESULT SHGetImageList(SHIL iImageList, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IImageList ppv); /// Retrieves the path of a known folder as an ITEMIDLIST structure. /// /// A reference to the KNOWNFOLDERID that identifies the folder. The folders associated with the known folder IDs might not exist on a particular system. /// /// /// Flags that specify special retrieval options. This value can be 0; otherwise, it is one or more of the KNOWN_FOLDER_FLAG values. /// /// /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to access the current /// user's instance of the folder. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as /// belonging to a single user. The most commonly used folder of this type is Documents. /// /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security privileges for the /// particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further /// discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// /// When this method returns, contains a pointer to the PIDL of the folder. This parameter is passed uninitialized. The caller is responsible for freeing /// the returned PIDL when it is no longer needed by calling ILFree. /// [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762187")] public static extern HRESULT SHGetKnownFolderIDList([In, MarshalAs(UnmanagedType.LPStruct)] Guid rfid, KNOWN_FOLDER_FLAG dwFlags, [In, Optional] SafeTokenHandle hToken, out PIDL ppidl); /// Retrieves an IShellItem object that represents a known folder. /// A reference to the KNOWNFOLDERID, a GUID that identifies the folder that contains the item. /// /// Flags that specify special options used in the retrieval of the known folder IShellItem. This value can be KF_FLAG_DEFAULT; otherwise, one or more of /// the KNOWN_FOLDER_FLAG values. /// /// /// An access token used to represent a particular user. This parameter is usually set to NULL, in which case the function tries to access the current /// user's instance of the folder. However, you may need to assign a value to hToken for those folders that can have multiple users but are treated as /// belonging to a single user. The most commonly used folder of this type is Documents. /// /// The calling application is responsible for correct impersonation when hToken is non-null. It must have appropriate security privileges for the /// particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further /// discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderIDList to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// A reference to the IID of the interface that represents the item, usually IID_IShellItem or IID_IShellItem2. /// When this method returns, contains the interface pointer requested in riid. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "dd378429")] public static extern HRESULT SHGetKnownFolderItem([In, MarshalAs(UnmanagedType.LPStruct)] Guid rfid, KNOWN_FOLDER_FLAG dwFlags, [In, Optional] SafeTokenHandle hToken, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. /// A reference to the KNOWNFOLDERID that identifies the folder. /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder /// for the current user. /// /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access /// Control for further discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that specifies the path of the known folder. The /// calling process is responsible for freeing this resource once it is no longer needed by calling CoTaskMemFree. The returned path does not include a /// trailing backslash. For example, "C:\Users" is returned rather than "C:\Users\". /// /// Returns S_OK if successful, or an error value otherwise. /// This function replaces SHGetFolderPath. That older function is now simply a wrapper for SHGetKnownFolderPath. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762188")] public static extern HRESULT SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, KNOWN_FOLDER_FLAG dwFlags, [In, Optional] SafeTokenHandle hToken, out SafeCoTaskMemHandle pszPath); /// Retrieves the full path of a known folder identified by the folder's KNOWNFOLDERID. /// A reference to the KNOWNFOLDERID that identifies the folder. /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// An access token that represents a particular user. If this parameter is NULL, which is the most common usage, the function requests the known folder /// for the current user. /// /// Request a specific user's folder by passing the hToken of that user. This is typically done in the context of a service that has sufficient /// privileges to retrieve the token of a given user. That token must be opened with TOKEN_QUERY and TOKEN_IMPERSONATE rights. In some cases, you also /// need to include TOKEN_DUPLICATE. In addition to passing the user's hToken, the registry hive of that specific user must be mounted. See Access /// Control for further discussion of access control issues. /// /// /// Assigning the hToken parameter a value of -1 indicates the Default User. This allows clients of SHGetKnownFolderPath to find folder locations (such /// as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special /// folders such as Documents and Desktop. Any items added to the Default User folder also appear in any new user account. Note that access to the /// Default User folders requires administrator privileges. /// /// /// String that specifies the path of the known folder. /// This function replaces SHGetFolderPath. That older function is now simply a wrapper for SHGetKnownFolderPath. [PInvokeData("Shlobj.h", MSDNShortId = "bb762188")] public static string SHGetKnownFolderPath(KNOWNFOLDERID id, KNOWN_FOLDER_FLAG dwFlags, SafeTokenHandle hToken = null) { SHGetKnownFolderPath(id.Guid(), dwFlags, hToken ?? SafeTokenHandle.Null, out SafeCoTaskMemHandle path); return path.ToString(-1); } /// Retrieves the display name of an item identified by its IDList. /// A PIDL that identifies the item. /// A value from the SIGDN enumeration that specifies the type of display name to retrieve. /// A value that, when this function returns successfully, receives the address of a pointer to the retrieved display name. [DllImport(Lib.Shell32, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762191")] public static extern HRESULT SHGetNameFromIDList(PIDL pidl, SIGDN sigdnName, out SafeCoTaskMemHandle ppszName); /// Converts an item identifier list to a file system path. /// /// The address of an item identifier list that specifies a file or directory location relative to the root of the namespace (the desktop). /// /// The address of a buffer to receive the file system path. This buffer must be at least MAX_PATH characters in size. /// Returns TRUE if successful; otherwise, FALSE. [DllImport(Lib.Shell32, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762194")] public static extern bool SHGetPathFromIDList(PIDL pidl, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszPath); /// Opens a Windows Explorer window with specified items in a particular folder selected. /// A pointer to a fully qualified item ID list that specifies the folder. /// /// A count of items in the selection array, apidl. If cidl is zero, then pidlFolder must point to a fully specified ITEMIDLIST describing a single item /// to select. This function opens the parent folder and selects that item. /// /// A pointer to an array of PIDL structures, each of which is an item to select in the target folder referenced by pidlFolder. /// The optional flags. Under Windows XP this parameter is ignored. In Windows Vista, the following flags are defined. [DllImport(Lib.Shell32, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762232")] public static extern HRESULT SHOpenFolderAndSelectItems(PIDL pidlFolder, uint cidl, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] IntPtr[] apidl, OFASI dwFlags); /// /// Translates a Shell namespace object's display name into an item identifier list and returns the attributes of the object. This function is the /// preferred method to convert a string to a pointer to an item identifier list (PIDL). /// /// A pointer to a zero-terminated wide string that contains the display name to parse. /// A bind context that controls the parsing operation. This parameter is normally set to NULL. /// /// The address of a pointer to a variable of type ITEMIDLIST that receives the item identifier list for the object. If an error occurs, then this /// parameter is set to NULL. /// /// /// A ULONG value that specifies the attributes to query. To query for one or more attributes, initialize this parameter with the flags that represent /// the attributes of interest. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. /// /// /// A pointer to a ULONG. On return, those attributes that are true for the object and were requested in sfgaoIn are set. An object's attribute flags can /// be zero or a combination of SFGAO flags. For a list of available SFGAO flags, see IShellFolder::GetAttributesOf. /// [DllImport(Lib.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true)] [PInvokeData("Shlobj.h", MSDNShortId = "bb762236")] public static extern HRESULT SHParseDisplayName([MarshalAs(UnmanagedType.LPWStr)] string pszName, [In, Optional] IntPtr pbc, out PIDL ppidl, SFGAO sfgaoIn, out SFGAO psfgaoOut); /// /// /// [CABINETSTATE is available for use in the operating systems specified in the Requirements section. It may be altered or /// unavailable in subsequent versions.] /// /// /// Holds the global configuration for Windows Explorer and Windows Internet Explorer. This structure is used in the ReadCabinetState /// and WriteCabinetState functions. /// /// // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-cabinetstate // typedef struct CABINETSTATE { WORD cLength; WORD nVersion; BOOL fFullPathTitle : 1; BOOL fSaveLocalView : 1; BOOL fNotShell : 1; BOOL fSimpleDefault : 1; BOOL fDontShowDescBar : 1; BOOL fNewWindowMode : 1; BOOL fShowCompColor : 1; BOOL fDontPrettyNames : 1; BOOL fAdminsCreateCommonGroups : 1; UINT fUnusedFlags : 7; UINT fMenuEnumFilter; } *LPCABINETSTATE; [PInvokeData("shlobj_core.h", MSDNShortId = "4b82b6a8-c4c0-4af2-9612-0551376c1c62")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct CABINETSTATE { /// Type: WORDThe size of the structure, in bytes. public ushort cLength; /// Type: WORD public ushort nVersion; private ushort fFlags; /// Type: UINTOne or both of the following flags.SHCONTF_FOLDERSDisplay folders.SHCONTF_NONFOLDERSDisplay non-folder items. public SHCONTF fMenuEnumFilter; /// Type: BOOLTRUEDisplay the full path in the title bar.FALSEDisplay only the file name in the title bar. public bool fFullPathTitle { get => (fFlags & 1 << 0) != 0; set { if (value) fFlags |= 1 << 0; else { int i = fFlags; i &= ~(1 << 0); fFlags = (ushort)i; } } } /// Type: BOOLTRUERemember each folder's view settings.FALSEUse global settings for all folders. public bool fSaveLocalView { get => (fFlags & 1 << 1) != 0; set { if (value) fFlags |= 1 << 1; else { int i = fFlags; i &= ~(1 << 1); fFlags = (ushort)i; } } } /// Type: BOOLNot used. public bool fNotShell { get => (fFlags & 1 << 2) != 0; set { if (value) fFlags |= 1 << 2; else { int i = fFlags; i &= ~(1 << 2); fFlags = (ushort)i; } } } /// Type: BOOLNot used. public bool fSimpleDefault { get => (fFlags & 1 << 3) != 0; set { if (value) fFlags |= 1 << 3; else { int i = fFlags; i &= ~(1 << 3); fFlags = (ushort)i; } } } /// Type: BOOLNot used. public bool fDontShowDescBar { get => (fFlags & 1 << 4) != 0; set { if (value) fFlags |= 1 << 4; else { int i = fFlags; i &= ~(1 << 4); fFlags = (ushort)i; } } } /// Type: BOOLTRUEDisplay in a new window.FALSEDisplay in the current window. public bool fNewWindowMode { get => (fFlags & 1 << 5) != 0; set { if (value) fFlags |= 1 << 5; else { int i = fFlags; i &= ~(1 << 5); fFlags = (ushort)i; } } } /// Type: BOOLTRUEShow encrypted or compressed NTFS files in color.FALSEDo not show encrypted or compressed NTFS files in color. public bool fShowCompColor { get => (fFlags & 1 << 6) != 0; set { if (value) fFlags |= 1 << 6; else { int i = fFlags; i &= ~(1 << 6); fFlags = (ushort)i; } } } /// Type: BOOLNot used. public bool fDontPrettyNames { get => (fFlags & 1 << 7) != 0; set { if (value) fFlags |= 1 << 7; else { int i = fFlags; i &= ~(1 << 7); fFlags = (ushort)i; } } } /// Type: BOOLUsed when an administrator installs an application that places an icon in the Start menu.TRUEAdd the icon to the Start menu for all users (CSIDL_COMMON_STARTMENU). This is the default value.FALSEAdd the icon to only the current user (CSIDL_STARTMENU). public bool fAdminsCreateCommonGroups { get => (fFlags & 1 << 8) != 0; set { if (value) fFlags |= 1 << 8; else { int i = fFlags; i &= ~(1 << 8); fFlags = (ushort)i; } } } } /// /// Defines the coordinates of a character cell in a console screen buffer. The origin of the coordinate system (0,0) is at the top, left cell of the buffer. /// [PInvokeData("wincon.h")] [StructLayout(LayoutKind.Sequential, Pack = 2)] public struct COORD { /// The horizontal coordinate or column value. The units depend on the function call. public short X; /// The vertical coordinate or row value. The units depend on the function call. public short Y; } /// Serves as the header for some of the extra data structures used by IShellLinkDataList. [StructLayout(LayoutKind.Sequential, Pack = 4)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773249")] public struct DATABLOCKHEADER { /// The size of the extra data block. public uint cbSize; /// A signature that identifies the type of data block that follows the header. public ShellDataBlockSignature dwSignature; } /// Contains context menu information used by SHCreateDefaultContextMenu. [StructLayout(LayoutKind.Sequential)] [PInvokeData("shlobj_core.h")] public struct DEFCONTEXTMENU { /// A handle to the context menu. Set this member to the handle returned from CreateMenu. public IntPtr hwnd; /// /// A pointer to the IContextMenuCB interface supported by the callback object. This value is optional and can be NULL. /// public IContextMenuCB pcmcb; /// /// The PIDL of the folder that contains the selected file object(s) or the folder of the context menu if no file objects are /// selected. This value is optional and can be NULL, in which case the PIDL is computed from the psf member. /// public IntPtr pidlFolder; /// /// A pointer to the IShellFolder interface of the folder object that contains the selected file objects, or the folder that /// contains the context menu if no file objects are selected. /// public IShellFolder psf; /// The count of items in member apidl. public uint cidl; /// /// A pointer to a constant array of ITEMIDLIST structures. Each entry in the array describes a child item to which the context /// menu applies, for instance, a selected file the user wants to Open. /// public IntPtr apidl; /// /// A pointer to the IQueryAssociations interface on the object from which to load extensions. This parameter is optional and /// thus can be NULL. If this value is NULL and members aKeys and cKeys are also NULL (see Remarks), punkAssociationInfo is /// computed from the apidl member and cidl via a request for IQueryAssociations through IShellFolder::GetUIObjectOf. If /// IShellFolder::GetUIObjectOf returns E_NOTIMPL, a default implementation is provided based on the SFGAO_FOLDER and /// SFGAO_FILESYSTEM attributes returned from IShellFolder::GetAttributesOf. /// public IQueryAssociations punkAssociationInfo; /// The count of items in member aKeys. This value can be zero. If the value is zero, the extensions are loaded based /// on the object that supports interface IQueryAssociations as specified by member punkAssociationInfo. If the value is /// non-NULL, the extensions are loaded based only on member aKeys and not member punkAssociationInfo. // Note The maximum number of keys is 16. Callers must enforce this limit as the API does not. Failing to do so can result in // memory corruption. /// public uint cKeys; /// /// A pointer to an HKEY that specifies the registry key from which to load extensions. This parameter is optional and can be /// NULL. If the value is NULL, the extensions are loaded based on the object that supports interface IQueryAssociations as /// specified in punkAssociationInfo. /// public IntPtr aKeys; } /// Holds an extra data block used by IShellLinkDataList. It holds the link's Windows Installer ID. [StructLayout(LayoutKind.Sequential, Pack = 4)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773274")] public struct EXP_DARWIN_LINK { /// /// DATABLOCK_HEADER structure stating the size and signature of the EXP_DARWIN_LINK structure. The following is the only recognized signature value: EXP_DARWIN_ID_SIG /// public DATABLOCKHEADER dbh; /// The link's ID in the form of an ANSI string. [MarshalAs(UnmanagedType.LPStr, SizeConst = MAX_PATH)] public string szDarwinID; /// The link's ID in the form of an Unicode string. [MarshalAs(UnmanagedType.LPWStr, SizeConst = MAX_PATH)] public string szwDarwinID; } /// Holds an extra data block used by IShellLinkDataList. It holds special folder information. [StructLayout(LayoutKind.Sequential, Pack = 4)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773279")] public struct EXP_SPECIAL_FOLDER { /// The size of the EXP_SPECIAL_FOLDER structure. public uint cbSize; /// The structure's signature. It should be set to EXP_SPECIAL_FOLDER_SIG. public ShellDataBlockSignature dwSignature; /// The ID of the special folder that the link points into. public uint idSpecialFolder; /// The offset into the saved PIDL. public uint cbOffset; } /// Holds an extra data block used by IShellLinkDataList. It holds expandable environment strings for the icon or target. [StructLayout(LayoutKind.Sequential, Pack = 4)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773282")] public struct EXP_SZ_LINK { /// The size of the EXP_SZ_LINK structure. public uint cbSize; /// /// The structure's signature. It can have one of the following values: EXP_SZ_LINK_SIG = Contains the link's target path; EXP_SZ_ICON_SIG = Contains /// the links icon path. /// public ShellDataBlockSignature dwSignature; /// The null-terminated ANSI string with the path of the target or icon. [MarshalAs(UnmanagedType.LPStr, SizeConst = MAX_PATH)] public string szTarget; /// The null-terminated Unicode string with the path of the target or icon. [MarshalAs(UnmanagedType.LPWStr, SizeConst = MAX_PATH)] public string swzTarget; } /// Holds an extra data block used by IShellLinkDataList. It holds console properties. [StructLayout(LayoutKind.Sequential, Pack = 2)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773359")] public struct NT_CONSOLE_PROPS { /// /// The DATABLOCK_HEADER structure with the NT_CONSOLE_PROPS structure's size and signature. The signature for an NT_CONSOLE_PROPS structure is NT_CONSOLE_PROPS_SIG. /// public DATABLOCKHEADER dbh; /// Fill attribute for the console. public ushort wFillAttribute; /// Fill attribute for console pop-ups. public ushort wPopupFillAttribute; /// A COORD structure with the console's screen buffer size. public COORD dwScreenBufferSize; /// A COORD structure with the console's window size. public COORD dwWindowSize; /// A COORD structure with the console's window origin. public COORD dwWindowOrigin; /// The font. public uint nFont; /// The input buffer size. public uint nInputBufferSize; /// A COORD structure with the font size. public COORD dwFontSize; /// The font family/ public uint uFontFamily; /// The font weight. public uint uFontWeight; /// A character array that contains the font's face name. [MarshalAs(UnmanagedType.LPWStr, SizeConst = LF_FACESIZE)] public string FaceName; /// The cursor size. public uint uCursorSize; /// A boolean value that is set to TRUE if the console is in full-screen mode, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool bFullScreen; /// A boolean value that is set to TRUE if the console is in quick-edit mode, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool bQuickEdit; /// A boolean value that is set to TRUE if the console is in insert mode, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool bInsertMode; /// A boolean value that is set to TRUE if the console is in auto-position mode, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool bAutoPosition; /// The size of the history buffer. public uint uHistoryBufferSize; /// The number of history buffers. public uint uNumberOfHistoryBuffers; /// A boolean value that is set to TRUE if old duplicate history lists should be discarded, or FALSE otherwise. [MarshalAs(UnmanagedType.Bool)] public bool bHistoryNoDup; /// An array of COLORREF values with the console's color settings. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public uint[] ColorTable; } /// Holds an extra data block used by IShellLinkDataList. It holds the console's code page. [StructLayout(LayoutKind.Sequential, Pack = 2)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773362")] public struct NT_FE_CONSOLE_PROPS { /// /// The DATABLOCK_HEADER structure with the NT_FE_CONSOLE_PROPS structure's size and signature. The signature for an NT_FE_CONSOLE_PROPS structure is NT_FE_CONSOLE_PROPS_SIG. /// public DATABLOCKHEADER dbh; /// The console's code page. public uint uCodePage; } /// This structure contains information from a .pif file. It is used by PifMgr_GetProperties. // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-propprg // typedef struct PROPPRG { WORD flPrg; WORD flPrgInit; CHAR achTitle[PIFNAMESIZE]; CHAR achCmdLine[PIFSTARTLOCSIZE + PIFPARAMSSIZE + 1]; CHAR achWorkDir[PIFDEFPATHSIZE]; WORD wHotKey; CHAR achIconFile[PIFDEFFILESIZE]; WORD wIconIndex; DWORD dwEnhModeFlags; DWORD dwRealModeFlags; CHAR achOtherFile[PIFDEFFILESIZE]; CHAR achPIFFile[PIFMAXFILEPATH]; }; [PInvokeData("shlobj_core.h", MSDNShortId = "603f990b-efb8-4d72-bc96-27bda4ffcbd8")] [StructLayout(LayoutKind.Sequential)] public struct PROPPRG { private const int PIFNAMESIZE = 30; private const int PIFSTARTLOCSIZE = 63; private const int PIFDEFPATHSIZE = 64; private const int PIFPARAMSSIZE = 64; private const int PIFSHPROGSIZE = 64; private const int PIFSHDATASIZE = 64; private const int PIFDEFFILESIZE = 80; private const int PIFMAXFILEPATH = 260; /// Type: WORDFlags that describe how the program will run.PRG_DEFAULTUse the default options.PRG_CLOSEONEXITClose the application on exit. public ushort flPrg; /// Type: WORDFlags that specify the initial conditions for the application.PRGINIT_DEFAULTUse the default options.PRGINIT_MINIMIZEDThe application should be minimized.PRGINIT_MAXIMIZEDThe application should be maximized.PRGINIT_REALMODEThe application should run in real mode.PRGINIT_REALMODESILENTThe application should run in real mode without being prompted.PRGINIT_AMBIGUOUSPIFThe data is ambiguous.PRGINIT_NOPIFNo .pif file was found.PRGINIT_DEFAULTPIFA default .pif was found.PRGINIT_INFSETTINGSA .inf file was found.PRGINIT_INHIBITPIFThe .inf file indicates that a .pif file should not be created. public ushort flPrgInit; /// Type: __wchar_tA null-terminated string that contains the title. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFNAMESIZE)] public byte[] achTitle; /// Type: __wchar_tA null-terminated string that contains the command line, including arguments. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFSTARTLOCSIZE + PIFPARAMSSIZE + 1)] public byte[] achCmdLine; /// Type: __wchar_tA null-terminated string that contains the working directory. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFPATHSIZE)] public byte[] achWorkDir; /// Type: WORDThe key code of the .pif file's hotkey. public ushort wHotKey; /// Type: __wchar_tA null-terminated string that contains the name of the file that contains the icon. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFFILESIZE)] public byte[] achIconFile; /// Type: WORDThe index of the icon in the file specified by achIconFile. public ushort wIconIndex; /// Type: DWORDReserved. public uint dwEnhModeFlags; /// Type: DWORDFlags that specify the real mode options.RMOPT_MOUSERequires a real-mode mouse.RMOPT_EMSRequires expanded memory.RMOPT_CDROMRequires CD-ROM support.RMOPT_NETWORKRequires network support.RMOPT_DISKLOCKRequires disk locking.RMOPT_PRIVATECFGUse a private config.sys or autoexec.bat file.RMOPT_VESARequires a VESA driver. public uint dwRealModeFlags; /// Type: __wchar_tA null-terminated string that contains the name of the "other" file in the directory. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFDEFFILESIZE)] public byte[] achOtherFile; /// Type: __wchar_tA null-terminated string that contains the name of the .pif file in the directory. [MarshalAs(UnmanagedType.ByValArray, SizeConst = PIFMAXFILEPATH)] public byte[] achPIFFile; } /// This structure is used with the SHCreateShellFolderView function. [StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h")] public struct SFV_CREATE { /// The size of the SFV_CREATE structure, in bytes. public uint cbSize; /// The IShellFolder interface of the folder for which to create the view. public IShellFolder pshf; /// /// A pointer to the parent IShellView interface. This parameter may be NULL. This parameter is used only when the view created by /// SHCreateShellFolderView is hosted in a common dialog box. /// public IShellView psvOuter; /// /// A pointer to the IShellFolderViewCB interface that handles the view's callbacks when various events occur. This parameter may be NULL. /// public IShellFolderViewCB psfvcb; } /// Receives item data in response to a call to SHGetDataFromIDList. [StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h", MSDNShortId = "bb759775")] public struct SHDESCRIPTIONID { /// Receives a value that determines what type the item is. public SHDID dwDescriptionId; /// Receives the CLSID of the object to which the item belongs. public Guid clsid; } /*[StructLayout(LayoutKind.Sequential)] [PInvokeData("Shlobj.h", MSDNShortId = "bb773399")] public struct SFV_CREATE { public uint cbSize; [MarshalAs(UnmanagedType.Interface)] public IShellFolder pshf; [MarshalAs(UnmanagedType.Interface)] public IShellView psvOuter; [MarshalAs(UnmanagedType.Interface)] public IShellFolderViewCB psfbcb; }*/ } }