using System; using System.Runtime.InteropServices; using Vanara.InteropServices; namespace Vanara.PInvoke { public static partial class Shell32 { /// Describes match criteria. Used by methods of the IKnownFolderManager interface. [PInvokeData("Shobjidl.h", MSDNShortId = "bb762505")] public enum FFFP_MODE { /// Exact match. FFFP_EXACTMATCH, /// Nearest parent match. FFFP_NEARESTPARENTMATCH, } /// Value that represent a category by which a folder registered with the Known Folder system can be classified. [PInvokeData("Shobjidl.h", MSDNShortId = "bb762512")] public enum KF_CATEGORY { /// /// Virtual folders are not part of the file system, which is to say that they have no path. For example, Control Panel and /// Printers are virtual folders. A number of features such as folder path and redirection do not apply to this category. /// KF_CATEGORY_VIRTUAL = 1, /// /// Fixed file system folders are not managed by the Shell and are usually given a permanent path when the system is installed. /// For example, the Windows and Program Files folders are fixed folders. A number of features such as redirection do not apply /// to this category. /// KF_CATEGORY_FIXED = 2, /// /// Common folders are those file system folders used for sharing data and settings, accessible by all users of a system. For /// example, all users share a common Documents folder as well as their per-user Documents folder. /// KF_CATEGORY_COMMON = 3, /// /// Per-user folders are those stored under each user's profile and accessible only by that user. For example, /// %USERPROFILE%\Pictures. This category of folder usually supports many features including aliasing, redirection and customization. /// KF_CATEGORY_PERUSER = 4, } /// Flags that specify certain known folder behaviors. Used with the KNOWNFOLDER_DEFINITION structure. [PInvokeData("Shobjidl.h", MSDNShortId = "bb762513")] [Flags] public enum KF_DEFINITION_FLAGS { /// /// Prevent a per-user known folder from being redirected to a network location. Note that if the known folder has been flagged /// with KFDF_LOCAL_REDIRECT_ONLY but it is a subfolder of a known folder that is redirected to a network location, this /// subfolder is redirected also. /// KFDF_LOCAL_REDIRECT_ONLY = 0x00000002, /// Can be roamed through a PC-to-PC synchronization. KFDF_ROAMABLE = 0x00000004, /// /// Create the folder when the user first logs on. Normally a known folder is not created until it is first called. At that time, /// an API such as SHCreateItemInKnownFolder or IKnownFolder::GetShellItem is called with the KF_FLAG_CREATE flag. However, some /// known folders need to exist immediately. An example is those known folders under %USERPROFILE%, which must exist to provide a /// proper view. In those cases, KFDF_PRECREATE is set and Windows Explorer calls the creation API during its user initialization. /// KFDF_PRECREATE = 0x00000008, /// Introduced in Windows 7. The known folder is a file rather than a folder. KFDF_STREAM = 0x00000010, /// /// Introduced in Windows 7. The full path of the known folder, with any environment variables fully expanded, is stored in the /// registry under HKEY_CURRENT_USER. /// KFDF_PUBLISHEXPANDEDPATH = 0x00000020, /// Introduced in Windows 8.1. Prevent showing the Locations tab in the property dialog of the known folder. KFDF_NO_REDIRECT_UI = 0x00000040, } /// /// Flags used by IKnownFolderManager::Redirect to specify details of a known folder redirection such as permissions and ownership /// for the redirected folder. /// [PInvokeData("Shobjidl.h", MSDNShortId = "bb762515")] [Flags] public enum KF_REDIRECT_FLAGS { /// Ensure that only the user has permission to access the redirected folder. KF_REDIRECT_USER_EXCLUSIVE = 0x00000001, /// Copy the DACL of the source folder to the target to maintain current access permissions. KF_REDIRECT_COPY_SOURCE_DACL = 0x00000002, /// /// Sets the user as the owner of a newly created target folder unless the user is a member of the Administrator group, in which /// case Administrator is set as the owner. Must be called with KF_REDIRECT_SET_OWNER_EXPLICIT. /// KF_REDIRECT_OWNER_USER = 0x00000004, /// /// Set the owner of a newly created target folder. If the user belongs to the Administrators group, Administrators is assigned /// as the owner. Must be called with KF_REDIRECT_OWNER_USER. /// KF_REDIRECT_SET_OWNER_EXPLICIT = 0x00000008, /// /// Do not perform a redirection, simply check whether redirection has occurred. If so, IKnownFolderManager::Redirect returns /// S_OK; if not, or if some actions remain to be completed, it returns S_FALSE. /// KF_REDIRECT_CHECK_ONLY = 0x00000010, /// Display UI during the redirection. KF_REDIRECT_WITH_UI = 0x00000020, /// Unpin the source folder. KF_REDIRECT_UNPIN = 0x00000040, /// Pin the target folder. KF_REDIRECT_PIN = 0x00000080, /// Copy the existing contents—both files and subfolders—of the known folder to the redirected folder. KF_REDIRECT_COPY_CONTENTS = 0x00000200, /// /// Delete the contents of the source folder after they have been copied to the redirected folder. This flag is valid only if /// KF_REDIRECT_COPY_CONTENTS is set. /// KF_REDIRECT_DEL_SOURCE_CONTENTS = 0x00000400, /// Reserved. Do not use. KF_REDIRECT_EXCLUDE_ALL_KNOWN_SUBFOLDERS = 0x00000800, } /// Flags that specify the current redirection capabilities of a known folder. Used by IKnownFolder::GetRedirectionCapabilities. [PInvokeData("Shobjidl.h", MSDNShortId = "bb762514")] [Flags] public enum KF_REDIRECTION_CAPABILITIES { /// /// The folder can be redirected if any of the bits in the lower byte of the value are set but no DENY flag is set. DENY flags /// are found in the upper byte of the value. /// KF_REDIRECTION_CAPABILITIES_ALLOW_ALL = 0x000000FF, /// /// The folder can be redirected. Currently, redirection exists for only common and user folders; fixed and virtual folders /// cannot be redirected. /// KF_REDIRECTION_CAPABILITIES_REDIRECTABLE = 0x00000001, /// Redirection is not allowed. KF_REDIRECTION_CAPABILITIES_DENY_ALL = 0x000FFF00, /// The folder cannot be redirected because it is already redirected by group policy. KF_REDIRECTION_CAPABILITIES_DENY_POLICY_REDIRECTED = 0x00000100, /// The folder cannot be redirected because the policy prohibits redirecting this folder. KF_REDIRECTION_CAPABILITIES_DENY_POLICY = 0x00000200, /// The folder cannot be redirected because the calling application does not have sufficient permissions. KF_REDIRECTION_CAPABILITIES_DENY_PERMISSIONS = 0x00000400, } /// Specify special retrieval options for known folders. These values supersede CSIDL values, which have parallel meanings. [Flags] [PInvokeData("Shlobj.h", MSDNShortId = "dd378447")] public enum KNOWN_FOLDER_FLAG : uint { /// No flags. KF_FLAG_DEFAULT = 0x00000000, /// /// Build a simple IDList (PIDL) This value can be used when you want to retrieve the file system path but do not specify this /// value if you are retrieving the localized display name of the folder because it might not resolve correctly. /// KF_FLAG_SIMPLE_IDLIST = 0x00000100, /// /// Gets the folder's default path independent of the current location of its parent. KF_FLAG_DEFAULT_PATH must also be set. /// KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200, /// /// Gets the default path for a known folder. If this flag is not set, the function retrieves the current—and possibly /// redirected—path of the folder. The execution of this flag includes a verification of the folder's existence unless /// KF_FLAG_DONT_VERIFY is set. /// KF_FLAG_DEFAULT_PATH = 0x00000400, /// /// Initializes the folder using its Desktop.ini settings. If the folder cannot be initialized, the function returns a failure /// code and no path is returned. This flag should always be combined with KF_FLAG_CREATE. If the folder is located on a network, /// the function might take a longer time to execute. /// KF_FLAG_INIT = 0x00000800, /// /// Gets the true system path for the folder, free of any aliased placeholders such as %USERPROFILE%, returned by /// SHGetKnownFolderIDList and IKnownFolder::GetIDList. This flag has no effect on paths returned by SHGetKnownFolderPath and /// IKnownFolder::GetPath. By default, known folder retrieval functions and methods return the aliased path if an alias exists. /// KF_FLAG_NO_ALIAS = 0x00001000, /// /// Stores the full path in the registry without using environment strings. If this flag is not set, portions of the path may be /// represented by environment strings such as %USERPROFILE%. This flag can only be used with SHSetKnownFolderPath and IKnownFolder::SetPath. /// KF_FLAG_DONT_UNEXPAND = 0x00002000, /// /// Do not verify the folder's existence before attempting to retrieve the path or IDList. If this flag is not set, an attempt is /// made to verify that the folder is truly present at the path. If that verification fails due to the folder being absent or /// inaccessible, the function returns a failure code and no path is returned. If the folder is located on a network, the /// function might take a longer time to execute. Setting this flag can reduce that lag time. /// KF_FLAG_DONT_VERIFY = 0x00004000, /// /// Forces the creation of the specified folder if that folder does not already exist. The security provisions predefined for /// that folder are applied. If the folder does not exist and cannot be created, the function returns a failure code and no path /// is returned. This value can be used only with the following functions and methods: SHGetKnownFolderPath, /// SHGetKnownFolderIDList, IKnownFolder::GetIDList, IKnownFolder::GetPath, and IKnownFolder::GetShellItem. /// KF_FLAG_CREATE = 0x00008000, /// /// Introduced in Windows 7: When running inside an app container, or when providing an app container token, this flag prevents /// redirection to app container folders. Instead, it retrieves the path that would be returned where it not running inside an /// app container. /// KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, /// Introduced in Windows 7. Return only aliased PIDLs. Do not use the file system path. KF_FLAG_ALIAS_ONLY = 0x80000000 } /// /// The KNOWNFOLDERID constants represent GUIDs that identify standard folders registered with the system as Known Folders. These /// folders are installed with Windows Vista and later operating systems, and a computer will have only folders appropriate to it /// installed. For descriptions of these folders, see CSIDL. /// [PInvokeData("Knownfolders.h", MSDNShortId = "dd378457")] public enum KNOWNFOLDERID { /// Account Pictures [KnownFolderDetail("{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}")] FOLDERID_AccountPictures, /// Get Programs [KnownFolderDetail("{de61d971-5ebc-4f02-a3a9-6c82895e5c04}")] FOLDERID_AddNewPrograms, /// Admin tools [KnownFolderDetail("{724EF170-A42D-4FEF-9F26-B60E846FBA4F}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_ADMINTOOLS)] FOLDERID_AdminTools, /// Application shortcuts [KnownFolderDetail("{A3918781-E5F2-4890-B3D9-A7E54332328C}")] FOLDERID_ApplicationShortcuts, /// Applications [KnownFolderDetail("{1e87508d-89c2-42f0-8a7e-645a0f50ca58}")] FOLDERID_AppsFolder, /// Installed Updates [KnownFolderDetail("{a305ce99-f527-492b-8b1a-7e76fa98d6e4}")] FOLDERID_AppUpdates, /// Camera Roll [KnownFolderDetail("{AB5FB87B-7CE2-4F83-915D-550846C9537B}")] FOLDERID_CameraRoll, /// Temporary Burn Folder [KnownFolderDetail("{9E52AB10-F80D-49DF-ACB8-4330F5687855}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_CDBURN_AREA)] FOLDERID_CDBurning, /// Programs and Features [KnownFolderDetail("{df7266ac-9274-4867-8d55-3bd661de872d}")] FOLDERID_ChangeRemovePrograms, /// Administrative Tools [KnownFolderDetail("{D0384E7D-BAC3-4797-8F14-CBA229B392B5}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_ADMINTOOLS)] FOLDERID_CommonAdminTools, /// OEM Links [KnownFolderDetail("{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_OEM_LINKS)] FOLDERID_CommonOEMLinks, /// Programs [KnownFolderDetail("{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_PROGRAMS)] FOLDERID_CommonPrograms, /// Start Menu [KnownFolderDetail("{A4115719-D62E-491D-AA7C-E74B8BE3B067}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_STARTMENU)] FOLDERID_CommonStartMenu, /// Startup [KnownFolderDetail("{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_STARTUP)] FOLDERID_CommonStartup, /// Templates [KnownFolderDetail("{B94237E7-57AC-4347-9151-B08C6C32D1F7}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_TEMPLATES)] FOLDERID_CommonTemplates, /// Computer [KnownFolderDetail("{0AC0837C-BBF8-452A-850D-79D08E667CA7}", Equivalent = Environment.SpecialFolder.MyComputer)] FOLDERID_ComputerFolder, /// Conflicts [KnownFolderDetail("{4bfefb45-347d-4006-a5be-ac0cb0567192}")] FOLDERID_ConflictFolder, /// Network Connections [KnownFolderDetail("{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}")] FOLDERID_ConnectionsFolder, /// Contacts [KnownFolderDetail("{56784854-C6CB-462b-8169-88E350ACB882}")] FOLDERID_Contacts, /// Control Panel [KnownFolderDetail("{82A74AEB-AEB4-465C-A014-D097EE346D63}")] FOLDERID_ControlPanelFolder, /// Cookies [KnownFolderDetail("{2B0F765D-C0E9-4171-908E-08A611B84FF6}", Equivalent = Environment.SpecialFolder.Cookies)] FOLDERID_Cookies, /// Desktop [KnownFolderDetail("{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}", Equivalent = Environment.SpecialFolder.Desktop)] FOLDERID_Desktop, /// DeviceMetadataStore [KnownFolderDetail("{5CE4A5E9-E4EB-479D-B89F-130C02886155}")] FOLDERID_DeviceMetadataStore, /// Documents [KnownFolderDetail("{FDD39AD0-238F-46AF-ADB4-6C85480369C7}", Equivalent = Environment.SpecialFolder.MyDocuments)] FOLDERID_Documents, /// Documents [KnownFolderDetail("{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}")] FOLDERID_DocumentsLibrary, /// Downloads [KnownFolderDetail("{374DE290-123F-4565-9164-39C4925E467B}")] FOLDERID_Downloads, /// Favorites [KnownFolderDetail("{1777F761-68AD-4D8A-87BD-30B759FA33DD}", Equivalent = Environment.SpecialFolder.Favorites)] FOLDERID_Favorites, /// Fonts [KnownFolderDetail("{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_FONTS)] FOLDERID_Fonts, /// Games [KnownFolderDetail("{CAC52C1A-B53D-4edc-92D7-6B2E8AC19434}")] FOLDERID_Games, /// GameExplorer [KnownFolderDetail("{054FAE61-4DD8-4787-80B6-090220C4B700}")] FOLDERID_GameTasks, /// History [KnownFolderDetail("{D9DC8A3B-B784-432E-A781-5A1130A75963}", Equivalent = Environment.SpecialFolder.History)] FOLDERID_History, /// Homegroup [KnownFolderDetail("{52528A6B-B9E3-4ADD-B60D-588C2DBA842D}")] FOLDERID_HomeGroup, /// The user's username (%USERNAME%) [KnownFolderDetail("{9B74B6A3-0DFD-4f11-9E78-5F7800F2E772}")] FOLDERID_HomeGroupCurrentUser, /// ImplicitAppShortcuts [KnownFolderDetail("{BCB5256F-79F6-4CEE-B725-DC34E402FD46}")] FOLDERID_ImplicitAppShortcuts, /// Temporary Internet Files [KnownFolderDetail("{352481E8-33BE-4251-BA85-6007CAEDCF9D}", Equivalent = Environment.SpecialFolder.InternetCache)] FOLDERID_InternetCache, /// The Internet [KnownFolderDetail("{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}")] FOLDERID_InternetFolder, /// Libraries [KnownFolderDetail("{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}")] FOLDERID_Libraries, /// Links [KnownFolderDetail("{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}")] FOLDERID_Links, /// Local [KnownFolderDetail("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}", Equivalent = Environment.SpecialFolder.LocalApplicationData)] FOLDERID_LocalAppData, /// LocalLow [KnownFolderDetail("{A520A1A4-1780-4FF6-BD18-167343C5AF16}")] FOLDERID_LocalAppDataLow, /// None [KnownFolderDetail("{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_RESOURCES_LOCALIZED)] FOLDERID_LocalizedResourcesDir, /// Music [KnownFolderDetail("{4BD8D571-6D19-48D3-BE97-422220080E43}", Equivalent = Environment.SpecialFolder.MyMusic)] FOLDERID_Music, /// Music [KnownFolderDetail("{2112AB0A-C86A-4FFE-A368-0DE96E47012E}")] FOLDERID_MusicLibrary, /// Network Shortcuts [KnownFolderDetail("{C5ABBF53-E17F-4121-8900-86626FC2C973}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_NETHOOD)] FOLDERID_NetHood, /// Network [KnownFolderDetail("{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}")] FOLDERID_NetworkFolder, /// Original Images [KnownFolderDetail("{2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39}")] FOLDERID_OriginalImages, /// Slide Shows [KnownFolderDetail("{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}")] FOLDERID_PhotoAlbums, /// Pictures [KnownFolderDetail("{A990AE9F-A03B-4E80-94BC-9912D7504104}")] FOLDERID_PicturesLibrary, /// Pictures [KnownFolderDetail("{33E28130-4E1E-4676-835A-98395C3BC3BB}", Equivalent = Environment.SpecialFolder.MyPictures)] FOLDERID_Pictures, /// Playlists [KnownFolderDetail("{DE92C1C7-837F-4F69-A3BB-86E631204A23}")] FOLDERID_Playlists, /// Printers [KnownFolderDetail("{76FC4E2D-D6AD-4519-A663-37BD56068185}")] FOLDERID_PrintersFolder, /// Printer Shortcuts [KnownFolderDetail("{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_PRINTHOOD)] FOLDERID_PrintHood, /// The user's username (%USERNAME%) [KnownFolderDetail("{5E6C858F-0E22-4760-9AFE-EA3317B67173}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_PROFILE)] FOLDERID_Profile, /// ProgramData [KnownFolderDetail("{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}", Equivalent = Environment.SpecialFolder.CommonApplicationData)] FOLDERID_ProgramData, /// Program Files [KnownFolderDetail("{905e63b6-c1bf-494e-b29c-65b732d3d21a}", Equivalent = Environment.SpecialFolder.ProgramFiles)] FOLDERID_ProgramFiles, /// Program Files [KnownFolderDetail("{6D809377-6AF0-444b-8957-A3773F02200E}")] FOLDERID_ProgramFilesX64, /// Program Files [KnownFolderDetail("{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_PROGRAM_FILESX86)] FOLDERID_ProgramFilesX86, /// Common Files [KnownFolderDetail("{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}", Equivalent = Environment.SpecialFolder.CommonProgramFiles)] FOLDERID_ProgramFilesCommon, /// Common Files [KnownFolderDetail("{6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D}")] FOLDERID_ProgramFilesCommonX64, /// Common Files [KnownFolderDetail("{DE974D24-D9C6-4D3E-BF91-F4455120B917}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_PROGRAM_FILES_COMMONX86)] FOLDERID_ProgramFilesCommonX86, /// Programs [KnownFolderDetail("{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}", Equivalent = Environment.SpecialFolder.Programs)] FOLDERID_Programs, /// Public [KnownFolderDetail("{DFDF76A2-C82A-4D63-906A-5644AC457385}")] FOLDERID_Public, /// Public Desktop [KnownFolderDetail("{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_DESKTOPDIRECTORY)] FOLDERID_PublicDesktop, /// Public Documents [KnownFolderDetail("{ED4824AF-DCE4-45A8-81E2-FC7965083634}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_DOCUMENTS)] FOLDERID_PublicDocuments, /// Public Downloads [KnownFolderDetail("{3D644C9B-1FB8-4f30-9B45-F670235F79C0}")] FOLDERID_PublicDownloads, /// GameExplorer [KnownFolderDetail("{DEBF2536-E1A8-4c59-B6A2-414586476AEA}")] FOLDERID_PublicGameTasks, /// Libraries [KnownFolderDetail("{48DAF80B-E6CF-4F4E-B800-0E69D84EE384}")] FOLDERID_PublicLibraries, /// Public Music [KnownFolderDetail("{3214FAB5-9757-4298-BB61-92A9DEAA44FF}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_MUSIC)] FOLDERID_PublicMusic, /// Public Pictures [KnownFolderDetail("{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_PICTURES)] FOLDERID_PublicPictures, /// Ringtones [KnownFolderDetail("{E555AB60-153B-4D17-9F04-A5FE99FC15EC}")] FOLDERID_PublicRingtones, /// Public Account Pictures [KnownFolderDetail("{0482af6c-08f1-4c34-8c90-e17ec98b1e17}")] FOLDERID_PublicUserTiles, /// Public Videos [KnownFolderDetail("{2400183A-6185-49FB-A2D8-4A392A602BA3}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_COMMON_VIDEO)] FOLDERID_PublicVideos, /// Quick Launch [KnownFolderDetail("{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}")] FOLDERID_QuickLaunch, /// Recent Items [KnownFolderDetail("{AE50C081-EBD2-438A-8655-8A092E34987A}", Equivalent = Environment.SpecialFolder.Recent)] FOLDERID_Recent, /// Recorded TV [KnownFolderDetail("{1A6FDBA2-F42D-4358-A798-B74D745926C5}")] FOLDERID_RecordedTVLibrary, /// Recycle Bin [KnownFolderDetail("{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}")] FOLDERID_RecycleBinFolder, /// Resources [KnownFolderDetail("{8AD10C31-2ADB-4296-A8F7-E4701232C972}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_RESOURCES)] FOLDERID_ResourceDir, /// Ringtones [KnownFolderDetail("{C870044B-F49E-4126-A9C3-B52A1FF411E8}")] FOLDERID_Ringtones, /// Roaming [KnownFolderDetail("{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}", Equivalent = Environment.SpecialFolder.ApplicationData)] FOLDERID_RoamingAppData, /// RoamedTileImages [KnownFolderDetail("{AAA8D5A5-F1D6-4259-BAA8-78E7EF60835E}")] FOLDERID_RoamedTileImages, /// RoamingTiles [KnownFolderDetail("{00BCFC5A-ED94-4e48-96A1-3F6217F21990}")] FOLDERID_RoamingTiles, /// Sample Music [KnownFolderDetail("{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}")] FOLDERID_SampleMusic, /// Sample Pictures [KnownFolderDetail("{C4900540-2379-4C75-844B-64E6FAF8716B}")] FOLDERID_SamplePictures, /// Sample Playlists [KnownFolderDetail("{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}")] FOLDERID_SamplePlaylists, /// Sample Videos [KnownFolderDetail("{859EAD94-2E85-48AD-A71A-0969CB56A6CD}")] FOLDERID_SampleVideos, /// Saved Games [KnownFolderDetail("{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}")] FOLDERID_SavedGames, /// Saved Pictures [KnownFolderDetail("{3B193882-D3AD-4eab-965A-69829D1FB59F}")] FOLDERID_SavedPictures, /// Saved Pictures Library [KnownFolderDetail("{E25B5812-BE88-4bd9-94B0-29233477B6C3}")] FOLDERID_SavedPicturesLibrary, /// Searches [KnownFolderDetail("{7d1d3a04-debb-4115-95cf-2f29da2920da}")] FOLDERID_SavedSearches, /// Screenshots [KnownFolderDetail("{b7bede81-df94-4682-a7d8-57a52620b86f}")] FOLDERID_Screenshots, /// Offline Files [KnownFolderDetail("{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}")] FOLDERID_SEARCH_CSC, /// History [KnownFolderDetail("{0D4C3DB6-03A3-462F-A0E6-08924C41B5D4}")] FOLDERID_SearchHistory, /// Search Results [KnownFolderDetail("{190337d1-b8ca-4121-a639-6d472d16972a}")] FOLDERID_SearchHome, /// Microsoft Office Outlook [KnownFolderDetail("{98ec0e18-2098-4d44-8644-66979315a281}")] FOLDERID_SEARCH_MAPI, /// Templates [KnownFolderDetail("{7E636BFE-DFA9-4D5E-B456-D7B39851D8A9}")] FOLDERID_SearchTemplates, /// SendTo [KnownFolderDetail("{8983036C-27C0-404B-8F08-102D10DCFD74}", Equivalent = Environment.SpecialFolder.SendTo)] FOLDERID_SendTo, /// Gadgets [KnownFolderDetail("{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}")] FOLDERID_SidebarDefaultParts, /// Gadgets [KnownFolderDetail("{A75D362E-50FC-4fb7-AC2C-A8BEAA314493}")] FOLDERID_SidebarParts, /// OneDrive [KnownFolderDetail("{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}")] FOLDERID_SkyDrive, /// Camera Roll [KnownFolderDetail("{767E6811-49CB-4273-87C2-20F355E1085B}")] FOLDERID_SkyDriveCameraRoll, /// Documents [KnownFolderDetail("{24D89E24-2F19-4534-9DDE-6A6671FBB8FE}")] FOLDERID_SkyDriveDocuments, /// Pictures [KnownFolderDetail("{339719B5-8C47-4894-94C2-D8F77ADD44A6}")] FOLDERID_SkyDrivePictures, /// Start Menu [KnownFolderDetail("{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}", Equivalent = Environment.SpecialFolder.StartMenu)] FOLDERID_StartMenu, /// Startup [KnownFolderDetail("{B97D20BB-F46A-4C97-BA10-5E3608430854}", Equivalent = Environment.SpecialFolder.Startup)] FOLDERID_Startup, /// Sync Center [KnownFolderDetail("{43668BF8-C14E-49B2-97C9-747784D784B7}")] FOLDERID_SyncManagerFolder, /// Sync Results [KnownFolderDetail("{289a9a43-be44-4057-a41b-587a76d7e7f9}")] FOLDERID_SyncResultsFolder, /// Sync Setup [KnownFolderDetail("{0F214138-B1D3-4a90-BBA9-27CBC0C5389A}")] FOLDERID_SyncSetupFolder, /// System32 [KnownFolderDetail("{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}", Equivalent = Environment.SpecialFolder.System)] FOLDERID_System, /// System32 [KnownFolderDetail("{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_SYSTEMX86)] FOLDERID_SystemX86, /// Templates [KnownFolderDetail("{A63293E8-664E-48DB-A079-DF759E0509F7}", Equivalent = Environment.SpecialFolder.Templates)] FOLDERID_Templates, /// User Pinned [KnownFolderDetail("{9E3995AB-1F9C-4F13-B827-48B24B6C7174}")] FOLDERID_UserPinned, /// Users [KnownFolderDetail("{0762D272-C50A-4BB0-A382-697DCD729B80}")] FOLDERID_UserProfiles, /// Programs [KnownFolderDetail("{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}")] FOLDERID_UserProgramFiles, /// Programs [KnownFolderDetail("{BCBD3057-CA5C-4622-B42D-BC56DB0AE516}")] FOLDERID_UserProgramFilesCommon, /// The user's full name (for instance, Jean Philippe Bagel) entered when the user account was created. [KnownFolderDetail("{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}")] FOLDERID_UsersFiles, /// Libraries [KnownFolderDetail("{A302545D-DEFF-464b-ABE8-61C8648D939B}")] FOLDERID_UsersLibraries, /// Videos [KnownFolderDetail("{18989B1D-99B5-455B-841C-AB7C74E4DDFC}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_MYVIDEO)] FOLDERID_Videos, /// Videos [KnownFolderDetail("{491E922F-5643-4AF4-A7EB-4E7A138D8174}")] FOLDERID_VideosLibrary, /// Windows [KnownFolderDetail("{F38BF404-1D43-42F2-9305-67DE0B28FC23}", Equivalent = (Environment.SpecialFolder)CSIDL.CSIDL_WINDOWS)] FOLDERID_Windows, } /// /// Exposes methods that allow an application to retrieve information about a known folder's category, type, GUID, pointer to an item /// identifier list (PIDL) value, redirection capabilities, and definition. It provides a method for the retrival of a known folder's /// IShellItem object. It also provides methods to get or set the path of the known folder. /// [ComImport, Guid("3AA7AF7E-9B36-420c-A8E3-F77D4674A488"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb762502")] public interface IKnownFolder { /// Gets the ID of the selected folder. /// /// When this method returns, returns the KNOWNFOLDERID value of the known folder. Note, KNOWNFOLDERID values are GUIDs. /// Guid GetId(); /// Retrieves the category—virtual, fixed, common, or per-user—of the selected folder. /// When this method returns, contains a pointer to the KF_CATEGORY of the selected folder. KF_CATEGORY GetCategory(); /// /// Retrieves the location of a known folder in the Shell namespace in the form of a Shell item (IShellItem or derived interface). /// /// /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// A reference to the IID of the requested interface. /// /// When this method returns, contains the interface pointer requested in riid. This is typically IShellItem or IShellItem2. /// [return: MarshalAs(UnmanagedType.Interface)] IShellItem GetShellItem([In] KNOWN_FOLDER_FLAG dwFlags, in Guid riid); /// Retrieves the path of a known folder as a string. /// /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// /// When this method returns, contains the address of a pointer to a null-terminated buffer that contains the path. The calling /// application is responsible for calling CoTaskMemFree to free this resource when it is no longer needed. /// SafeCoTaskMemString GetPath([In] KNOWN_FOLDER_FLAG dwFlags); /// Assigns a new path to a known folder. /// Either zero or the following value: KF_FLAG_DONT_UNEXPAND /// The PSZ path. void SetPath([In] KNOWN_FOLDER_FLAG dwFlags, [In, MarshalAs(UnmanagedType.LPWStr)] string pszPath); /// Gets the location of the Shell namespace folder in the IDList (ITEMIDLIST) form. /// /// Flags that specify special retrieval options. This value can be 0; otherwise, one or more of the KNOWN_FOLDER_FLAG values. /// /// /// When this method returns, contains the address of an absolute PIDL. This parameter is passed uninitialized. The calling /// application is responsible for freeing this resource when it is no longer needed. /// [return: ComAliasName("ShellObjects.wirePIDL")] PIDL GetIDList([In] KNOWN_FOLDER_FLAG dwFlags); /// Retrieves the folder type. /// When this returns, contains a pointer to a FOLDERTYPEID (a GUID) that identifies the known folder type. Guid GetFolderType(); /// /// Gets a value that states whether the known folder can have its path set to a new value or what specific restrictions or /// prohibitions are placed on that redirection. /// /// /// When this method returns, contains a pointer to a KF_REDIRECTION_CAPABILITIES value that indicates the redirection /// capabilities for this folder. /// KF_REDIRECTION_CAPABILITIES GetRedirectionCapabilities(); /// /// Retrieves a structure that contains the defining elements of a known folder, which includes the folder's category, name, /// path, description, tooltip, icon, and other properties. /// /// /// When this method returns, contains a pointer to the KNOWNFOLDER_DEFINITION structure. When no longer needed, the calling /// application is responsible for calling FreeKnownFolderDefinitionFields to free this resource. /// KNOWNFOLDER_DEFINITION GetFolderDefinition(); } /// Exposes methods that create, enumerate or manage existing known folders. [ComImport, Guid("8BE2D872-86AA-4d47-B776-32CCA40C7018"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(CKnownFolderManager))] [PInvokeData("Shobjidl.h", MSDNShortId = "bb761744")] public interface IKnownFolderManager { /// Gets the KNOWNFOLDERID that is the equivalent of a legacy CSIDL value. /// The CSIDL value. /// When this method returns, contains a pointer to the KNOWNFOLDERID. This pointer is passed uninitialized. Guid FolderIdFromCsidl([In] int nCsidl); /// Gets the legacy CSIDL value that is the equivalent of a given KNOWNFOLDERID. /// Reference to the KNOWNFOLDERID. /// When this method returns, contains a pointer to the CSIDL value. This pointer is passed uninitialized. CSIDL FolderIdToCsidl(in Guid rfid); /// /// Gets an array of all registered known folder IDs. This can be used in enumerating all known folders. /// /// /// Type: KNOWNFOLDERID** /// /// When this method returns, contains a pointer to an array of all KNOWNFOLDERID values registered with the system. Use /// CoTaskMemFree to free these resources when they are no longer needed. /// /// /// /// Type: UINT* /// /// When this method returns, contains a pointer to the number of KNOWNFOLDERID values in the array at ppKFId. The [in] /// functionality of this parameter is not used. /// /// /// /// The caller of this method must have User privileges. /// You can use StringFromCLSID or StringFromGUID2 to convert the retrieved KNOWNFOLDERID values to strings. /// // https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-iknownfoldermanager-getfolderids HRESULT // GetFolderIds( KNOWNFOLDERID **ppKFId, UINT *pCount ); [PInvokeData("shobjidl_core.h", MSDNShortId = "3ac09fc4-15c4-4346-94ad-2a4617c463d1")] void GetFolderIds(out SafeCoTaskMemHandle ppKFId, out uint pCount); /// /// Gets an object that represents a known folder identified by its KNOWNFOLDERID. The object allows you to query certain folder /// properties, get the current path of the folder, redirect the folder to another location, and get the path of the folder as an ITEMIDLIST. /// /// Reference to the KNOWNFOLDERID. /// When this method returns, contains an interface pointer to the IKnownFolder object that represents the folder. [return: MarshalAs(UnmanagedType.Interface)] IKnownFolder GetFolder(in Guid rfid); /// /// Gets an object that represents a known folder identified by its canonical name. The object allows you to query certain folder /// properties, get the current path of the folder, redirect the folder to another location, and get the path of the folder as an ITEMIDLIST. /// /// /// A pointer to the non-localized, canonical name for the known folder, stored as a null-terminated Unicode string. If this /// folder is a common or per-user folder, this value is also used as the value name of the "User Shell Folders" registry /// settings. This value is retrieved through the pszName member of the folder's KNOWNFOLDER_DEFINITION structure. /// /// /// When this method returns, contains the address of a pointer to the IKnownFolder object that represents the known folder. /// [return: MarshalAs(UnmanagedType.Interface)] IKnownFolder GetFolderByName([In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName); /// /// Adds a new known folder to the registry. Used particularly by independent software vendors (ISVs) that are adding one of /// their own folders to the known folder system. /// /// A GUID that represents the known folder. /// A pointer to a valid KNOWNFOLDER_DEFINITION structure that provides the details of the new folder. void RegisterFolder(in Guid rfid, in KNOWNFOLDER_DEFINITION pKFD); /// /// Remove a known folder from the registry, which makes it unknown to the known folder system. This method does not remove the /// folder itself. /// /// GUID or KNOWNFOLDERID that represents the known folder. void UnregisterFolder(in Guid rfid); /// /// Gets an object that represents a known folder based on a file system path. The object allows you to query certain folder /// properties, get the current path of the folder, redirect the folder to another location, and get the path of the folder as an ITEMIDLIST. /// /// Pointer to a null-terminated Unicode string of length MAX_PATH that contains a path to a known folder. /// /// One of the following values that specify the precision of the match of path and known folder: FFFP_EXACTMATCH = Retrieve only /// the specific known folder for the given file path; FFFP_NEARESTPARENTMATCH = If an exact match is not found for the given /// file path, retrieve the first known folder that matches one of its parent folders walking up the parent tree. /// /// /// When this method returns, contains the address of a pointer to the IKnownFolder object that represents the known folder. /// [return: MarshalAs(UnmanagedType.Interface)] IKnownFolder FindFolderFromPath([In, MarshalAs(UnmanagedType.LPWStr)] string pszPath, [In] FFFP_MODE mode); /// /// Gets an object that represents a known folder based on an IDList. The object allows you to query certain folder properties, /// get the current path of the folder, redirect the folder to another location, and get the path of the folder as an ITEMIDLIST. /// /// A pointer to the IDList. /// /// When this method returns, contains the address of a pointer to the IKnownFolder object that represents the known folder. /// [return: MarshalAs(UnmanagedType.Interface)] IKnownFolder FindFolderFromIDList([In] PIDL pidl); /// Redirects folder requests for common and per-user folders. /// A reference to the KNOWNFOLDERID of the folder to be redirected. /// /// The handle of the parent window used to display copy engine progress UI dialogs when KF_REDIRECT_WITH_UI i passed in the /// flags parameter. If no progress dialog is needed, this value can be NULL. /// /// The KF_REDIRECT_FLAGS options for redirection. /// /// A pointer to the new path for the folder. This is a null-terminated Unicode string. This value can be NULL. /// /// The number of KNOWNFOLDERID values in the array at pExclusion. /// /// Pointer to an array of KNOWNFOLDERID values that refer to subfolders of rfid that should be excluded from the redirection. If /// no subfolders are excluded, this value can be NULL. /// /// /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that contains an error /// message if one was generated. This value can be NULL. /// SafeCoTaskMemString Redirect(in Guid rfid, [In] HWND hwnd, [In] KF_REDIRECT_FLAGS flags, [In, MarshalAs(UnmanagedType.LPWStr)] string pszTargetPath, [In] uint cFolders, [In] Guid[] pExclusion); } /// Defines the specifics of a known folder. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] [PInvokeData("Shobjidl.h", MSDNShortId = "bb773325")] public struct KNOWNFOLDER_DEFINITION { /// A single value from the KF_CATEGORY constants that classifies the folder as virtual, fixed, common, or per-user. public KF_CATEGORY category; /// /// A pointer to the non-localized, canonical name for the known folder, stored as a null-terminated Unicode string. If this /// folder is a common or per-user folder, this value is also used as the value name of the "User Shell Folders" registry /// settings. This name is meant to be a unique, human-readable name. Third parties are recommended to follow the format /// Company.Application.Name. The name given here should not be confused with the display name. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszName; /// /// A pointer to a short description of the known folder, stored as a null-terminated Unicode string. This description should /// include the folder's purpose and usage. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszDescription; /// /// A KNOWNFOLDERID value that names another known folder to serve as the parent folder. Applies to common and per-user folders /// only. This value is used in conjunction with pszRelativePath. See Remarks for more details. This value is optional if no /// value is provided for pszRelativePath. /// public Guid fidParent; /// /// Optional. A pointer to a path relative to the parent folder specified in fidParent. This is a null-terminated Unicode string, /// refers to the physical file system path, and is not localized. Applies to common and per-user folders only. See Remarks for /// more details. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszRelativePath; /// /// A pointer to the Shell namespace folder path of the folder, stored as a null-terminated Unicode string. Applies to virtual /// folders only. For example, Control Panel has a parsing name of ::%CLSID_MyComputer%\::%CLSID_ControlPanel%. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszParsingName; /// /// Optional. A pointer to the default tooltip resource used for this known folder when it is created. This is a null-terminated /// Unicode string in this form: /// Module name, Resource ID /// /// For example, @%_SYS_MOD_PATH%,-12688 is the tooltip for Common Pictures.When the folder is created, this string is stored in /// that folder's copy of Desktop.ini. It can be changed later by other Shell APIs. This resource might be localized. /// /// This information is not required for virtual folders. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszTooltip; /// /// Optional. A pointer to the default localized name resource used when the folder is created. This is a null-terminated Unicode /// string in this form: /// Module name, Resource ID /// /// When the folder is created, this string is stored in that folder's copy of Desktop.ini. It can be changed later by other /// Shell APIs. /// /// This information is not required for virtual folders. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszLocalizedName; /// /// Optional. A pointer to the default icon resource used when the folder is created. This is a null-terminated Unicode string in /// this form: /// Module name, Resource ID /// /// When the folder is created, this string is stored in that folder's copy of Desktop.ini. It can be changed later by other /// Shell APIs. /// /// This information is not required for virtual folders. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszIcon; /// /// Optional. A pointer to a Security Descriptor Definition Language format string. This is a null-terminated Unicode string that /// describes the default security descriptor that the folder receives when it is created. If this parameter is NULL, the new /// folder inherits the security descriptor of its parent. This is particularly useful for common folders that are accessed by /// all users. /// [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszSecurity; /// /// Optional. Default file system attributes given to the folder when it is created. For example, the file could be hidden and /// read-only (FILE_ATTRIBUTE_HIDDEN and FILE_ATTRIBUTE_READONLY). For a complete list of possible values, see the /// dwFlagsAndAttributes parameter of the CreateFile function. Set to -1 if not needed. /// public uint dwAttributes; /// /// Optional. One of more values from the KF_DEFINITION_FLAGS enumeration that allow you to restrict redirection, allow PC-to-PC /// roaming, and control the time at which the known folder is created. Set to 0 if not needed. /// public KF_DEFINITION_FLAGS kfdFlags; /// /// One of the FOLDERTYPEID values that identifies the known folder type based on its contents (such as documents, music, or /// photographs). This value is a GUID. /// public Guid ftidType; } /// Class interface for IKnownFolderManager. [ComImport, Guid("4df0c730-df9d-4ae3-9153-aa6b82e9795a"), ClassInterface(ClassInterfaceType.None)] public class CKnownFolderManager { } /// Provides information about a . [AttributeUsage(AttributeTargets.Field)] internal class KnownFolderDetailAttribute : AssociateAttribute { /// The equivalent SpecialFolder. public Environment.SpecialFolder Equivalent = (Environment.SpecialFolder)0XFFFF; /// Initializes a new instance of the class with a GUID for the . /// The GUID for the . public KnownFolderDetailAttribute(string knownFolderGuid) : base(knownFolderGuid) { } } } }