* Reorganized files to reduce file size

* Added documentation
* Added IShellLibrary and supporting constructs
pull/10/head
David Hall 2018-01-09 14:08:57 -07:00
parent a6d2584354
commit a23370af91
11 changed files with 3415 additions and 2960 deletions

View File

@ -0,0 +1,82 @@
using System;
using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.Shell32;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
/// <summary>Extension methods for <see cref="KNOWNFOLDERID"/>.</summary>
public static class KnownFolderIdExt
{
private const string RegPath =
@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\";
private const KNOWN_FOLDER_FLAG stdGetFlags =
KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT_PATH | KNOWN_FOLDER_FLAG.KF_FLAG_NOT_PARENT_RELATIVE |
KNOWN_FOLDER_FLAG.KF_FLAG_NO_ALIAS | KNOWN_FOLDER_FLAG.KF_FLAG_DONT_VERIFY;
/// <summary>Retrieves the full path associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The path.</returns>
public static string FullPath(this KNOWNFOLDERID id)
{
SHGetKnownFolderPath(id.Guid(), stdGetFlags, SafeTokenHandle.Null, out var path);
return path.ToString(-1);
}
/// <summary>Gets a registry property associated with this known folder.</summary>
/// <typeparam name="T">Return type.</typeparam>
/// <param name="id">The known folder.</param>
/// <param name="valueName">Name of the property (value under registry key).</param>
/// <returns>Retrieved value or default(T) if no value exists.</returns>
public static T GetRegistryProperty<T>(this KNOWNFOLDERID id, string valueName) =>
(T)Microsoft.Win32.Registry.GetValue(RegPath + id.Guid().ToString("B"), valueName, default(T));
/// <summary>Retrieves the Guid associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The GUID.</returns>
public static Guid Guid(this KNOWNFOLDERID id)
{
var attr = typeof(KNOWNFOLDERID).GetField(id.ToString()).GetCustomAttributes(typeof(KnownFolderDetailAttribute), false);
return attr.Length > 0 ? ((KnownFolderDetailAttribute) attr[0]).guid : System.Guid.Empty;
}
/// <summary>Retrieves the <see cref="KNOWNFOLDERID"/> associated with the <see cref="Environment.SpecialFolder"/>.</summary>
/// <param name="spFolder">The <see cref="Environment.SpecialFolder"/>.</param>
/// <returns>Matching <see cref="KNOWNFOLDERID"/>.</returns>
public static KNOWNFOLDERID KnownFolderId(this System.Environment.SpecialFolder spFolder)
{
if (spFolder == Environment.SpecialFolder.Personal) return KNOWNFOLDERID.FOLDERID_Documents;
if (spFolder == Environment.SpecialFolder.DesktopDirectory) return KNOWNFOLDERID.FOLDERID_Desktop;
foreach (KNOWNFOLDERID val in Enum.GetValues(typeof(KNOWNFOLDERID)))
if (val.SpecialFolder() == spFolder) return val;
throw new InvalidCastException(@"There is not a Known Folder equivalent to this SpecialFolder.");
}
/// <summary>Retrieves the name associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The name.</returns>
public static string Name(this KNOWNFOLDERID id) => id.GetRegistryProperty<string>("Name");
/// <summary>Retrieves the PIDL associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The PIDL.</returns>
public static PIDL PIDL(this KNOWNFOLDERID id)
{
SHGetKnownFolderIDList(id.Guid(), stdGetFlags, SafeTokenHandle.Null, out var pidl);
return pidl;
}
/// <summary>Retrieves the <see cref="Environment.SpecialFolder"/> associated with a <see cref="KNOWNFOLDERID"/> if it exists.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The <see cref="Environment.SpecialFolder"/> if defined, <c>null</c> otherwise.</returns>
public static Environment.SpecialFolder? SpecialFolder(this KNOWNFOLDERID id)
{
var attr = typeof(KNOWNFOLDERID).GetField(id.ToString()).GetCustomAttributes(typeof(KnownFolderDetailAttribute), false);
var ret = (Environment.SpecialFolder) 0XFFFF;
if (attr.Length > 0)
ret = ((KnownFolderDetailAttribute) attr[0]).Equivalent;
return ret == (Environment.SpecialFolder) 0XFFFF ? (Environment.SpecialFolder?) null : ret;
}
}
}

View File

@ -1,542 +0,0 @@
using System;
using Vanara.InteropServices;
using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.Shell32;
// ReSharper disable InconsistentNaming
namespace Vanara.PInvoke
{
/// <summary>Extension methods for <see cref="KNOWNFOLDERID"/>.</summary>
public static class KnownFolderIdExt
{
private const string RegPath =
@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\";
private const KNOWN_FOLDER_FLAG stdGetFlags =
KNOWN_FOLDER_FLAG.KF_FLAG_DEFAULT_PATH | KNOWN_FOLDER_FLAG.KF_FLAG_NOT_PARENT_RELATIVE |
KNOWN_FOLDER_FLAG.KF_FLAG_NO_ALIAS | KNOWN_FOLDER_FLAG.KF_FLAG_DONT_VERIFY;
/// <summary>Retrieves the full path associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The path.</returns>
public static string FullPath(this KNOWNFOLDERID id)
{
SafeCoTaskMemHandle path;
SHGetKnownFolderPath(id.Guid(), stdGetFlags, SafeTokenHandle.Null, out path);
return path.ToString(-1);
}
/// <summary>Gets a registry property associated with this known folder.</summary>
/// <typeparam name="T">Return type.</typeparam>
/// <param name="id">The known folder.</param>
/// <param name="valueName">Name of the property (value under registry key).</param>
/// <returns>Retrieved value or default(T) if no value exists.</returns>
public static T GetRegistryProperty<T>(this KNOWNFOLDERID id, string valueName) => (T)
Microsoft.Win32.Registry.GetValue(RegPath + id.Guid().ToString("B"), valueName, default(T));
/// <summary>Retrieves the Guid associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The GUID.</returns>
public static Guid Guid(this KNOWNFOLDERID id)
{
var attr = typeof(KNOWNFOLDERID).GetField(id.ToString())
.GetCustomAttributes(typeof(KnownFolderDetailAttribute), false);
return attr.Length > 0 ? ((KnownFolderDetailAttribute) attr[0]).guid : System.Guid.Empty;
}
/// <summary>Retrieves the <see cref="KNOWNFOLDERID"/> associated with the <see cref="Environment.SpecialFolder"/>.</summary>
/// <param name="spFolder">The <see cref="Environment.SpecialFolder"/>.</param>
/// <returns>Matching <see cref="KNOWNFOLDERID"/>.</returns>
public static KNOWNFOLDERID KnownFolderId(this System.Environment.SpecialFolder spFolder)
{
if (spFolder == Environment.SpecialFolder.Personal) return KNOWNFOLDERID.FOLDERID_Documents;
if (spFolder == Environment.SpecialFolder.DesktopDirectory) return KNOWNFOLDERID.FOLDERID_Desktop;
foreach (KNOWNFOLDERID val in Enum.GetValues(typeof(KNOWNFOLDERID)))
if (val.SpecialFolder() == spFolder) return val;
throw new InvalidCastException(@"There is not a Known Folder equivalent to this SpecialFolder.");
}
/// <summary>Retrieves the name associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The name.</returns>
public static string Name(this KNOWNFOLDERID id) => id.GetRegistryProperty<string>("Name");
/// <summary>Retrieves the PIDL associated with a <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The PIDL.</returns>
public static PIDL PIDL(this KNOWNFOLDERID id)
{
PIDL pidl;
SHGetKnownFolderIDList(id.Guid(), stdGetFlags, SafeTokenHandle.Null, out pidl);
return pidl;
}
/// <summary>Retrieves the <see cref="Environment.SpecialFolder"/> associated with a <see cref="KNOWNFOLDERID"/> if it exists.</summary>
/// <param name="id">The known folder.</param>
/// <returns>The <see cref="Environment.SpecialFolder"/> if defined, <c>null</c> otherwise.</returns>
public static Environment.SpecialFolder? SpecialFolder(this KNOWNFOLDERID id)
{
var attr = typeof(KNOWNFOLDERID).GetField(id.ToString())
.GetCustomAttributes(typeof(KnownFolderDetailAttribute), false);
var ret = (Environment.SpecialFolder) 0XFFFF;
if (attr.Length > 0)
ret = ((KnownFolderDetailAttribute) attr[0]).Equivalent;
return ret == (Environment.SpecialFolder) 0XFFFF ? (Environment.SpecialFolder?) null : ret;
}
}
public static partial class Shell32
{
/// <summary>
/// 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.
/// </summary>
[PInvokeData("Knownfolders.h", MSDNShortId = "dd378457")]
public enum KNOWNFOLDERID
{
/// <summary>Account Pictures</summary>
[KnownFolderDetail("{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}")] FOLDERID_AccountPictures,
/// <summary>Get Programs</summary>
[KnownFolderDetail("{de61d971-5ebc-4f02-a3a9-6c82895e5c04}")] FOLDERID_AddNewPrograms,
[KnownFolderDetail("{724EF170-A42D-4FEF-9F26-B60E846FBA4F}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_ADMINTOOLS)]
FOLDERID_AdminTools,
[KnownFolderDetail("{A3918781-E5F2-4890-B3D9-A7E54332328C}")] FOLDERID_ApplicationShortcuts,
/// <summary>Applications</summary>
[KnownFolderDetail("{1e87508d-89c2-42f0-8a7e-645a0f50ca58}")] FOLDERID_AppsFolder,
/// <summary>Installed Updates</summary>
[KnownFolderDetail("{a305ce99-f527-492b-8b1a-7e76fa98d6e4}")] FOLDERID_AppUpdates,
/// <summary>Camera Roll</summary>
[KnownFolderDetail("{AB5FB87B-7CE2-4F83-915D-550846C9537B}")] FOLDERID_CameraRoll,
/// <summary>Temporary Burn Folder</summary>
[KnownFolderDetail("{9E52AB10-F80D-49DF-ACB8-4330F5687855}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_CDBURN_AREA)]
FOLDERID_CDBurning,
/// <summary>Programs and Features</summary>
[KnownFolderDetail("{df7266ac-9274-4867-8d55-3bd661de872d}")] FOLDERID_ChangeRemovePrograms,
/// <summary>Administrative Tools</summary>
[KnownFolderDetail("{D0384E7D-BAC3-4797-8F14-CBA229B392B5}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_ADMINTOOLS)]
FOLDERID_CommonAdminTools,
/// <summary>OEM Links</summary>
[KnownFolderDetail("{C1BAE2D0-10DF-4334-BEDD-7AA20B227A9D}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_OEM_LINKS)]
FOLDERID_CommonOEMLinks,
/// <summary>Programs</summary>
[KnownFolderDetail("{0139D44E-6AFE-49F2-8690-3DAFCAE6FFB8}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_PROGRAMS)]
FOLDERID_CommonPrograms,
/// <summary>Start Menu</summary>
[KnownFolderDetail("{A4115719-D62E-491D-AA7C-E74B8BE3B067}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_STARTMENU)]
FOLDERID_CommonStartMenu,
/// <summary>Startup</summary>
[KnownFolderDetail("{82A5EA35-D9CD-47C5-9629-E15D2F714E6E}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_STARTUP)]
FOLDERID_CommonStartup,
/// <summary>Templates</summary>
[KnownFolderDetail("{B94237E7-57AC-4347-9151-B08C6C32D1F7}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_TEMPLATES)]
FOLDERID_CommonTemplates,
/// <summary>Computer</summary>
[KnownFolderDetail("{0AC0837C-BBF8-452A-850D-79D08E667CA7}", Equivalent = Environment.SpecialFolder.MyComputer)]
FOLDERID_ComputerFolder,
/// <summary>Conflicts</summary>
[KnownFolderDetail("{4bfefb45-347d-4006-a5be-ac0cb0567192}")] FOLDERID_ConflictFolder,
/// <summary>Network Connections</summary>
[KnownFolderDetail("{6F0CD92B-2E97-45D1-88FF-B0D186B8DEDD}")] FOLDERID_ConnectionsFolder,
/// <summary>Contacts</summary>
[KnownFolderDetail("{56784854-C6CB-462b-8169-88E350ACB882}")] FOLDERID_Contacts,
/// <summary>Control Panel</summary>
[KnownFolderDetail("{82A74AEB-AEB4-465C-A014-D097EE346D63}")] FOLDERID_ControlPanelFolder,
/// <summary>Cookies</summary>
[KnownFolderDetail("{2B0F765D-C0E9-4171-908E-08A611B84FF6}", Equivalent = Environment.SpecialFolder.Cookies)]
FOLDERID_Cookies,
/// <summary>Desktop</summary>
[KnownFolderDetail("{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}", Equivalent = Environment.SpecialFolder.Desktop)]
FOLDERID_Desktop,
/// <summary>DeviceMetadataStore</summary>
[KnownFolderDetail("{5CE4A5E9-E4EB-479D-B89F-130C02886155}")] FOLDERID_DeviceMetadataStore,
/// <summary>Documents</summary>
[KnownFolderDetail("{FDD39AD0-238F-46AF-ADB4-6C85480369C7}", Equivalent = Environment.SpecialFolder.MyDocuments)]
FOLDERID_Documents,
/// <summary>Documents</summary>
[KnownFolderDetail("{7B0DB17D-9CD2-4A93-9733-46CC89022E7C}")] FOLDERID_DocumentsLibrary,
/// <summary>Downloads</summary>
[KnownFolderDetail("{374DE290-123F-4565-9164-39C4925E467B}")] FOLDERID_Downloads,
/// <summary>Favorites</summary>
[KnownFolderDetail("{1777F761-68AD-4D8A-87BD-30B759FA33DD}", Equivalent = Environment.SpecialFolder.Favorites)]
FOLDERID_Favorites,
/// <summary>Fonts</summary>
[KnownFolderDetail("{FD228CB7-AE11-4AE3-864C-16F3910AB8FE}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_FONTS)]
FOLDERID_Fonts,
/// <summary>Games</summary>
[KnownFolderDetail("{CAC52C1A-B53D-4edc-92D7-6B2E8AC19434}")] FOLDERID_Games,
/// <summary>GameExplorer</summary>
[KnownFolderDetail("{054FAE61-4DD8-4787-80B6-090220C4B700}")] FOLDERID_GameTasks,
/// <summary>History</summary>
[KnownFolderDetail("{D9DC8A3B-B784-432E-A781-5A1130A75963}", Equivalent = Environment.SpecialFolder.History)]
FOLDERID_History,
/// <summary>Homegroup</summary>
[KnownFolderDetail("{52528A6B-B9E3-4ADD-B60D-588C2DBA842D}")] FOLDERID_HomeGroup,
/// <summary>The user's username (%USERNAME%)</summary>
[KnownFolderDetail("{9B74B6A3-0DFD-4f11-9E78-5F7800F2E772}")] FOLDERID_HomeGroupCurrentUser,
/// <summary>ImplicitAppShortcuts</summary>
[KnownFolderDetail("{BCB5256F-79F6-4CEE-B725-DC34E402FD46}")] FOLDERID_ImplicitAppShortcuts,
/// <summary>Temporary Internet Files</summary>
[KnownFolderDetail("{352481E8-33BE-4251-BA85-6007CAEDCF9D}", Equivalent = Environment.SpecialFolder.InternetCache)]
FOLDERID_InternetCache,
/// <summary>The Internet</summary>
[KnownFolderDetail("{4D9F7874-4E0C-4904-967B-40B0D20C3E4B}")] FOLDERID_InternetFolder,
/// <summary>Libraries</summary>
[KnownFolderDetail("{1B3EA5DC-B587-4786-B4EF-BD1DC332AEAE}")] FOLDERID_Libraries,
/// <summary>Links</summary>
[KnownFolderDetail("{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}")] FOLDERID_Links,
/// <summary>Local</summary>
[KnownFolderDetail("{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}", Equivalent =
Environment.SpecialFolder.LocalApplicationData)]
FOLDERID_LocalAppData,
/// <summary>LocalLow</summary>
[KnownFolderDetail("{A520A1A4-1780-4FF6-BD18-167343C5AF16}")] FOLDERID_LocalAppDataLow,
/// <summary>None</summary>
[KnownFolderDetail("{2A00375E-224C-49DE-B8D1-440DF7EF3DDC}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_RESOURCES_LOCALIZED)]
FOLDERID_LocalizedResourcesDir,
/// <summary>Music</summary>
[KnownFolderDetail("{4BD8D571-6D19-48D3-BE97-422220080E43}", Equivalent = Environment.SpecialFolder.MyMusic)]
FOLDERID_Music,
/// <summary>Music</summary>
[KnownFolderDetail("{2112AB0A-C86A-4FFE-A368-0DE96E47012E}")] FOLDERID_MusicLibrary,
/// <summary>Network Shortcuts</summary>
[KnownFolderDetail("{C5ABBF53-E17F-4121-8900-86626FC2C973}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_NETHOOD)]
FOLDERID_NetHood,
/// <summary>Network</summary>
[KnownFolderDetail("{D20BEEC4-5CA8-4905-AE3B-BF251EA09B53}")] FOLDERID_NetworkFolder,
/// <summary>Original Images</summary>
[KnownFolderDetail("{2C36C0AA-5812-4b87-BFD0-4CD0DFB19B39}")] FOLDERID_OriginalImages,
/// <summary>Slide Shows</summary>
[KnownFolderDetail("{69D2CF90-FC33-4FB7-9A0C-EBB0F0FCB43C}")] FOLDERID_PhotoAlbums,
/// <summary>Pictures</summary>
[KnownFolderDetail("{A990AE9F-A03B-4E80-94BC-9912D7504104}")] FOLDERID_PicturesLibrary,
/// <summary>Pictures</summary>
[KnownFolderDetail("{33E28130-4E1E-4676-835A-98395C3BC3BB}", Equivalent = Environment.SpecialFolder.MyPictures)]
FOLDERID_Pictures,
/// <summary>Playlists</summary>
[KnownFolderDetail("{DE92C1C7-837F-4F69-A3BB-86E631204A23}")] FOLDERID_Playlists,
/// <summary>Printers</summary>
[KnownFolderDetail("{76FC4E2D-D6AD-4519-A663-37BD56068185}")] FOLDERID_PrintersFolder,
/// <summary>Printer Shortcuts</summary>
[KnownFolderDetail("{9274BD8D-CFD1-41C3-B35E-B13F55A758F4}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_PRINTHOOD)]
FOLDERID_PrintHood,
/// <summary>The user's username (%USERNAME%)</summary>
[KnownFolderDetail("{5E6C858F-0E22-4760-9AFE-EA3317B67173}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_PROFILE)]
FOLDERID_Profile,
/// <summary>ProgramData</summary>
[KnownFolderDetail("{62AB5D82-FDC1-4DC3-A9DD-070D1D495D97}", Equivalent =
Environment.SpecialFolder.CommonApplicationData)]
FOLDERID_ProgramData,
/// <summary>Program Files</summary>
[KnownFolderDetail("{905e63b6-c1bf-494e-b29c-65b732d3d21a}", Equivalent = Environment.SpecialFolder.ProgramFiles)]
FOLDERID_ProgramFiles,
/// <summary>Program Files</summary>
[KnownFolderDetail("{6D809377-6AF0-444b-8957-A3773F02200E}")] FOLDERID_ProgramFilesX64,
/// <summary>Program Files</summary>
[KnownFolderDetail("{7C5A40EF-A0FB-4BFC-874A-C0F2E0B9FA8E}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_PROGRAM_FILESX86)]
FOLDERID_ProgramFilesX86,
/// <summary>Common Files</summary>
[KnownFolderDetail("{F7F1ED05-9F6D-47A2-AAAE-29D317C6F066}", Equivalent =
Environment.SpecialFolder.CommonProgramFiles)]
FOLDERID_ProgramFilesCommon,
/// <summary>Common Files</summary>
[KnownFolderDetail("{6365D5A7-0F0D-45E5-87F6-0DA56B6A4F7D}")] FOLDERID_ProgramFilesCommonX64,
/// <summary>Common Files</summary>
[KnownFolderDetail("{DE974D24-D9C6-4D3E-BF91-F4455120B917}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_PROGRAM_FILES_COMMONX86)]
FOLDERID_ProgramFilesCommonX86,
/// <summary>Programs</summary>
[KnownFolderDetail("{A77F5D77-2E2B-44C3-A6A2-ABA601054A51}", Equivalent = Environment.SpecialFolder.Programs)]
FOLDERID_Programs,
/// <summary>Public</summary>
[KnownFolderDetail("{DFDF76A2-C82A-4D63-906A-5644AC457385}")] FOLDERID_Public,
/// <summary>Public Desktop</summary>
[KnownFolderDetail("{C4AA340D-F20F-4863-AFEF-F87EF2E6BA25}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_DESKTOPDIRECTORY)]
FOLDERID_PublicDesktop,
/// <summary>Public Documents</summary>
[KnownFolderDetail("{ED4824AF-DCE4-45A8-81E2-FC7965083634}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_DOCUMENTS)]
FOLDERID_PublicDocuments,
/// <summary>Public Downloads</summary>
[KnownFolderDetail("{3D644C9B-1FB8-4f30-9B45-F670235F79C0}")] FOLDERID_PublicDownloads,
/// <summary>GameExplorer</summary>
[KnownFolderDetail("{DEBF2536-E1A8-4c59-B6A2-414586476AEA}")] FOLDERID_PublicGameTasks,
/// <summary>Libraries</summary>
[KnownFolderDetail("{48DAF80B-E6CF-4F4E-B800-0E69D84EE384}")] FOLDERID_PublicLibraries,
/// <summary>Public Music</summary>
[KnownFolderDetail("{3214FAB5-9757-4298-BB61-92A9DEAA44FF}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_MUSIC)]
FOLDERID_PublicMusic,
/// <summary>Public Pictures</summary>
[KnownFolderDetail("{B6EBFB86-6907-413C-9AF7-4FC2ABF07CC5}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_PICTURES)]
FOLDERID_PublicPictures,
/// <summary>Ringtones</summary>
[KnownFolderDetail("{E555AB60-153B-4D17-9F04-A5FE99FC15EC}")] FOLDERID_PublicRingtones,
/// <summary>Public Account Pictures</summary>
[KnownFolderDetail("{0482af6c-08f1-4c34-8c90-e17ec98b1e17}")] FOLDERID_PublicUserTiles,
/// <summary>Public Videos</summary>
[KnownFolderDetail("{2400183A-6185-49FB-A2D8-4A392A602BA3}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_COMMON_VIDEO)]
FOLDERID_PublicVideos,
/// <summary>Quick Launch</summary>
[KnownFolderDetail("{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}")] FOLDERID_QuickLaunch,
/// <summary>Recent Items</summary>
[KnownFolderDetail("{AE50C081-EBD2-438A-8655-8A092E34987A}", Equivalent = Environment.SpecialFolder.Recent)]
FOLDERID_Recent,
/// <summary>Recorded TV</summary>
[KnownFolderDetail("{1A6FDBA2-F42D-4358-A798-B74D745926C5}")] FOLDERID_RecordedTVLibrary,
/// <summary>Recycle Bin</summary>
[KnownFolderDetail("{B7534046-3ECB-4C18-BE4E-64CD4CB7D6AC}")] FOLDERID_RecycleBinFolder,
/// <summary>Resources</summary>
[KnownFolderDetail("{8AD10C31-2ADB-4296-A8F7-E4701232C972}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_RESOURCES)]
FOLDERID_ResourceDir,
/// <summary>Ringtones</summary>
[KnownFolderDetail("{C870044B-F49E-4126-A9C3-B52A1FF411E8}")] FOLDERID_Ringtones,
/// <summary>Roaming</summary>
[KnownFolderDetail("{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}", Equivalent =
Environment.SpecialFolder.ApplicationData)]
FOLDERID_RoamingAppData,
/// <summary>RoamedTileImages</summary>
[KnownFolderDetail("{AAA8D5A5-F1D6-4259-BAA8-78E7EF60835E}")] FOLDERID_RoamedTileImages,
/// <summary>RoamingTiles</summary>
[KnownFolderDetail("{00BCFC5A-ED94-4e48-96A1-3F6217F21990}")] FOLDERID_RoamingTiles,
/// <summary>Sample Music</summary>
[KnownFolderDetail("{B250C668-F57D-4EE1-A63C-290EE7D1AA1F}")] FOLDERID_SampleMusic,
/// <summary>Sample Pictures</summary>
[KnownFolderDetail("{C4900540-2379-4C75-844B-64E6FAF8716B}")] FOLDERID_SamplePictures,
/// <summary>Sample Playlists</summary>
[KnownFolderDetail("{15CA69B3-30EE-49C1-ACE1-6B5EC372AFB5}")] FOLDERID_SamplePlaylists,
/// <summary>Sample Videos</summary>
[KnownFolderDetail("{859EAD94-2E85-48AD-A71A-0969CB56A6CD}")] FOLDERID_SampleVideos,
/// <summary>Saved Games</summary>
[KnownFolderDetail("{4C5C32FF-BB9D-43b0-B5B4-2D72E54EAAA4}")] FOLDERID_SavedGames,
/// <summary>Saved Pictures</summary>
[KnownFolderDetail("{3B193882-D3AD-4eab-965A-69829D1FB59F}")] FOLDERID_SavedPictures,
/// <summary>Saved Pictures Library</summary>
[KnownFolderDetail("{E25B5812-BE88-4bd9-94B0-29233477B6C3}")] FOLDERID_SavedPicturesLibrary,
/// <summary>Searches</summary>
[KnownFolderDetail("{7d1d3a04-debb-4115-95cf-2f29da2920da}")] FOLDERID_SavedSearches,
/// <summary>Screenshots</summary>
[KnownFolderDetail("{b7bede81-df94-4682-a7d8-57a52620b86f}")] FOLDERID_Screenshots,
/// <summary>Offline Files</summary>
[KnownFolderDetail("{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}")] FOLDERID_SEARCH_CSC,
/// <summary>History</summary>
[KnownFolderDetail("{0D4C3DB6-03A3-462F-A0E6-08924C41B5D4}")] FOLDERID_SearchHistory,
/// <summary>Search Results</summary>
[KnownFolderDetail("{190337d1-b8ca-4121-a639-6d472d16972a}")] FOLDERID_SearchHome,
/// <summary>Microsoft Office Outlook</summary>
[KnownFolderDetail("{98ec0e18-2098-4d44-8644-66979315a281}")] FOLDERID_SEARCH_MAPI,
/// <summary>Templates</summary>
[KnownFolderDetail("{7E636BFE-DFA9-4D5E-B456-D7B39851D8A9}")] FOLDERID_SearchTemplates,
/// <summary>SendTo</summary>
[KnownFolderDetail("{8983036C-27C0-404B-8F08-102D10DCFD74}", Equivalent = Environment.SpecialFolder.SendTo)]
FOLDERID_SendTo,
/// <summary>Gadgets</summary>
[KnownFolderDetail("{7B396E54-9EC5-4300-BE0A-2482EBAE1A26}")] FOLDERID_SidebarDefaultParts,
/// <summary>Gadgets</summary>
[KnownFolderDetail("{A75D362E-50FC-4fb7-AC2C-A8BEAA314493}")] FOLDERID_SidebarParts,
/// <summary>OneDrive</summary>
[KnownFolderDetail("{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}")] FOLDERID_SkyDrive,
/// <summary>Camera Roll</summary>
[KnownFolderDetail("{767E6811-49CB-4273-87C2-20F355E1085B}")] FOLDERID_SkyDriveCameraRoll,
/// <summary>Documents</summary>
[KnownFolderDetail("{24D89E24-2F19-4534-9DDE-6A6671FBB8FE}")] FOLDERID_SkyDriveDocuments,
/// <summary>Pictures</summary>
[KnownFolderDetail("{339719B5-8C47-4894-94C2-D8F77ADD44A6}")] FOLDERID_SkyDrivePictures,
/// <summary>Start Menu</summary>
[KnownFolderDetail("{625B53C3-AB48-4EC1-BA1F-A1EF4146FC19}", Equivalent = Environment.SpecialFolder.StartMenu)]
FOLDERID_StartMenu,
/// <summary>Startup</summary>
[KnownFolderDetail("{B97D20BB-F46A-4C97-BA10-5E3608430854}", Equivalent = Environment.SpecialFolder.Startup)]
FOLDERID_Startup,
/// <summary>Sync Center</summary>
[KnownFolderDetail("{43668BF8-C14E-49B2-97C9-747784D784B7}")] FOLDERID_SyncManagerFolder,
/// <summary>Sync Results</summary>
[KnownFolderDetail("{289a9a43-be44-4057-a41b-587a76d7e7f9}")] FOLDERID_SyncResultsFolder,
/// <summary>Sync Setup</summary>
[KnownFolderDetail("{0F214138-B1D3-4a90-BBA9-27CBC0C5389A}")] FOLDERID_SyncSetupFolder,
/// <summary>System32</summary>
[KnownFolderDetail("{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}", Equivalent = Environment.SpecialFolder.System)]
FOLDERID_System,
/// <summary>System32</summary>
[KnownFolderDetail("{D65231B0-B2F1-4857-A4CE-A8E7C6EA7D27}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_SYSTEMX86)]
FOLDERID_SystemX86,
/// <summary>Templates</summary>
[KnownFolderDetail("{A63293E8-664E-48DB-A079-DF759E0509F7}", Equivalent = Environment.SpecialFolder.Templates)]
FOLDERID_Templates,
/// <summary>User Pinned</summary>
[KnownFolderDetail("{9E3995AB-1F9C-4F13-B827-48B24B6C7174}")] FOLDERID_UserPinned,
/// <summary>Users</summary>
[KnownFolderDetail("{0762D272-C50A-4BB0-A382-697DCD729B80}")] FOLDERID_UserProfiles,
/// <summary>Programs</summary>
[KnownFolderDetail("{5CD7AEE2-2219-4A67-B85D-6C9CE15660CB}")] FOLDERID_UserProgramFiles,
/// <summary>Programs</summary>
[KnownFolderDetail("{BCBD3057-CA5C-4622-B42D-BC56DB0AE516}")] FOLDERID_UserProgramFilesCommon,
/// <summary>The user's full name (for instance, Jean Philippe Bagel) entered when the user account was created.</summary>
[KnownFolderDetail("{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}")] FOLDERID_UsersFiles,
/// <summary>Libraries</summary>
[KnownFolderDetail("{A302545D-DEFF-464b-ABE8-61C8648D939B}")] FOLDERID_UsersLibraries,
/// <summary>Videos</summary>
[KnownFolderDetail("{18989B1D-99B5-455B-841C-AB7C74E4DDFC}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_MYVIDEO)]
FOLDERID_Videos,
/// <summary>Videos</summary>
[KnownFolderDetail("{491E922F-5643-4AF4-A7EB-4E7A138D8174}")] FOLDERID_VideosLibrary,
/// <summary>Windows</summary>
[KnownFolderDetail("{F38BF404-1D43-42F2-9305-67DE0B28FC23}", Equivalent =
(Environment.SpecialFolder)CSIDL.CSIDL_WINDOWS)]
FOLDERID_Windows,
}
/// <summary>Provides information about a <see cref="KNOWNFOLDERID"/>.</summary>
[AttributeUsage(AttributeTargets.Field)]
internal class KnownFolderDetailAttribute : Attribute
{
public Environment.SpecialFolder Equivalent = (Environment.SpecialFolder) 0XFFFF;
internal Guid guid;
/// <summary>Initializes a new instance of the <see cref="KnownFolderDetailAttribute"/> class with a GUID for the <see cref="KNOWNFOLDERID"/>.</summary>
/// <param name="knownFolderGuid">The GUID for the <see cref="KNOWNFOLDERID"/>.</param>
public KnownFolderDetailAttribute(string knownFolderGuid)
{
guid = new Guid(knownFolderGuid);
}
}
}
}

View File

@ -0,0 +1,872 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using Vanara.InteropServices;
// 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
{
public static partial class Shell32
{
/// <summary>Specifies list placement.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "bb762502")]
public enum FDAP : uint
{
/// <summary>The place is added to the bottom of the default list.</summary>
FDAP_BOTTOM = 0,
/// <summary>The place is added to the top of the default list.</summary>
FDAP_TOP = 1
}
/// <summary>
/// Specifies the values used by the IFileDialogEvents::OnShareViolation method to indicate an application's response to a sharing violation that occurs
/// when a file is opened or saved.
/// </summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "bb762504")]
public enum FDE_SHAREVIOLATION_RESPONSE
{
/// <summary>
/// The application has not handled the event. The dialog displays a UI that indicates that the file is in use and a different file must be chosen.
/// </summary>
FDESVR_DEFAULT,
/// <summary>The application has determined that the file should be returned from the dialog.</summary>
FDESVR_ACCEPT,
/// <summary>The application has determined that the file should not be returned from the dialog.</summary>
FDESVR_REFUSE
}
/// <summary>Defines the set of options available to an Open or Save dialog.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "dn457282")]
[Flags]
public enum FILEOPENDIALOGOPTIONS : uint
{
/// <summary>When saving a file, prompt before overwriting an existing file of the same name. This is a default value for the Save dialog.</summary>
FOS_OVERWRITEPROMPT = 0x00000002,
/// <summary>In the Save dialog, only allow the user to choose a file that has one of the file name extensions specified through IFileDialog::SetFileTypes.</summary>
FOS_STRICTFILETYPES = 0x00000004,
/// <summary>Don't change the current working directory.</summary>
FOS_NOCHANGEDIR = 0x00000008,
/// <summary>Present an Open dialog that offers a choice of folders rather than files.</summary>
FOS_PICKFOLDERS = 0x00000020,
/// <summary>Ensures that returned items are file system items (SFGAO_FILESYSTEM). Note that this does not apply to items returned by IFileDialog::GetCurrentSelection.</summary>
FOS_FORCEFILESYSTEM = 0x00000040,
/// <summary>
/// Enables the user to choose any item in the Shell namespace, not just those with SFGAO_STREAM or SFAGO_FILESYSTEM attributes. This flag cannot be
/// combined with FOS_FORCEFILESYSTEM.
/// </summary>
FOS_ALLNONSTORAGEITEMS = 0x00000080,
/// <summary>
/// Do not check for situations that would prevent an application from opening the selected file, such as sharing violations or access denied errors.
/// </summary>
FOS_NOVALIDATE = 0x00000100,
/// <summary>
/// Enables the user to select multiple items in the open dialog. Note that when this flag is set, the IFileOpenDialog interface must be used to
/// retrieve those items.
/// </summary>
FOS_ALLOWMULTISELECT = 0x00000200,
/// <summary>The item returned must be in an existing folder. This is a default value.</summary>
FOS_PATHMUSTEXIST = 0x00000800,
/// <summary>The item returned must exist. This is a default value for the Open dialog.</summary>
FOS_FILEMUSTEXIST = 0x00001000,
/// <summary>Prompt for creation if the item returned in the save dialog does not exist. Note that this does not actually create the item.</summary>
FOS_CREATEPROMPT = 0x00002000,
/// <summary>
/// In the case of a sharing violation when an application is opening a file, call the application back through OnShareViolation for guidance. This
/// flag is overridden by FOS_NOVALIDATE.
/// </summary>
FOS_SHAREAWARE = 0x00004000,
/// <summary>Do not return read-only items. This is a default value for the Save dialog.</summary>
FOS_NOREADONLYRETURN = 0x00008000,
/// <summary>
/// Do not test whether creation of the item as specified in the Save dialog will be successful. If this flag is not set, the calling application
/// must handle errors, such as denial of access, discovered when the item is created.
/// </summary>
FOS_NOTESTFILECREATE = 0x00010000,
/// <summary>Hide the list of places from which the user has recently opened or saved items. This value is not supported as of Windows 7.</summary>
FOS_HIDEMRUPLACES = 0x00020000,
/// <summary>
/// Hide items shown by default in the view's navigation pane. This flag is often used in conjunction with the IFileDialog::AddPlace method, to hide
/// standard locations and replace them with custom locations.
/// <para>
/// <c>Windows 7</c> and later. Hide all of the standard namespace locations (such as Favorites, Libraries, Computer, and Network) shown in the
/// navigation pane.
/// </para>
/// <para>
/// <c>Windows Vista.</c> Hide the contents of the Favorite Links tree in the navigation pane. Note that the category itself is still displayed, but
/// shown as empty.
/// </para>
/// </summary>
FOS_HIDEPINNEDPLACES = 0x00040000,
/// <summary>
/// Shortcuts should not be treated as their target items. This allows an application to open a .lnk file rather than what that file is a shortcut to.
/// </summary>
FOS_NODEREFERENCELINKS = 0x00100000,
/// <summary>Do not add the item being opened or saved to the recent documents list (SHAddToRecentDocs).</summary>
FOS_DONTADDTORECENT = 0x02000000,
/// <summary>Include hidden and system items.</summary>
FOS_FORCESHOWHIDDEN = 0x10000000,
/// <summary>
/// Indicates to the Save As dialog box that it should open in expanded mode. Expanded mode is the mode that is set and unset by clicking the button
/// in the lower-left corner of the Save As dialog box that switches between Browse Folders and Hide Folders when clicked. This value is not
/// supported as of Windows 7.
/// </summary>
FOS_DEFAULTNOMINIMODE = 0x20000000,
/// <summary>Indicates to the Open dialog box that the preview pane should always be displayed.</summary>
FOS_FORCEPREVIEWPANEON = 0x40000000,
/// <summary>Indicates that the caller is opening a file as a stream (BHID_Stream), so there is no need to download that file.</summary>
FOS_SUPPORTSTREAMABLEITEMS = 0x80000000
}
/// <summary>Used by methods of the ITransferSource and ITransferDestination interfaces to control their file operations.</summary>
public enum TRANSFER_SOURCE_FLAGS
{
/// <summary>Fail if the destination already exists, unless TSF_OVERWRITE_EXIST is specified. This is a default behavior.</summary>
TSF_NORMAL = 0,
/// <summary>Fail if the destination already exists, unless TSF_OVERWRITE_EXIST is specified. This is a default behavior</summary>
TSF_FAIL_EXIST = 0,
/// <summary>Rename with auto-name generation if the destination already exists.</summary>
TSF_RENAME_EXIST = 0x1,
/// <summary>Overwrite or merge with the destination.</summary>
TSF_OVERWRITE_EXIST = 0x2,
/// <summary>Allow creation of a decrypted destination.</summary>
TSF_ALLOW_DECRYPTION = 0x4,
/// <summary>No discretionary access control list (DACL), system access control list (SACL), or owner.</summary>
TSF_NO_SECURITY = 0x8,
/// <summary>Copy the creation time as part of the copy. This can be useful for a move operation that is being used as a copy and delete operation (TSF_MOVE_AS_COPY_DELETE).</summary>
TSF_COPY_CREATION_TIME = 0x10,
/// <summary>Copy the last write time as part of the copy.</summary>
TSF_COPY_WRITE_TIME = 0x20,
/// <summary>Assign write, read, and delete permissions as share mode.</summary>
TSF_USE_FULL_ACCESS = 0x40,
/// <summary>Recycle on file delete, if possible.</summary>
TSF_DELETE_RECYCLE_IF_POSSIBLE = 0x80,
/// <summary>Hard link to the desired source (not required). This avoids a normal copy operation.</summary>
TSF_COPY_HARD_LINK = 0x100,
/// <summary>Copy the localized name.</summary>
TSF_COPY_LOCALIZED_NAME = 0x200,
/// <summary>Move as a copy and delete operation.</summary>
TSF_MOVE_AS_COPY_DELETE = 0x400,
/// <summary>Suspend Shell events.</summary>
TSF_SUSPEND_SHELLEVENTS = 0x800
}
/// <summary>Exposes methods that initialize, show, and get results from the common file dialog.</summary>
/// <seealso cref="IModalWindow"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("42f85136-db7e-439c-85f1-e4075d135fc8")]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb775966")]
public interface IFileDialog : IModalWindow
{
/// <summary>Launches the modal window.</summary>
/// <param name="parent">The handle of the owner window. This value can be NULL.</param>
/// <returns>
/// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code, including the following:
/// HRESULT_FROM_WIN32(ERROR_CANCELLED) = The user closed the window by canceling the operation.
/// </returns>
[PreserveSig]
new HRESULT Show(IntPtr parent);
/// <summary>Sets the file types that the dialog can open or save.</summary>
/// <param name="cFileTypes">The number of elements in the array specified by rgFilterSpec.</param>
/// <param name="rgFilterSpec">A pointer to an array of COMDLG_FILTERSPEC structures, each representing a file type.</param>
void SetFileTypes(uint cFileTypes,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] COMDLG_FILTERSPEC[] rgFilterSpec);
/// <summary>Sets the file type that appears as selected in the dialog.</summary>
/// <param name="iFileType">
/// The index of the file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter. Note that this is a one-based
/// index, not zero-based.
/// </param>
void SetFileTypeIndex(uint iFileType);
/// <summary>Gets the currently selected file type.</summary>
/// <returns>
/// A UINT value that receives the index of the selected file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter.
/// </returns>
uint GetFileTypeIndex();
/// <summary>Assigns an event handler that listens for events coming from the dialog.</summary>
/// <param name="pfde">A pointer to an IFileDialogEvents implementation that will receive events from the dialog.</param>
/// <returns>
/// A DWORD value identifying this event handler. When the client is finished with the dialog, that client must call the IFileDialog::Unadvise method
/// with this value.
/// </returns>
uint Advise(IFileDialogEvents pfde);
/// <summary>Removes an event handler that was attached through the IFileDialog::Advise method.</summary>
/// <param name="dwCookie">
/// The DWORD value that represents the event handler. This value is obtained through the pdwCookie parameter of the IFileDialog::Advise method.
/// </param>
void Unadvise(uint dwCookie);
/// <summary>Sets flags to control the behavior of the dialog.</summary>
/// <param name="fos">One or more of the FILEOPENDIALOGOPTIONS values.</param>
void SetOptions(FILEOPENDIALOGOPTIONS fos);
/// <summary>Gets the current flags that are set to control dialog behavior.</summary>
/// <returns>When this method returns successfully, points to a value made up of one or more of the FILEOPENDIALOGOPTIONS values.</returns>
FILEOPENDIALOGOPTIONS GetOptions();
/// <summary>Sets the folder used as a default if there is not a recently used folder value available.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
void SetDefaultFolder(IShellItem psi);
/// <summary>Sets a folder that is always selected when the dialog is opened, regardless of previous user action.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
void SetFolder(IShellItem psi);
/// <summary>
/// Gets either the folder currently selected in the dialog, or, if the dialog is not currently displayed, the folder that is to be selected when the
/// dialog is opened.
/// </summary>
/// <returns>The address of a pointer to the interface that represents the folder.</returns>
IShellItem GetFolder();
/// <summary>Gets the user's current selection in the dialog.</summary>
/// <returns>
/// The address of a pointer to the interface that represents the item currently selected in the dialog. This item can be a file or folder selected
/// in the view window, or something that the user has entered into the dialog's edit box. The latter case may require a parsing operation
/// (cancelable by the user) that blocks the current thread.
/// </returns>
IShellItem GetCurrentSelection();
/// <summary>Sets the file name that appears in the File name edit box when that dialog box is opened.</summary>
/// <param name="pszName">A pointer to the name of the file.</param>
void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);
/// <summary>Retrieves the text currently entered in the dialog's File name edit box.</summary>
/// <returns>The address of a pointer to a buffer that, when this method returns successfully, receives the text.</returns>
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler), MarshalCookie = "Unicode")]
string GetFileName();
/// <summary>Sets the title of the dialog.</summary>
/// <param name="pszTitle">A pointer to a buffer that contains the title text.</param>
void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
/// <summary>Sets the text of the Open or Save button.</summary>
/// <param name="pszText">A pointer to a buffer that contains the button text.</param>
void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);
/// <summary>Sets the text of the label next to the file name edit box.</summary>
/// <param name="pszLabel">A pointer to a buffer that contains the label text.</param>
void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
/// <summary>Gets the choice that the user made in the dialog.</summary>
/// <returns>The address of a pointer to an IShellItem that represents the user's choice.</returns>
IShellItem GetResult();
/// <summary>Adds a folder to the list of places available for the user to open or save items.</summary>
/// <param name="psi">A pointer to an IShellItem that represents the folder to be made available to the user. This can only be a folder.</param>
/// <param name="fdap">Specifies where the folder is placed within the list.</param>
void AddPlace(IShellItem psi, FDAP fdap);
/// <summary>Sets the default extension to be added to file names.</summary>
/// <param name="pszDefaultExtension">
/// A pointer to a buffer that contains the extension text. This string should not include a leading period. For example, "jpg" is correct, while
/// ".jpg" is not.
/// </param>
void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
/// <summary>Closes the dialog.</summary>
/// <param name="hr">The code that will be returned by Show to indicate that the dialog was closed before a selection was made.</param>
void Close([MarshalAs(UnmanagedType.Error)] HRESULT hr);
/// <summary>Enables a calling application to associate a GUID with a dialog's persisted state.</summary>
/// <param name="guid">The GUID to associate with this dialog state.</param>
void SetClientGuid([In, MarshalAs(UnmanagedType.LPStruct)] Guid guid);
/// <summary>Instructs the dialog to clear all persisted state information.</summary>
void ClearClientData();
/// <summary>Sets the filter. <note>Deprecated. SetFilter is no longer available for use as of Windows 7.</note></summary>
/// <param name="pFilter">A pointer to the IShellItemFilter that is to be set.</param>
void SetFilter([MarshalAs(UnmanagedType.Interface)] object pFilter);
}
/// <summary>Exposes methods that allow notification of events within a common file dialog.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("973510DB-7D7F-452B-8975-74A85828D354")]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb775876")]
public interface IFileDialogEvents
{
/// <summary>Called just before the dialog is about to return with a result.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <returns>
/// Implementations should return S_OK to accept the current result in the dialog or S_FALSE to refuse it. In the case of S_FALSE, the dialog should
/// remain open.
/// </returns>
/// <remarks>
/// When this method is called, the IFileDialog::GetResult and GetResults methods can be called.
/// <para>
/// The application can use this callback method to perform additional validation before the dialog closes, or to prevent the dialog from closing. If
/// the application prevents the dialog from closing, it should display a UI to indicate a cause. To obtain a parent HWND for the UI, obtain the
/// IOleWindow interface through IFileDialog::QueryInterface and call IOleWindow::GetWindow.
/// </para>
/// <para>An application can also use this method to perform all of its work surrounding the opening or saving of files.</para>
/// </remarks>
[PreserveSig]
HRESULT OnFileOk(IFileDialog pfd);
/// <summary>Called before IFileDialogEvents::OnFolderChange. This allows the implementer to stop navigation to a particular location.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <param name="psiFolder">A pointer to an interface that represents the folder to which the dialog is about to navigate.</param>
/// <returns>
/// Returns S_OK if successful, or an error value otherwise. A return value of S_OK or E_NOTIMPL indicates that the folder change can proceed.
/// </returns>
/// <remarks>
/// The calling application can call IFileDialog::SetFolder during this callback to redirect navigation to an alternate folder. The actual navigation
/// does not occur until IFileDialogEvents::OnFolderChanging has returned.
/// <para>
/// If the calling application simply prevents navigation to a particular folder, UI should be displayed with an explanation of the restriction. To
/// obtain a parent HWND for the UI, obtain the IOleWindow interface through IFileDialog and call IOleWindow::GetWindow.
/// </para>
/// </remarks>
[PreserveSig]
HRESULT OnFolderChanging(IFileDialog pfd, IShellItem psiFolder);
/// <summary>Called when the user navigates to a new folder.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[PreserveSig]
HRESULT OnFolderChange(IFileDialog pfd);
/// <summary>Called when the user changes the selection in the dialog's view.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[PreserveSig]
HRESULT OnSelectionChange(IFileDialog pfd);
/// <summary>Enables an application to respond to sharing violations that arise from Open or Save operations.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <param name="psi">A pointer to the interface that represents the item that has the sharing violation.</param>
/// <param name="pResponse">A pointer to a value from the FDE_SHAREVIOLATION_RESPONSE enumeration indicating the response to the sharing violation.</param>
/// <returns>The implementer should return E_NOTIMPL if this method is not implemented; S_OK or an appropriate error code otherwise.</returns>
/// <remarks>
/// The FOS_SHAREAWARE flag must be set through IFileDialog::SetOptions before this method is called.
/// <para>
/// A sharing violation could possibly arise when the application attempts to open a file, because the file could have been locked between the time
/// that the dialog tested it and the application opened it.
/// </para>
/// </remarks>
[PreserveSig]
HRESULT OnShareViolation(IFileDialog pfd, IShellItem psi, out FDE_SHAREVIOLATION_RESPONSE pResponse);
/// <summary>Called when the dialog is opened to notify the application of the initial chosen filetype.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
/// <remarks>
/// This method is called when the dialog is opened to notify the application of the initially chosen filetype. If the application has code in
/// IFileDialogEvents that responds to type changes, it can respond to the type. For example, it could hide certain controls. The application
/// controls the initial file type and could do its own checks, so this method is provided as a convenience.
/// </remarks>
[PreserveSig]
HRESULT OnTypeChange(IFileDialog pfd);
/// <summary>Called from the save dialog when the user chooses to overwrite a file.</summary>
/// <param name="pfd">A pointer to the interface that represents the dialog.</param>
/// <param name="psi">A pointer to the interface that represents the item that will be overwritten.</param>
/// <param name="pResponse">
/// A pointer to a value from the FDE_OVERWRITE_RESPONSE enumeration indicating the response to the potential overwrite action.
/// </param>
/// <returns>The implementer should return E_NOTIMPL if this method is not implemented; S_OK or an appropriate error code otherwise.</returns>
/// <remarks>The FOS_OVERWRITEPROMPT flag must be set through IFileDialog::SetOptions before this method is called.</remarks>
[PreserveSig]
HRESULT OnOverwrite(IFileDialog pfd, IShellItem psi, out FDE_SHAREVIOLATION_RESPONSE pResponse);
}
/// <summary>Extends the IFileDialog interface by adding methods specific to the open dialog.</summary>
/// <seealso cref="IFileDialog"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("d57c7288-d4ad-4768-be02-9d969532d960"), CoClass(typeof(CFileOpenDialog))]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb775834")]
public interface IFileOpenDialog : IFileDialog
{
/// <summary>Launches the modal window.</summary>
/// <param name="parent">The handle of the owner window. This value can be NULL.</param>
/// <returns>
/// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code, including the following:
/// HRESULT_FROM_WIN32(ERROR_CANCELLED) = The user closed the window by canceling the operation.
/// </returns>
[PreserveSig]
new HRESULT Show(IntPtr parent);
/// <summary>Sets the file types that the dialog can open or save.</summary>
/// <param name="cFileTypes">The number of elements in the array specified by rgFilterSpec.</param>
/// <param name="rgFilterSpec">A pointer to an array of COMDLG_FILTERSPEC structures, each representing a file type.</param>
new void SetFileTypes(uint cFileTypes,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] COMDLG_FILTERSPEC[] rgFilterSpec);
/// <summary>Sets the file type that appears as selected in the dialog.</summary>
/// <param name="iFileType">
/// The index of the file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter. Note that this is a one-based
/// index, not zero-based.
/// </param>
new void SetFileTypeIndex(uint iFileType);
/// <summary>Gets the currently selected file type.</summary>
/// <returns>
/// A UINT value that receives the index of the selected file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter.
/// </returns>
new uint GetFileTypeIndex();
/// <summary>Assigns an event handler that listens for events coming from the dialog.</summary>
/// <param name="pfde">A pointer to an IFileDialogEvents implementation that will receive events from the dialog.</param>
/// <returns>
/// A DWORD value identiying this event handler. When the client is finished with the dialog, that client must call the IFileDialog::Unadvise method
/// with this value.
/// </returns>
new uint Advise(IFileDialogEvents pfde);
/// <summary>Removes an event handler that was attached through the IFileDialog::Advise method.</summary>
/// <param name="dwCookie">
/// The DWORD value that represents the event handler. This value is obtained through the pdwCookie parameter of the IFileDialog::Advise method.
/// </param>
new void Unadvise(uint dwCookie);
/// <summary>Sets flags to control the behavior of the dialog.</summary>
/// <param name="fos">One or more of the FILEOPENDIALOGOPTIONS values.</param>
new void SetOptions(FILEOPENDIALOGOPTIONS fos);
/// <summary>Gets the current flags that are set to control dialog behavior.</summary>
/// <returns>When this method returns successfully, points to a value made up of one or more of the FILEOPENDIALOGOPTIONS values.</returns>
new FILEOPENDIALOGOPTIONS GetOptions();
/// <summary>Sets the folder used as a default if there is not a recently used folder value available.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
new void SetDefaultFolder(IShellItem psi);
/// <summary>Sets a folder that is always selected when the dialog is opened, regardless of previous user action.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
new void SetFolder(IShellItem psi);
/// <summary>
/// Gets either the folder currently selected in the dialog, or, if the dialog is not currently displayed, the folder that is to be selected when the
/// dialog is opened.
/// </summary>
/// <returns>The address of a pointer to the interface that represents the folder.</returns>
new IShellItem GetFolder();
/// <summary>Gets the user's current selection in the dialog.</summary>
/// <returns>
/// The address of a pointer to the interface that represents the item currently selected in the dialog. This item can be a file or folder selected
/// in the view window, or something that the user has entered into the dialog's edit box. The latter case may require a parsing operation
/// (cancelable by the user) that blocks the current thread.
/// </returns>
new IShellItem GetCurrentSelection();
/// <summary>Sets the file name that appears in the File name edit box when that dialog box is opened.</summary>
/// <param name="pszName">A pointer to the name of the file.</param>
new void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);
/// <summary>Retrieves the text currently entered in the dialog's File name edit box.</summary>
/// <returns>The address of a pointer to a buffer that, when this method returns successfully, receives the text.</returns>
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler), MarshalCookie = "Unicode")]
new string GetFileName();
/// <summary>Sets the title of the dialog.</summary>
/// <param name="pszTitle">A pointer to a buffer that contains the title text.</param>
new void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
/// <summary>Sets the text of the Open or Save button.</summary>
/// <param name="pszText">A pointer to a buffer that contains the button text.</param>
new void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);
/// <summary>Sets the text of the label next to the file name edit box.</summary>
/// <param name="pszLabel">A pointer to a buffer that contains the label text.</param>
new void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
/// <summary>Gets the choice that the user made in the dialog.</summary>
/// <returns>The address of a pointer to an IShellItem that represents the user's choice.</returns>
new IShellItem GetResult();
/// <summary>Adds a folder to the list of places available for the user to open or save items.</summary>
/// <param name="psi">A pointer to an IShellItem that represents the folder to be made available to the user. This can only be a folder.</param>
/// <param name="fdap">Specifies where the folder is placed within the list.</param>
new void AddPlace(IShellItem psi, FDAP fdap);
/// <summary>Sets the default extension to be added to file names.</summary>
/// <param name="pszDefaultExtension">
/// A pointer to a buffer that contains the extension text. This string should not include a leading period. For example, "jpg" is correct, while
/// ".jpg" is not.
/// </param>
new void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
/// <summary>Closes the dialog.</summary>
/// <param name="hr">The code that will be returned by Show to indicate that the dialog was closed before a selection was made.</param>
new void Close([MarshalAs(UnmanagedType.Error)] HRESULT hr);
/// <summary>Enables a calling application to associate a GUID with a dialog's persisted state.</summary>
/// <param name="guid">The GUID to associate with this dialog state.</param>
new void SetClientGuid([In, MarshalAs(UnmanagedType.LPStruct)] Guid guid);
/// <summary>Instructs the dialog to clear all persisted state information.</summary>
new void ClearClientData();
/// <summary>Sets the filter. <note>Deprecated. SetFilter is no longer available for use as of Windows 7.</note></summary>
/// <param name="pFilter">A pointer to the IShellItemFilter that is to be set.</param>
new void SetFilter([MarshalAs(UnmanagedType.Interface)] object pFilter);
/// <summary>Gets the user's choices in a dialog that allows multiple selection.</summary>
/// <returns>The address of a pointer to an IShellItemArray through which the items selected in the dialog can be accessed.</returns>
IShellItemArray GetResults();
/// <summary>
/// Gets the currently selected items in the dialog. These items may be items selected in the view, or text selected in the file name edit box.
/// </summary>
/// <returns>The address of a pointer to an IShellItemArray through which the selected items can be accessed.</returns>
IShellItemArray GetSelectedItems();
}
/// <summary>
/// Exposes methods that provide a rich notification system used by callers of IFileOperation to monitor the details of the operations they are
/// performing through that interface.
/// </summary>
[ComImport, Guid("04b0f1a7-9490-44bc-96e1-4296a31252e2"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb775722")]
public interface IFileOperationProgressSink
{
/// <summary>Performs caller-implemented actions before any specific file operations are performed.</summary>
void StartOperations();
/// <summary>Performs caller-implemented actions after the last operation performed by the call to IFileOperation is complete.</summary>
/// <param name="hrResult">The return value of the final operation. Note that this is not the HRESULT returned by one of the IFileOperation methods, which simply queue the operations. Instead, this is the result of the actual operation, such as copy, delete, or move.</param>
void FinishOperations(HRESULT hrResult);
/// <summary>Performs caller-implemented actions before the rename process for each item begins.</summary>
/// <param name="dwFlags">bitwise value that contains flags that control the operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the item to be renamed.</param>
/// <param name="pszNewName">Pointer to the new display name of the item. This is a null-terminated, Unicode string.</param>
void PreRenameItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName);
/// <summary>Performs caller-implemented actions after the rename process for each item is complete.</summary>
/// <param name="dwFlags">bitwise value that contains flags that were used during the rename operation. Some values can be set or changed during the rename operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the item before it was renamed.</param>
/// <param name="pszNewName">Pointer to the new display name of the item. This is a null-terminated, Unicode string. Note that this might not be the name that you asked for, given collisions and other naming rules.</param>
/// <param name="hrRename">The return value of the rename operation. Note that this is not the HRESULT returned by RenameItem, which simply queues the rename operation. Instead, this is the result of the actual rename operation.</param>
/// <param name="psiNewlyCreated">Pointer to an IShellItem that represents the item with its new name.</param>
void PostRenameItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName, HRESULT hrRename, IShellItem psiNewlyCreated);
/// <summary>Performs caller-implemented actions before the move process for each item begins.</summary>
/// <param name="dwFlags">bitwise value that contains flags that control the operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the item to be moved.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder to contain the moved item.</param>
/// <param name="pszNewName">Pointer to a new name for the item in its new location. This is a null-terminated Unicode string and can be NULL. If NULL, the name of the destination item is the same as the source.</param>
void PreMoveItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName);
/// <summary>Performs caller-implemented actions after the move process for each item is complete.</summary>
/// <param name="dwFlags">bitwise value that contains flags that were used during the move operation. Some values can be set or changed during the move operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the source item.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder that contains the moved item.</param>
/// <param name="pszNewName">Pointer to the name that was given to the item after it was moved. This is a null-terminated Unicode string. Note that this might not be the name that you asked for, given collisions and other naming rules.</param>
/// <param name="hrMove">The return value of the move operation. Note that this is not the HRESULT returned by MoveItem, which simply queues the move operation. Instead, this is the result of the actual move.</param>
/// <param name="psiNewlyCreated">Pointer to an IShellItem that represents the moved item in its new location.</param>
void PostMoveItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName, HRESULT hrMove, IShellItem psiNewlyCreated);
/// <summary>Performs caller-implemented actions before the copy process for each item begins.</summary>
/// <param name="dwFlags">bitwise value that contains flags that control the operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the source item.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder to contain the copy of the item.</param>
/// <param name="pszNewName">Pointer to a new name for the item after it has been copied. This is a null-terminated Unicode string and can be NULL. If NULL, the name of the destination item is the same as the source.</param>
void PreCopyItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName);
/// <summary>Performs caller-implemented actions after the copy process for each item is complete.</summary>
/// <param name="dwFlags">bitwise value that contains flags that were used during the copy operation. Some values can be set or changed during the copy operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the source item.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder to which the item was copied.</param>
/// <param name="pszNewName">Pointer to the new name that was given to the item after it was copied. This is a null-terminated Unicode string. Note that this might not be the name that you asked for, given collisions and other naming rules.</param>
/// <param name="hrCopy">The return value of the copy operation. Note that this is not the HRESULT returned by CopyItem, which simply queues the copy operation. Instead, this is the result of the actual copy.</param>
/// <param name="psiNewlyCreated">Pointer to an IShellItem that represents the new copy of the item.</param>
void PostCopyItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName,
HRESULT hrCopy, IShellItem psiNewlyCreated);
/// <summary>Performs caller-implemented actions before the delete process for each item begins.</summary>
/// <param name="dwFlags">bitwise value that contains flags that control the operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the item to be deleted.</param>
void PreDeleteItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem);
/// <summary>Performs caller-implemented actions after the delete process for each item is complete.</summary>
/// <param name="dwFlags">bitwise value that contains flags that were used during the delete operation. Some values can be set or changed during the delete operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiItem">Pointer to an IShellItem that specifies the item that was deleted.</param>
/// <param name="hrDelete">The return value of the delete operation. Note that this is not the HRESULT returned by DeleteItem, which simply queues the delete operation. Instead, this is the result of the actual deletion.</param>
/// <param name="psiNewlyCreated">A pointer to an IShellItem that specifies the deleted item, now in the Recycle Bin. If the item was fully deleted, this value is NULL.</param>
void PostDeleteItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiItem, HRESULT hrDelete, IShellItem psiNewlyCreated);
/// <summary>Performs caller-implemented actions before the process to create a new item begins.</summary>
/// <param name="dwFlags">bitwise value that contains flags that control the operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder that will contain the new item.</param>
/// <param name="pszNewName">Pointer to the file name of the new item, for instance Newfile.txt. This is a null-terminated, Unicode string.</param>
void PreNewItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName);
/// <summary>Performs caller-implemented actions after the new item is created.</summary>
/// <param name="dwFlags">bitwise value that contains flags that were used during the creation operation. Some values can be set or changed during the creation operation. See TRANSFER_SOURCE_FLAGS for flag descriptions.</param>
/// <param name="psiDestinationFolder">Pointer to an IShellItem that specifies the destination folder to which the new item was added.</param>
/// <param name="pszNewName">Pointer to the file name of the new item, for instance Newfile.txt. This is a null-terminated, Unicode string.</param>
/// <param name="pszTemplateName">Pointer to the name of the template file (for example Excel9.xls) that the new item is based on, stored in one of the following locations:
/// <list type="bullet">
/// <item><description> CSIDL_COMMON_TEMPLATES. The default path for this folder is %ALLUSERSPROFILE%\Templates.</description></item>
/// <item><description>CSIDL_TEMPLATES. The default path for this folder is %USERPROFILE%\Templates.</description></item>
/// <item><description>%SystemRoot%\shellnew</description></item>
/// </list>
/// <para>This is a null-terminated, Unicode string used to specify an existing file of the same type as the new file, containing the minimal content that an application wants to include in any new file.</para>
/// <para>This parameter is normally NULL to specify a new, blank file.</para>
/// </param>
/// <param name="dwFileAttributes">The file attributes applied to the new item. One or more of the values found at GetFileAttributes.</param>
/// <param name="hrNew">The return value of the creation operation. Note that this is not the HRESULT returned by NewItem, which simply queues the creation operation. Instead, this is the result of the actual creation.</param>
/// <param name="psiNewItem">Pointer to an IShellItem that represents the new item.</param>
void PostNewItem(TRANSFER_SOURCE_FLAGS dwFlags, IShellItem psiDestinationFolder, [MarshalAs(UnmanagedType.LPWStr)] string pszNewName,
[MarshalAs(UnmanagedType.LPWStr)] string pszTemplateName, uint dwFileAttributes, HRESULT hrNew, IShellItem psiNewItem);
/// <summary>Updates the progress.</summary>
/// <param name="iWorkTotal">The i work total.</param>
/// <param name="iWorkSoFar">The i work so far.</param>
void UpdateProgress(uint iWorkTotal, uint iWorkSoFar);
/// <summary>Resets the timer.</summary>
[Obsolete("This method is not supported.")]
void ResetTimer();
/// <summary>Pauses the timer.</summary>
[Obsolete("This method is not supported.")]
void PauseTimer();
/// <summary>Resumes the timer.</summary>
[Obsolete("This method is not supported.")]
void ResumeTimer();
}
/// <summary>
/// Extends the IFileDialog interface by adding methods specific to the save dialog, which include those that provide support for the collection of
/// metadata to be persisted with the file.
/// </summary>
/// <seealso cref="IFileDialog"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("84bccd23-5fde-4cdb-aea4-af64b83d78ab"), CoClass(typeof(CFileSaveDialog))]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb775688")]
public interface IFileSaveDialog : IFileDialog
{
/// <summary>Launches the modal window.</summary>
/// <param name="parent">The handle of the owner window. This value can be NULL.</param>
/// <returns>
/// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code, including the following:
/// HRESULT_FROM_WIN32(ERROR_CANCELLED) = The user closed the window by canceling the operation.
/// </returns>
[PreserveSig]
new HRESULT Show(IntPtr parent);
/// <summary>Sets the file types that the dialog can open or save.</summary>
/// <param name="cFileTypes">The number of elements in the array specified by rgFilterSpec.</param>
/// <param name="rgFilterSpec">A pointer to an array of COMDLG_FILTERSPEC structures, each representing a file type.</param>
new void SetFileTypes(uint cFileTypes,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] COMDLG_FILTERSPEC[] rgFilterSpec);
/// <summary>Sets the file type that appears as selected in the dialog.</summary>
/// <param name="iFileType">
/// The index of the file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter. Note that this is a one-based
/// index, not zero-based.
/// </param>
new void SetFileTypeIndex(uint iFileType);
/// <summary>Gets the currently selected file type.</summary>
/// <returns>
/// A UINT value that receives the index of the selected file type in the file type array passed to IFileDialog::SetFileTypes in its cFileTypes parameter.
/// </returns>
new uint GetFileTypeIndex();
/// <summary>Assigns an event handler that listens for events coming from the dialog.</summary>
/// <param name="pfde">A pointer to an IFileDialogEvents implementation that will receive events from the dialog.</param>
/// <returns>
/// A DWORD value identiying this event handler. When the client is finished with the dialog, that client must call the IFileDialog::Unadvise method
/// with this value.
/// </returns>
new uint Advise(IFileDialogEvents pfde);
/// <summary>Removes an event handler that was attached through the IFileDialog::Advise method.</summary>
/// <param name="dwCookie">
/// The DWORD value that represents the event handler. This value is obtained through the pdwCookie parameter of the IFileDialog::Advise method.
/// </param>
new void Unadvise(uint dwCookie);
/// <summary>Sets flags to control the behavior of the dialog.</summary>
/// <param name="fos">One or more of the FILEOPENDIALOGOPTIONS values.</param>
new void SetOptions(FILEOPENDIALOGOPTIONS fos);
/// <summary>Gets the current flags that are set to control dialog behavior.</summary>
/// <returns>When this method returns successfully, points to a value made up of one or more of the FILEOPENDIALOGOPTIONS values.</returns>
new FILEOPENDIALOGOPTIONS GetOptions();
/// <summary>Sets the folder used as a default if there is not a recently used folder value available.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
new void SetDefaultFolder(IShellItem psi);
/// <summary>Sets a folder that is always selected when the dialog is opened, regardless of previous user action.</summary>
/// <param name="psi">A pointer to the interface that represents the folder.</param>
new void SetFolder(IShellItem psi);
/// <summary>
/// Gets either the folder currently selected in the dialog, or, if the dialog is not currently displayed, the folder that is to be selected when the
/// dialog is opened.
/// </summary>
/// <returns>The address of a pointer to the interface that represents the folder.</returns>
new IShellItem GetFolder();
/// <summary>Gets the user's current selection in the dialog.</summary>
/// <returns>
/// The address of a pointer to the interface that represents the item currently selected in the dialog. This item can be a file or folder selected
/// in the view window, or something that the user has entered into the dialog's edit box. The latter case may require a parsing operation
/// (cancelable by the user) that blocks the current thread.
/// </returns>
new IShellItem GetCurrentSelection();
/// <summary>Sets the file name that appears in the File name edit box when that dialog box is opened.</summary>
/// <param name="pszName">A pointer to the name of the file.</param>
new void SetFileName([MarshalAs(UnmanagedType.LPWStr)] string pszName);
/// <summary>Retrieves the text currently entered in the dialog's File name edit box.</summary>
/// <returns>The address of a pointer to a buffer that, when this method returns successfully, receives the text.</returns>
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler), MarshalCookie = "Unicode")]
new string GetFileName();
/// <summary>Sets the title of the dialog.</summary>
/// <param name="pszTitle">A pointer to a buffer that contains the title text.</param>
new void SetTitle([MarshalAs(UnmanagedType.LPWStr)] string pszTitle);
/// <summary>Sets the text of the Open or Save button.</summary>
/// <param name="pszText">A pointer to a buffer that contains the button text.</param>
new void SetOkButtonLabel([MarshalAs(UnmanagedType.LPWStr)] string pszText);
/// <summary>Sets the text of the label next to the file name edit box.</summary>
/// <param name="pszLabel">A pointer to a buffer that contains the label text.</param>
new void SetFileNameLabel([MarshalAs(UnmanagedType.LPWStr)] string pszLabel);
/// <summary>Gets the choice that the user made in the dialog.</summary>
/// <returns>The address of a pointer to an IShellItem that represents the user's choice.</returns>
new IShellItem GetResult();
/// <summary>Adds a folder to the list of places available for the user to open or save items.</summary>
/// <param name="psi">A pointer to an IShellItem that represents the folder to be made available to the user. This can only be a folder.</param>
/// <param name="fdap">Specifies where the folder is placed within the list.</param>
new void AddPlace(IShellItem psi, FDAP fdap);
/// <summary>Sets the default extension to be added to file names.</summary>
/// <param name="pszDefaultExtension">
/// A pointer to a buffer that contains the extension text. This string should not include a leading period. For example, "jpg" is correct, while
/// ".jpg" is not.
/// </param>
new void SetDefaultExtension([MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension);
/// <summary>Closes the dialog.</summary>
/// <param name="hr">The code that will be returned by Show to indicate that the dialog was closed before a selection was made.</param>
new void Close([MarshalAs(UnmanagedType.Error)] HRESULT hr);
/// <summary>Enables a calling application to associate a GUID with a dialog's persisted state.</summary>
/// <param name="guid">The GUID to associate with this dialog state.</param>
new void SetClientGuid([In, MarshalAs(UnmanagedType.LPStruct)] Guid guid);
/// <summary>Instructs the dialog to clear all persisted state information.</summary>
new void ClearClientData();
/// <summary>Sets the filter. <note>Deprecated. SetFilter is no longer available for use as of Windows 7.</note></summary>
/// <param name="pFilter">A pointer to the IShellItemFilter that is to be set.</param>
new void SetFilter([MarshalAs(UnmanagedType.Interface)] object pFilter);
/// <summary>Sets an item to be used as the initial entry in a Save As dialog.</summary>
/// <param name="psi">Pointer to an IShellItem that represents the item.</param>
void SetSaveAsItem(IShellItem psi);
/// <summary>Provides a property store that defines the default values to be used for the item being saved.</summary>
/// <param name="pStore">Pointer to the interface that represents the property store that contains the associated metadata.</param>
void SetProperties([In] PropSys.IPropertyStore pStore);
/// <summary>Specifies which properties will be collected in the save dialog.</summary>
/// <param name="pList">Pointer to the interface that represents the list of properties to collect. This parameter can be NULL.</param>
/// <param name="fAppendDefault">
/// TRUE to show default properties for the currently selected filetype in addition to the properties specified by pList. FALSE to show only
/// properties specified by pList.
/// </param>
void SetCollectedProperties(PropSys.IPropertyDescriptionList pList, [In, MarshalAs(UnmanagedType.Bool)] bool fAppendDefault);
/// <summary>Retrieves the set of property values for a saved item or an item in the process of being saved.</summary>
/// <returns>Address of a pointer to an IPropertyStore that receives the property values.</returns>
PropSys.IPropertyStore GetProperties();
/// <summary>Applies a set of properties to an item using the Shell's copy engine.</summary>
/// <param name="psi">Pointer to the IShellItem that represents the file being saved. This is usually the item retrieved by GetResult.</param>
/// <param name="pStore">
/// Pointer to the IPropertyStore that represents the property values to be applied to the file. This can be the property store returned by IFileSaveDialog::GetProperties.
/// </param>
/// <param name="hwnd">The handle of the application window.</param>
/// <param name="pSink">
/// Pointer to an optional IFileOperationProgressSink that the calling application can use if they want to be notified of the progress of the
/// property stamping. This value may be NULL.
/// </param>
void ApplyProperties(IShellItem psi, PropSys.IPropertyStore pStore, [In] IntPtr hwnd, IFileOperationProgressSink pSink);
}
/// <summary>Exposes a method that represents a modal window. This interface is used in the Windows XP Passport Wizard.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("b4db1657-70d7-485e-8e3e-6fcb5a5c1802")]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb761686")]
public interface IModalWindow
{
/// <summary>Launches the modal window.</summary>
/// <param name="parent">The handle of the owner window. This value can be NULL.</param>
/// <returns>
/// If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code, including the following:
/// HRESULT_FROM_WIN32(ERROR_CANCELLED) = The user closed the window by cancelling the operation.
/// </returns>
[PreserveSig]
HRESULT Show(IntPtr parent);
}
/// <summary>Used generically to filter elements.</summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
[PInvokeData("Shtypes.h", MSDNShortId = "bb773221")]
public struct COMDLG_FILTERSPEC
{
/// <summary>A pointer to a buffer that contains the friendly name of the filter.</summary>
public string pszName;
/// <summary>A pointer to a buffer that contains the filter pattern.</summary>
public string pszSpec;
}
/// <summary>Class interface for ITaskbarList and derivatives.</summary>
[ComImport, Guid("DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7"), ClassInterface(ClassInterfaceType.None)]
public class CFileOpenDialog { }
/// <summary>Class interface for ITaskbarList and derivatives.</summary>
[ComImport, Guid("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B"), ClassInterface(ClassInterfaceType.None)]
public class CFileSaveDialog { }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,190 @@
using System;
using System.Runtime.InteropServices;
using Vanara.InteropServices;
// ReSharper disable UnusedMember.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberHidesStaticFromOuterClass
// ReSharper disable UnusedMethodReturnValue.Global
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Specifies the default save location.</summary>
public enum DEFAULTSAVEFOLDERTYPE
{
/// <summary>The current user determines the save folder. If the current user is the library's owner, use the private save location (DSFT_PRIVATE). If the current user is not the library's owner, use the public save location (DSFT_PUBLIC).</summary>
DSFT_DETECT = 1,
/// <summary>The library's private save location, which can only be accessed by the library's owner.</summary>
DSFT_PRIVATE,
/// <summary>The library's public save location, which can be accessed by all users.</summary>
DSFT_PUBLIC
}
/// <summary>Defines options for filtering folder items.</summary>
public enum LIBRARYFOLDERFILTER
{
/// <summary>Return only file system items.</summary>
LFF_FORCEFILESYSTEM = 1,
/// <summary>Return items that can be bound to an IStorage object.</summary>
LFF_STORAGEITEMS = 2,
/// <summary>Return all items.</summary>
LFF_ALLITEMS = 3
}
/// <summary>Used by SHShowManageLibraryUI to define options for handling a name collision when saving a library.</summary>
public enum LIBRARYMANAGEDIALOGOPTIONS
{
/// <summary>Show default warning UI to the user.</summary>
LMD_DEFAULT = 0x00000000,
/// <summary>Do not display a warning dialog to the user in collisions that concern network locations that cannot be indexed.</summary>
LMD_ALLOWUNINDEXABLENETWORKLOCATIONS = 0x00000001
}
/// <summary>Specifies the library options.</summary>
[Flags]
public enum LIBRARYOPTIONFLAGS
{
/// <summary>No library options are set.</summary>
LOF_DEFAULT = 0x00000000,
/// <summary>Pin the library to the navigation pane.</summary>
LOF_PINNEDTONAVPANE = 0x00000001,
/// <summary>All valid library options flags.</summary>
LOF_MASK_ALL = 0x00000001
}
/// <summary>Specifies the options for handling a name collision when saving a library.</summary>
[Flags]
public enum LIBRARYSAVEFLAGS
{
/// <summary>If a library with the same name already exists, the save operation fails.</summary>
LSF_FAILIFTHERE = 0x00000000,
/// <summary>If a library with the same name already exists, the save operation overwrites the existing library.</summary>
LSF_OVERRIDEEXISTING = 0x00000001,
/// <summary>If a library with the same name already exists, the save operation generates a new, unique name for the library.</summary>
LSF_MAKEUNIQUENAME = 0x00000002,
}
/// <summary>Exposes methods for creating and managing libraries.</summary>
[ComImport, Guid("11a66efa-382e-451a-9234-1e0e12ef3085"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(CShellLibrary))]
public interface IShellLibrary
{
/// <summary>Loads the library from a specified library definition file.</summary>
/// <param name="library">An IShellItem object for the library definition file to load. An error is returned if this object is not a library.</param>
/// <param name="grfMode">One or more STGM storage medium flags that specify access and sharing modes for the library object.</param>
void LoadLibraryFromItem([In, MarshalAs(UnmanagedType.Interface)] IShellItem library, [In] STGM grfMode);
/// <summary>Loads the library that is referenced by a KNOWNFOLDERID.</summary>
/// <param name="knownfidLibrary">The KNOWNFOLDERID value that identifies the library to load.</param>
/// <param name="grfMode">One or more STGM storage medium flags that specify access and sharing modes for the library object.</param>
void LoadLibraryFromKnownFolder([In, MarshalAs(UnmanagedType.LPStruct)] Guid knownfidLibrary, [In] STGM grfMode);
/// <summary>Adds a folder to the library.</summary>
/// <param name="location">An IShellItem object that represents the folder to be added to the library.</param>
void AddFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem location);
/// <summary>Removes a folder from the library.</summary>
/// <param name="location">An IShellItem object that represents the folder to remove.</param>
void RemoveFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem location);
/// <summary>Gets the set of child folders that are contained in the library.</summary>
/// <param name="lff">One of the following LIBRARYFOLDERFILTER values that determines the folders to get.</param>
/// <param name="riid">A reference to the IID of the interface to get in ppv. This value is typically IID_IShellItemArray, but it can also be IID_IObjectCollection, IID_IObjectArray, or the IID of any other interface that is implemented by CShellItemArray.</param>
/// <returns>A pointer to the interface requested in riid. If this call fails, this value is NULL.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
IShellItemArray GetFolders([In] LIBRARYFOLDERFILTER lff, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Resolves the target location of a library folder, even if the folder has been moved or renamed.</summary>
/// <param name="folderToResolve">An IShellItem object that represents the library folder to locate.</param>
/// <param name="timeout">The maximum time, in milliseconds, the method will attempt to locate the folder before returning. If the folder could not be located before the specified time elapses, an error is returned.</param>
/// <param name="riid">A reference to the IID of the interface to get in ppv that will represent the resolved target location. This value is typically IID_IShellItem, but it can also be IID_IShellItem2 or the IID of any other interface that is implemented by CShellItem.</param>
/// <returns>A pointer to the interface requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
IShellItem ResolveFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem folderToResolve, [In] uint timeout, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Retrieves the default target folder that the library uses for save operations.</summary>
/// <param name="dsft">The DEFAULTSAVEFOLDERTYPE value that specifies the save folder to get.</param>
/// <param name="riid">A reference to the IID of the interface to get in ppv that will represent the save location. This value is typically IID_IShellItem, but it can also be IID_IShellItem2 or the IID of any other interface that is implemented by CShellItem.</param>
/// <returns>A pointer to the interface requested in riid.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
IShellItem GetDefaultSaveFolder([In] DEFAULTSAVEFOLDERTYPE dsft, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Sets the default target folder that the library will use for save operations.</summary>
/// <param name="dsft">The DEFAULTSAVEFOLDERTYPE value that specifies the default save location to set.</param>
/// <param name="si">An IShellItem object that represents the folder that to use as the default save location. The folder that this object represents must be a folder that is already in the library.</param>
void SetDefaultSaveFolder([In] DEFAULTSAVEFOLDERTYPE dsft, [In, MarshalAs(UnmanagedType.Interface)] IShellItem si);
/// <summary>Gets the library's options.</summary>
/// <returns>The library options for this library. LIBRARYOPTIONFLAGS is a bitwise enumerator, which means that more than one flag could be set.</returns>
LIBRARYOPTIONFLAGS GetOptions();
/// <summary>Sets the library options.</summary>
/// <param name="lofMask">A bitmask that specifies the LIBRARYOPTIONFLAGS values to change in this call.</param>
/// <param name="lofOptions">A bitmask that specifies the new value of each LIBRARYOPTIONFLAGS value to change. LIBRARYOPTIONFLAGS values that are not set in lofMask are not changed by this call.</param>
void SetOptions([In] LIBRARYOPTIONFLAGS lofMask, [In] LIBRARYOPTIONFLAGS lofOptions);
/// <summary>Gets the library's folder type.</summary>
/// <returns>The view template that is applied to a folder, usually based on its intended use and contents.</returns>
[return: MarshalAs(UnmanagedType.LPStruct)]
Guid GetFolderType();
/// <summary>Sets the library's folder type.</summary>
/// <param name="ftid">The GUID or FOLDERTYPEID that represents the view template that is applied to a folder, usually based on its intended use and contents.</param>
void SetFolderType([In, MarshalAs(UnmanagedType.LPStruct)] Guid ftid);
/// <summary>Gets the default icon for the library.</summary>
/// <returns>A null-terminated Unicode string that describes the location of the default icon. The string is returned as ModuleFileName,ResourceIndex or ModuleFileName,-ResourceID.</returns>
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler), MarshalCookie = "Unicode")]
string GetIcon();
/// <summary>Sets the default icon for the library.</summary>
/// <param name="icon">A null-terminated Unicode string that describes the location of the default icon. The string must be formatted as ModuleFileName,ResourceIndex or ModuleFileName,-ResourceID.</param>
void SetIcon([In, MarshalAs(UnmanagedType.LPWStr)] string icon);
/// <summary>Commits library updates to an existing Library Description file.</summary>
void Commit();
/// <summary>Saves the library to a new Library Description (*.library-ms) file.</summary>
/// <param name="folderToSaveIn">The IShellItem object that specifies the folder in which to save the library, or NULL to save the library with the user's default libraries in the FOLDERID_Libraries known folder.</param>
/// <param name="libraryName">The file name under which to save the library. The file name must not include the file name extension; the file name extension is added automatically.</param>
/// <param name="lsf">The LIBRARYSAVEFLAGS value that specifies how to handle a library name collision.</param>
/// <returns>The IShellItem object that represents the library description file into which the library was saved.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
IShellItem Save([In, MarshalAs(UnmanagedType.Interface)] IShellItem folderToSaveIn, [In, MarshalAs(UnmanagedType.LPWStr)] string libraryName, [In] LIBRARYSAVEFLAGS lsf);
/// <summary>Saves the library to a new file in a specified known folder.</summary>
/// <param name="kfidToSaveIn">The ID of the known folder in which to save the IShellLibrary object. For more information, see KNOWNFOLDERID.</param>
/// <param name="libraryName">The file name under which to save the library. The file name must not include the file name extension; the file name extension is added automatically.</param>
/// <param name="lsf">The LIBRARYSAVEFLAGS value that specifies how to handle a library name collision.</param>
/// <returns>The IShellItem object that represents the library description file into which the library was saved.</returns>
[return: MarshalAs(UnmanagedType.Interface)]
IShellItem SaveInKnownFolder([In, MarshalAs(UnmanagedType.LPStruct)] Guid kfidToSaveIn, [In, MarshalAs(UnmanagedType.LPWStr)] string libraryName, [In] LIBRARYSAVEFLAGS lsf);
}
/// <summary>Resolves all locations in a library, even those locations that have been moved or renamed.</summary>
/// <param name="psiLibrary">A pointer to an IShellItem object that represents the library.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
/// <remarks>This function can block the calling thread for as long as it takes to resolve all the locations in the specified library. Because it blocks the thread from which it is called, it should not be called from a thread that also handles user interface interactions.
/// <para>This function resolves all locations in the specified library in a single call. To resolve an individual location in a library, see the IShellLibrary::ResolveFolder method or the SHResolveFolderPathInLibrary function.</para></remarks>
[DllImport(Lib.Shell32, ExactSpelling = true)]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378439")]
public static extern HRESULT SHResolveLibrary([MarshalAs(UnmanagedType.Interface)] IShellItem psiLibrary);
/// <summary>Shows the library management dialog box, which enables users to manage the library folders and default save location.</summary>
/// <param name="psiLibrary">A pointer to an IShellItem object that represents the library that is to be managed.</param>
/// <param name="hwndOwner">The handle for the window that owns the library management dialog box. The value of this parameter can be NULL.</param>
/// <param name="pszTitle">A pointer to the title for the library management dialog. To display the generic title string, set the value of this parameter to NULL.</param>
/// <param name="pszInstruction">A pointer to a help string to display below the title string in the library management dialog box. To display the generic help string, set the value of this parameter to NULL.</param>
/// <param name="lmdOptions">A value from the LIBRARYMANAGEDIALOGOPTIONS enumeration that specifies the behavior of the management dialog box.</param>
/// <returns>If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
[DllImport(Lib.Shell32, ExactSpelling = true)]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378433")]
public static extern HRESULT SHShowManageLibraryUI([MarshalAs(UnmanagedType.Interface)] IShellItem psiLibrary, HandleRef hwndOwner, [In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle, [In, MarshalAs(UnmanagedType.LPWStr)] string pszInstruction, LIBRARYMANAGEDIALOGOPTIONS lmdOptions);
/// <summary>Class interface for IShellLibrary</summary>
[ComImport, Guid("d9b3211d-e57f-4426-aaef-30a806add397"), ClassInterface(ClassInterfaceType.None)]
public class CShellLibrary { }
}
}

View File

@ -0,0 +1,418 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using Vanara.InteropServices;
// 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
{
public static partial class Shell32
{
/// <summary>Specifies option settings. Used with IShellLinkDataList::GetFlags and IShellLinkDataList::SetFlags.</summary>
[PInvokeData("Shlobj.h", MSDNShortId = "bb762540")]
[Flags]
public enum SHELL_LINK_DATA_FLAGS : uint
{
/// <summary>Default value used when no other flag is explicitly set.</summary>
SLDF_DEFAULT = 0x00000000,
/// <summary>The Shell link was saved with an ID list.</summary>
SLDF_HAS_ID_LIST = 0x00000001,
/// <summary>
/// The Shell link was saved with link information to enable distributed tracking. This information is used by .lnk files to locate the target if the
/// targets's path has changed. It includes information such as volume label and serial number, although the specific stored information can change
/// from release to release.
/// </summary>
SLDF_HAS_LINK_INFO = 0x00000002,
/// <summary>The link has a name.</summary>
SLDF_HAS_NAME = 0x00000004,
/// <summary>The link has a relative path.</summary>
SLDF_HAS_RELPATH = 0x00000008,
/// <summary>The link has a working directory.</summary>
SLDF_HAS_WORKINGDIR = 0x00000010,
/// <summary>The link has arguments.</summary>
SLDF_HAS_ARGS = 0x00000020,
/// <summary>The link has an icon location.</summary>
SLDF_HAS_ICONLOCATION = 0x00000040,
/// <summary>Stored strings are Unicode.</summary>
SLDF_UNICODE = 0x00000080,
/// <summary>
/// Prevents the storage of link tracking information. If this flag is set, it is less likely, though not impossible, that a target can be found by
/// the link if that target is moved.
/// </summary>
SLDF_FORCE_NO_LINKINFO = 0x00000100,
/// <summary>The link contains expandable environment strings such as %windir%.</summary>
SLDF_HAS_EXP_SZ = 0x00000200,
/// <summary>Causes a 16-bit target application to run in a separate Virtual DOS Machine (VDM)/Windows on Windows (WOW).</summary>
SLDF_RUN_IN_SEPARATE = 0x00000400,
/// <summary>Not supported. Note that as of Windows Vista, this value is no longer defined.</summary>
SLDF_HAS_LOGO3ID = 0x00000800,
/// <summary>The link is a special Windows Installer link.</summary>
SLDF_HAS_DARWINID = 0x00001000,
/// <summary>Causes the target application to run as a different user.</summary>
SLDF_RUNAS_USER = 0x00002000,
/// <summary>The icon path in the link contains an expandable environment string such as such as %windir%.</summary>
SLDF_HAS_EXP_ICON_SZ = 0x00004000,
/// <summary>Prevents the use of ID list alias mapping when parsing the ID list from the path.</summary>
SLDF_NO_PIDL_ALIAS = 0x00008000,
/// <summary>Forces the use of the UNC name (a full network resource name), rather than the local name.</summary>
SLDF_FORCE_UNCNAME = 0x00010000,
/// <summary>
/// Causes the target of this link to launch with a shim layer active. A shim is an intermediate DLL that facilitates compatibility between otherwise
/// incompatible software services. Shims are typically used to provide version compatibility.
/// </summary>
SLDF_RUN_WITH_SHIMLAYER = 0x00020000,
/// <summary>Introduced in Windows Vista. Disable object ID distributed tracking information.</summary>
SLDF_FORCE_NO_LINKTRACK = 0x00040000,
/// <summary>Introduced in Windows Vista. Enable the caching of target metadata into the link file.</summary>
SLDF_ENABLE_TARGET_METADATA = 0x000800000,
/// <summary>Introduced in Windows 7. Disable shell link tracking.</summary>
SLDF_DISABLE_LINK_PATH_TRACKING = 0x00100000,
/// <summary>Introduced in Windows Vista. Disable known folder tracking information.</summary>
SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING = 0x00200000,
/// <summary>Introduced in Windows 7. Disable known folder alias mapping when loading the IDList during deserialization.</summary>
SLDF_NO_KF_ALIAS = 0x00400000,
/// <summary>Introduced in Windows 7. Allow link to point to another shell link as long as this does not create cycles.</summary>
SLDF_ALLOW_LINK_TO_LINK = 0x00800000,
/// <summary>Introduced in Windows 7. Remove alias when saving the IDList.</summary>
SLDF_UNALIAS_ON_SAVE = 0x01000000,
/// <summary>
/// Introduced in Windows 7. Recalculate the IDList from the path with the environmental variables at load time, rather than persisting the IDList.
/// </summary>
SLDF_PREFER_ENVIRONMENT_PATH = 0x02000000,
/// <summary>
/// Introduced in Windows 7. If the target is a UNC location on a local machine, keep the local IDList target in addition to the remote target.
/// </summary>
SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET = 0x04000000,
/// <summary>Introduced in Windows 8. Persist the target IDlist in its volume-ID-relative form to avoid a dependency on drive letters.</summary>
SLDF_PERSIST_VOLUME_ID_RELATIVE = 0x08000000,
}
/// <summary>Defines which data block is supported.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774916")]
public enum ShellDataBlockSignature : uint
{
/// <summary>The target name.</summary>
EXP_SZ_LINK_SIG = 0xA0000001,
/// <summary>Console properties</summary>
NT_CONSOLE_PROPS_SIG = 0xA0000002,
/// <summary>The console's code page.</summary>
NT_FE_CONSOLE_PROPS_SIG = 0xA0000004,
/// <summary>Special folder information.</summary>
EXP_SPECIAL_FOLDER_SIG = 0xA0000005,
/// <summary>The link's Windows Installer ID.</summary>
EXP_DARWIN_ID_SIG = 0xA0000006,
/// <summary>The icon path.</summary>
EXP_SZ_ICON_SIG = 0xA0000007,
/// <summary>Stores information about the Shell link state.</summary>
EXP_PROPERTYSTORAGE_SIG = 0xA0000009,
}
/// <summary>Action flags.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774952")]
[Flags]
public enum SLR_FLAGS
{
/// <summary>No action.</summary>
SLR_NONE = 0,
/// <summary>
/// Do not display a dialog box if the link cannot be resolved. When SLR_NO_UI is set, the high-order word of fFlags can be set to a time-out value
/// that specifies the maximum amount of time to be spent resolving the link. The function returns if the link cannot be resolved within the time-out
/// duration. If the high-order word is set to zero, the time-out duration will be set to the default value of 3,000 milliseconds (3 seconds). To
/// specify a value, set the high word of fFlags to the desired time-out duration, in milliseconds.
/// </summary>
SLR_NO_UI = 0x1,
/// <summary>Not used.</summary>
SLR_ANY_MATCH = 0x2,
/// <summary>
/// If the link object has changed, update its path and list of identifiers. If SLR_UPDATE is set, you do not need to call IPersistFile::IsDirty to
/// determine whether the link object has changed.
/// </summary>
SLR_UPDATE = 0x4,
/// <summary>Do not update the link information.</summary>
SLR_NOUPDATE = 0x8,
/// <summary>Do not execute the search heuristics.</summary>
SLR_NOSEARCH = 0x10,
/// <summary>Do not use distributed link tracking.</summary>
SLR_NOTRACK = 0x20,
/// <summary>
/// Disable distributed link tracking. By default, distributed link tracking tracks removable media across multiple devices based on the volume name.
/// It also uses the UNC path to track remote file systems whose drive letter has changed. Setting SLR_NOLINKINFO disables both types of tracking.
/// </summary>
SLR_NOLINKINFO = 0x40,
/// <summary>Call the Windows Installer.</summary>
SLR_INVOKE_MSI = 0x80,
/// <summary>Windows XP and later.</summary>
SLR_NO_UI_WITH_MSG_PUMP = 0x101,
/// <summary>
/// Windows 7 and later. Offer the option to delete the shortcut when this method is unable to resolve it, even if the shortcut is not a shortcut to
/// a file.
/// </summary>
SLR_OFFER_DELETE_WITHOUT_FILE = 0x200,
/// <summary>
/// Windows 7 and later. Report as dirty if the target is a known folder and the known folder was redirected. This only works if the original target
/// path was a file system path or ID list and not an aliased known folder ID list.
/// </summary>
SLR_KNOWNFOLDER = 0x400,
/// <summary>Windows 7 and later. Resolve the computer name in UNC targets that point to a local computer. This value is used with SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET.</summary>
SLR_MACHINE_IN_LOCAL_TARGET = 0x800,
/// <summary>Windows 7 and later. Update the computer GUID and user SID if necessary.</summary>
SLR_UPDATE_MACHINE_AND_SID = 0x1000,
/// <summary></summary>
SLR_NO_OBJECT_ID = 0x2000
}
/// <summary>Exposes methods that allow an application to attach extra data blocks to a Shell link. These methods add, copy, or remove data blocks.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("45e2b4ae-b1c3-11d0-b92f-00a0c90312e1")]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774916")]
public interface IShellLinkDataList
{
/// <summary>Adds a data block to a link.</summary>
/// <param name="pDataBlock">The data block structure. For a list of supported structures, see IShellLinkDataList.</param>
void AddDataBlock(IntPtr pDataBlock);
/// <summary>Retrieves a copy of a link's data block.</summary>
/// <param name="dwSig">
/// The data block's signature. The signature value for a particular type of data block can be found in its structure reference. For a list of
/// supported data block types and their associated structures, see IShellLinkDataList.
/// </param>
/// <returns>
/// The address of a pointer to a copy of the data block structure. If IShellLinkDataList::CopyDataBlock returns a successful result, the calling
/// application must free the memory when it is no longer needed by calling LocalFree.
/// </returns>
SafeLocalHandle CopyDataBlock(ShellDataBlockSignature dwSig);
/// <summary>Removes a data block from a link.</summary>
/// <param name="dwSig">
/// The data block's signature. The signature value for a particular type of data block can be found in its structure reference. For a list of
/// supported data block types and their associated structures, see IShellLinkDataList.
/// </param>
void RemoveDataBlock(ShellDataBlockSignature dwSig);
/// <summary>Gets the current option settings.</summary>
/// <returns>Pointer to one or more of the SHELL_LINK_DATA_FLAGS that indicate the current option settings.</returns>
SHELL_LINK_DATA_FLAGS GetFlags();
/// <summary>Sets the current option settings.</summary>
/// <param name="dwFlags">One or more of the SHELL_LINK_DATA_FLAGS that indicate the option settings.</param>
void SetFlags(SHELL_LINK_DATA_FLAGS dwFlags);
}
/// <summary>Exposes methods that create, modify, and resolve Shell links.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F9-0000-0000-C000-000000000046"), CoClass(typeof(CShellLinkW))]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774950")]
public interface IShellLinkW
{
/// <summary>Gets the path and file name of the target of a Shell link object.</summary>
/// <param name="pszFile">The address of a buffer that receives the path and file name of the target of the Shell link object.</param>
/// <param name="cchMaxPath">
/// The size, in characters, of the buffer pointed to by the pszFile parameter, including the terminating null character. The maximum path size that
/// can be returned is MAX_PATH. This parameter is commonly set by calling ARRAYSIZE(pszFile). The ARRAYSIZE macro is defined in Winnt.h.
/// </param>
/// <param name="pfd">
/// A pointer to a WIN32_FIND_DATA structure that receives information about the target of the Shell link object. If this parameter is NULL, then no
/// additional information is returned.
/// </param>
/// <param name="fFlags">Flags that specify the type of path information to retrieve.</param>
void GetPath([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath,
[In, Out] WIN32_FIND_DATA pfd, SLGP fFlags);
/// <summary>Gets the list of item identifiers for the target of a Shell link object.</summary>
/// <returns>When this method returns, contains the address of a PIDL.</returns>
PIDL GetIDList();
/// <summary>Sets the pointer to an item identifier list (PIDL) for a Shell link object.</summary>
/// <param name="pidl">The object's fully qualified PIDL.</param>
void SetIDList(PIDL pidl);
/// <summary>Gets the description string for a Shell link object.</summary>
/// <param name="pszFile">A pointer to the buffer that receives the description string.</param>
/// <param name="cchMaxName">The maximum number of characters to copy to the buffer pointed to by the pszName parameter.</param>
void GetDescription([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxName);
/// <summary>Sets the description for a Shell link object. The description can be any application-defined string.</summary>
/// <param name="pszName">A pointer to a buffer containing the new description string.</param>
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
/// <summary>Gets the name of the working directory for a Shell link object.</summary>
/// <param name="pszDir">The address of a buffer that receives the name of the working directory.</param>
/// <param name="cchMaxPath">
/// The maximum number of characters to copy to the buffer pointed to by the pszDir parameter. The name of the working directory is truncated if it
/// is longer than the maximum specified by this parameter.
/// </param>
void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszDir, int cchMaxPath);
/// <summary>Sets the name of the working directory for a Shell link object.</summary>
/// <param name="pszDir">The address of a buffer that contains the name of the new working directory.</param>
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
/// <summary>Gets the command-line arguments associated with a Shell link object.</summary>
/// <param name="pszArgs">A pointer to the buffer that, when this method returns successfully, receives the command-line arguments.</param>
/// <param name="cchMaxPath">
/// The maximum number of characters that can be copied to the buffer supplied by the pszArgs parameter. In the case of a Unicode string, there is no
/// limitation on maximum string length. In the case of an ANSI string, the maximum length of the returned string varies depending on the version of
/// Windows—MAX_PATH prior to Windows 2000 and INFOTIPSIZE (defined in Commctrl.h) in Windows 2000 and later.
/// </param>
void GetArguments([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszArgs, int cchMaxPath);
/// <summary>Sets the command-line arguments for a Shell link object.</summary>
/// <param name="pszArgs">
/// A pointer to a buffer that contains the new command-line arguments. In the case of a Unicode string, there is no limitation on maximum string
/// length. In the case of an ANSI string, the maximum length of the returned string varies depending on the version of Windows—MAX_PATH prior to
/// Windows 2000 and INFOTIPSIZE (defined in Commctrl.h) in Windows 2000 and later.
/// </param>
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
/// <summary>Gets the keyboard shortcut (hot key) for a Shell link object.</summary>
/// <returns>
/// The address of the keyboard shortcut. The virtual key code is in the low-order byte, and the modifier flags are in the high-order byte.
/// </returns>
ushort GetHotKey();
/// <summary>Sets a keyboard shortcut (hot key) for a Shell link object.</summary>
/// <param name="wHotKey">
/// The new keyboard shortcut. The virtual key code is in the low-order byte, and the modifier flags are in the high-order byte. The modifier flags
/// can be a combination of the values specified in the description of the IShellLink::GetHotkey method.
/// </param>
void SetHotKey(ushort wHotKey);
/// <summary>Gets the show command for a Shell link object.</summary>
/// <returns>
/// A pointer to the command. The following commands are supported.
/// <list>
/// <item>
/// <term>SW_SHOWNORMAL</term>
/// <description>
/// Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An
/// application should specify this flag when displaying the window for the first time.
/// </description>
/// </item>
/// <item>
/// <term>SW_SHOWMAXIMIZED</term>
/// <description>Activates the window and displays it as a maximized window.</description>
/// </item>
/// <item>
/// <term>SW_SHOWMINIMIZED</term>
/// <description>Activates the window and displays it as a minimized window.</description>
/// </item>
/// </list>
/// </returns>
ShowWindowCommand GetShowCmd();
/// <summary>Sets the show command for a Shell link object. The show command sets the initial show state of the window.</summary>
/// <param name="iShowCmd">
/// SetShowCmd accepts one of the following ShowWindow commands.
/// <list>
/// <item>
/// <term>SW_SHOWNORMAL</term>
/// <description>
/// Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An
/// application should specify this flag when displaying the window for the first time.
/// </description>
/// </item>
/// <item>
/// <term>SW_SHOWMAXIMIZED</term>
/// <description>Activates the window and displays it as a maximized window.</description>
/// </item>
/// <item>
/// <term>SW_SHOWMINIMIZED</term>
/// <description>Activates the window and displays it as a minimized window.</description>
/// </item>
/// </list>
/// </param>
void SetShowCmd(ShowWindowCommand iShowCmd);
/// <summary>Gets the location (path and index) of the icon for a Shell link object.</summary>
/// <param name="pszIconPath">The address of a buffer that receives the path of the file containing the icon.</param>
/// <param name="cchIconPath">The maximum number of characters to copy to the buffer pointed to by the pszIconPath parameter.</param>
/// <param name="piIcon">The address of a value that receives the index of the icon.</param>
void GetIconLocation([Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszIconPath, int cchIconPath,
out int piIcon);
/// <summary>Sets the location (path and index) of the icon for a Shell link object.</summary>
/// <param name="pszIconPath">The address of a buffer to contain the path of the file containing the icon.</param>
/// <param name="iIcon">The index of the icon.</param>
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
/// <summary>Sets the relative path to the Shell link object.</summary>
/// <param name="pszPathRel">
/// The address of a buffer that contains the fully-qualified path of the shortcut file, relative to which the shortcut resolution should be
/// performed. It should be a file name, not a folder name.
/// </param>
/// <param name="dwReserved">Reserved. Set this parameter to zero.</param>
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, [Optional] uint dwReserved);
/// <summary>Attempts to find the target of a Shell link, even if it has been moved or renamed.</summary>
/// <param name="hwnd">
/// A handle to the window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the user
/// for more information while resolving a Shell link.
/// </param>
/// <param name="fFlags">Action flags.</param>
void Resolve(IntPtr hwnd, SLR_FLAGS fFlags);
/// <summary>Sets the path and file name for the target of a Shell link object.</summary>
/// <param name="pszFile">The address of a buffer that contains the new path.</param>
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
/// <summary>Class interface for IShellLinkW.</summary>
[ComImport, Guid("00021401-0000-0000-C000-000000000046"), ClassInterface(ClassInterfaceType.None)]
public class CShellLinkW { }
}
}

View File

@ -0,0 +1,740 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable InconsistentNaming
// ReSharper disable MemberHidesStaticFromOuterClass
// ReSharper disable UnusedMethodReturnValue.Global
namespace Vanara.PInvoke
{
public static partial class Shell32
{
/// <summary>Used by the ITaskbarList4::SetTabProperties method to specify tab properties.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "dd562320")]
[Flags]
public enum STPFLAG
{
/// <summary>
/// No specific property values are specified. The default behavior is used: the tab window provides a thumbnail and peek image, either live or
/// static as appropriate.
/// </summary>
STPF_NONE = 0,
/// <summary>
/// Always use the thumbnail provided by the main application frame window rather than a thumbnail provided by the individual tab window. Do not
/// combine this value with STPF_USEAPPTHUMBNAILWHENACTIVE; doing so will result in an error.
/// </summary>
STPF_USEAPPTHUMBNAILALWAYS = 1,
/// <summary>
/// When the application tab is active and a live representation of its window is available, use the main application's frame window thumbnail. At
/// other times, use the tab window thumbnail. Do not combine this value with STPF_USEAPPTHUMBNAILALWAYS; doing so will result in an error.
/// </summary>
STPF_USEAPPTHUMBNAILWHENACTIVE = 2,
/// <summary>
/// Always use the peek image provided by the main application frame window rather than a peek image provided by the individual tab window. Do not
/// combine this value with STPF_USEAPPPEEKWHENACTIVE; doing so will result in an error.
/// </summary>
STPF_USEAPPPEEKALWAYS = 4,
/// <summary>
/// When the application tab is active and a live representation of its window is available, show the main application frame in the peek feature. At
/// other times, use the tab window. Do not combine this value with STPF_USEAPPPEEKALWAYS; doing so will result in an error.
/// </summary>
STPF_USEAPPPEEKWHENACTIVE = 8,
}
/// <summary>
/// Flags that control the current state of the progress button. Specify only one of the following flags; all states are mutually exclusive of all others.
/// </summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "dd391697")]
[Flags]
public enum TBPFLAG
{
/// <summary>
/// The progress indicator turns red to show that an error has occurred in one of the windows that is broadcasting progress. This is a determinate
/// state. If the progress indicator is in the indeterminate state, it switches to a red determinate display of a generic percentage not indicative
/// of actual progress.
/// </summary>
TBPF_ERROR = 4,
/// <summary>
/// The progress indicator does not grow in size, but cycles repeatedly along the length of the taskbar button. This indicates activity without
/// specifying what proportion of the progress is complete. Progress is taking place, but there is no prediction as to how long the operation will take.
/// </summary>
TBPF_INDETERMINATE = 1,
/// <summary>
/// Stops displaying progress and returns the button to its normal state. Call this method with this flag to dismiss the progress bar when the
/// operation is complete or canceled.
/// </summary>
TBPF_NOPROGRESS = 0,
/// <summary>
/// The progress indicator grows in size from left to right in proportion to the estimated amount of the operation completed. This is a determinate
/// progress indicator; a prediction is being made as to the duration of the operation.
/// </summary>
TBPF_NORMAL = 2,
/// <summary>
/// The progress indicator turns yellow to show that progress is currently stopped in one of the windows but can be resumed by the user. No error
/// condition exists and nothing is preventing the progress from continuing. This is a determinate state. If the progress indicator is in the
/// indeterminate state, it switches to a yellow determinate display of a generic percentage not indicative of actual progress.
/// </summary>
TBPF_PAUSED = 8
}
/// <summary>Used by THUMBBUTTON to control specific states and behaviors of the button.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "dd562321")]
[Flags]
public enum THUMBBUTTONFLAGS : uint
{
/// <summary>The button is disabled. It is present, but has a visual state that indicates that it will not respond to user action.</summary>
THBF_DISABLED = 1,
/// <summary>When the button is clicked, the taskbar button's flyout closes immediately.</summary>
THBF_DISMISSONCLICK = 2,
/// <summary>The button is active and available to the user.</summary>
THBF_ENABLED = 0,
/// <summary>The button is not shown to the user.</summary>
THBF_HIDDEN = 8,
/// <summary>Do not draw a button border, use only the image.</summary>
THBF_NOBACKGROUND = 4,
/// <summary>
/// The button is enabled but not interactive; no pressed button state is drawn. This value is intended for instances where the button is used in a notification.
/// </summary>
THBF_NONINTERACTIVE = 0x10
}
/// <summary>Used by the THUMBBUTTON structure to specify which members of that structure contain valid data.</summary>
[PInvokeData("Shobjidl.h", MSDNShortId = "dd562322")]
[Flags]
public enum THUMBBUTTONMASK : uint
{
/// <summary>The iBitmap member contains valid information.</summary>
THB_BITMAP = 1,
/// <summary>The dwFlags member contains valid information.</summary>
THB_FLAGS = 8,
/// <summary>The hIcon member contains valid information.</summary>
THB_ICON = 2,
/// <summary>The szTip member contains valid information.</summary>
THB_TOOLTIP = 4
}
/// <summary>Exposes methods that allow an application to provide a custom Jump List, including destinations and tasks, for display in the taskbar.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("6332debf-87b5-4670-90c0-5e57b408a49e"), CoClass(typeof(CDestinationList))]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd378402")]
public interface ICustomDestinationList
{
/// <summary>
/// Specifies a unique Application User Model ID (AppUserModelID) for the application whose taskbar button will hold the custom Jump List built
/// through the methods of this interface. This method is optional.
/// </summary>
/// <param name="pszAppID">A pointer to the AppUserModelID of the process or application whose taskbar representation receives the Jump List.</param>
void SetAppID([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
/// <summary>Initiates a building session for a custom Jump List.</summary>
/// <param name="pcMaxSlots">
/// A pointer that, when this method returns, points to the current user setting for the Number of recent items to display in Jump Lists option in
/// the Taskbar and Start Menu Properties window. The default value is 10. This is the maximum number of destinations that will be shown, and it is a
/// total of all destinations, regardless of category. More destinations can be added, but they will not be shown in the UI.
/// <para>A Jump List will always show at least this many slots—destinations and, if there is room, tasks.</para>
/// <para>
/// This number does not include separators and section headers as long as the total number of separators and headers does not exceed four.
/// Separators and section headers beyond the first four might reduce the number of destinations displayed if space is constrained. This number does
/// not affect the standard command entries for pinning or unpinning, closing the window, or launching a new instance. It also does not affect tasks
/// or pinned items, the number of which that can be displayed is based on the space available to the Jump List.
/// </para>
/// </param>
/// <param name="riid">
/// A reference to the IID of an interface to be retrieved in ppv, typically IID_IObjectArray, that will represent all items currently stored in the
/// list of removed destinations for the application. This information is used to ensure that removed items are not part of the new Jump List.
/// </param>
/// <returns>
/// When this method returns, contains the interface pointer requested in riid. This is typically an IObjectArray, which represents a collection of
/// IShellItem and IShellLink objects that represent the removed items.
/// </returns>
[return: MarshalAs(UnmanagedType.Interface)]
object BeginList(out uint pcMaxSlots, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Defines a custom category and the destinations that it contains, for inclusion in a custom Jump List.</summary>
/// <param name="pszCategory">
/// A pointer to a string that contains the display name of the custom category. This string is shown in the category's header in the Jump List. The
/// string can directly hold the display name or it can be an indirect string representation, such as "@shell32.dll,-1324", to use a stored string.
/// An indirect string enables the category header to be displayed in the user's selected language. <note>Each custom category must have a unique
/// name. Duplicate category names will cause presentation issues in the Jump List.</note>
/// </param>
/// <param name="poa">
/// A pointer to an IObjectArray that represents one or more IShellItem objects that represent the destinations in the category. Some destinations in
/// the list might also be represented by IShellLink objects, although less often. <note>Any IShellLink used here must declare an argument list
/// through SetArguments. Adding an IShellLink object with no arguments to a custom category is not supported since a user cannot pin or unpin this
/// type of item from a Jump List, nor can they be added or removed.</note>
/// </param>
void AppendCategory([MarshalAs(UnmanagedType.LPWStr)] string pszCategory, IObjectArray poa);
/// <summary>Specifies that the Frequent or Recent category should be included in a custom Jump List.</summary>
/// <param name="category">One of the KNOWNDESTCATEGORY values that indicate which known category to add to the list.</param>
void AppendKnownCategory(KNOWNDESTCATEGORY category);
/// <summary>Specifies items to include in the Tasks category of a custom Jump List.</summary>
/// <param name="poa">
/// A pointer to an IObjectArray that represents one or more IShellLink (or, more rarely, IShellItem) objects that represent the tasks. <note>Any
/// IShellLink used here must declare an argument list through SetArguments. Adding an IShellLink object with no arguments to a custom category is
/// not supported. A user cannot pin or unpin this type of item from a Jump List, nor can they be added or removed.</note>
/// </param>
void AddUserTasks(IObjectArray poa);
/// <summary>Declares that the Jump List initiated by a call to ICustomDestinationList::BeginList is complete and ready for display.</summary>
void CommitList();
/// <summary>
/// Retrieves the current list of destinations that have been removed by the user from the existing Jump List that this custom Jump List is meant to replace.
/// </summary>
/// <param name="riid">A reference to the IID of the interface to retrieve through ppv, typically IID_IObjectArray.</param>
/// <returns>
/// When this method returns, contains the interface pointer requested in riid. This is typically an IObjectArray, which represents a collection of
/// IShellItem or IShellLink objects that represent the items in the list of removed destinations.
/// </returns>
[return: MarshalAs(UnmanagedType.Interface)]
object GetRemovedDestinations([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
/// <summary>Deletes a custom Jump List for a specified application.</summary>
/// <param name="pszAppID">
/// A pointer to the AppUserModelID of the process whose taskbar button representation displays the custom Jump List. In the beta release of Windows
/// 7, this AppUserModelID must be explicitly provided because this method is intended to be called from an uninstaller, which runs in a separate
/// process. Because it is in a separate process, the system cannot reliably deduce the AppUserModelID. This restriction is expected to be removed in
/// later releases.
/// </param>
void DeleteList([MarshalAs(UnmanagedType.LPWStr)] string pszAppID);
/// <summary>Discontinues a Jump List building session initiated by ICustomDestinationList::BeginList without committing any changes.</summary>
void AbortList();
}
/// <summary>Exposes methods that control the taskbar. It allows you to dynamically add, remove, and activate items on the taskbar.</summary>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("56FDF342-FD6D-11d0-958A-006097C9A090"), CoClass(typeof(CTaskbarList))]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774652")]
public interface ITaskbarList
{
/// <summary>Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.</summary>
void HrInit();
/// <summary>Adds an item to the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be added to the taskbar.</param>
void AddTab(IntPtr hwnd);
/// <summary>Deletes an item from the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be deleted from the taskbar.</param>
void DeleteTab(IntPtr hwnd);
/// <summary>
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
/// </summary>
/// <param name="hwnd">A handle to the window on the taskbar to be displayed as active.</param>
void ActivateTab(IntPtr hwnd);
/// <summary>Marks a taskbar item as active but does not visually activate it.</summary>
/// <param name="hwnd">A handle to the window to be marked as active.</param>
void SetActiveAlt(IntPtr hwnd);
}
/// <summary>Extends the ITaskbarList interface by exposing a method to mark a window as a full-screen display.</summary>
/// <seealso cref="ITaskbarList"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("602D4995-B13A-429b-A66E-1935E44F4317"), CoClass(typeof(CTaskbarList))]
[PInvokeData("Shobjidl.h", MSDNShortId = "bb774638")]
public interface ITaskbarList2 : ITaskbarList
{
/// <summary>Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.</summary>
new void HrInit();
/// <summary>Adds an item to the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be added to the taskbar.</param>
new void AddTab(IntPtr hwnd);
/// <summary>Deletes an item from the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be deleted from the taskbar.</param>
new void DeleteTab(IntPtr hwnd);
/// <summary>
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
/// </summary>
/// <param name="hwnd">A handle to the window on the taskbar to be displayed as active.</param>
new void ActivateTab(IntPtr hwnd);
/// <summary>Marks a taskbar item as active but does not visually activate it.</summary>
/// <param name="hwnd">A handle to the window to be marked as active.</param>
new void SetActiveAlt(IntPtr hwnd);
/// <summary>Marks a window as full-screen.</summary>
/// <param name="hwnd">The handle of the window to be marked.</param>
/// <param name="fFullscreen">A Boolean value marking the desired full-screen status of the window.</param>
void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
}
/// <summary>
/// Extends ITaskbarList2 by exposing methods that support the unified launching and switching taskbar button functionality added in Windows 7. This
/// functionality includes thumbnail representations and switch targets based on individual tabs in a tabbed application, thumbnail toolbars,
/// notification and status overlays, and progress indicators.
/// </summary>
/// <seealso cref="ITaskbarList2"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf"), CoClass(typeof(CTaskbarList))]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd391692", MinClient = PInvokeClient.Windows7)]
public interface ITaskbarList3 : ITaskbarList2
{
/// <summary>Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.</summary>
new void HrInit();
/// <summary>Adds an item to the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be added to the taskbar.</param>
new void AddTab(IntPtr hwnd);
/// <summary>Deletes an item from the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be deleted from the taskbar.</param>
new void DeleteTab(IntPtr hwnd);
/// <summary>
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
/// </summary>
/// <param name="hwnd">A handle to the window on the taskbar to be displayed as active.</param>
new void ActivateTab(IntPtr hwnd);
/// <summary>Marks a taskbar item as active but does not visually activate it.</summary>
/// <param name="hwnd">A handle to the window to be marked as active.</param>
new void SetActiveAlt(IntPtr hwnd);
/// <summary>Marks a window as full-screen.</summary>
/// <param name="hwnd">The handle of the window to be marked.</param>
/// <param name="fFullscreen">A Boolean value marking the desired full-screen status of the window.</param>
new void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
/// <summary>Displays or updates a progress bar hosted in a taskbar button to show the specific percentage completed of the full operation.</summary>
/// <param name="hwnd">The handle of the window whose associated taskbar button is being used as a progress indicator.</param>
/// <param name="ullCompleted">
/// An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.
/// </param>
/// <param name="ullTotal">An application-defined value that specifies the value ullCompleted will have when the operation is complete.</param>
void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
/// <summary>Sets the type and state of the progress indicator displayed on a taskbar button.</summary>
/// <param name="hwnd">
/// The handle of the window in which the progress of an operation is being shown. This window's associated taskbar button will display the progress bar.
/// </param>
/// <param name="tbpFlags">
/// Flags that control the current state of the progress button. Specify only one of the following flags; all states are mutually exclusive of all others.
/// </param>
void SetProgressState(IntPtr hwnd, TBPFLAG tbpFlags);
/// <summary>Informs the taskbar that a new tab or document thumbnail has been provided for display in an application's taskbar group flyout.</summary>
/// <param name="hwndTab">Handle of the tab or document window. This value is required and cannot be NULL.</param>
/// <param name="hwndMDI">
/// Handle of the application's main window. This value tells the taskbar which application's preview group to attach the new thumbnail to. This
/// value is required and cannot be NULL.
/// </param>
/// <remarks>
/// By itself, registering a tab thumbnail alone will not result in its being displayed. You must also call ITaskbarList3::SetTabOrder to instruct
/// the group where to display it.
/// </remarks>
void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
/// <summary>Removes a thumbnail from an application's preview group when that tab or document is closed in the application.</summary>
/// <param name="hwndTab">
/// The handle of the tab window whose thumbnail is being removed. This is the same value with which the thumbnail was registered as part the group
/// through ITaskbarList3::RegisterTab. This value is required and cannot be NULL.
/// </param>
/// <remarks>
/// It is the responsibility of the calling application to free hwndTab through DestroyWindow. UnregisterTab must be called before the handle is freed.
/// </remarks>
void UnregisterTab(IntPtr hwndTab);
/// <summary>
/// Inserts a new thumbnail into a tabbed-document interface (TDI) or multiple-document interface (MDI) application's group flyout or moves an
/// existing thumbnail to a new position in the application's group.
/// </summary>
/// <param name="hwndTab">
/// The handle of the tab window whose thumbnail is being placed. This value is required, must already be registered through
/// ITaskbarList3::RegisterTab, and cannot be NULL.
/// </param>
/// <param name="hwndInsertBefore">
/// The handle of the tab window whose thumbnail that hwndTab is inserted to the left of. This handle must already be registered through
/// ITaskbarList3::RegisterTab. If this value is NULL, the new thumbnail is added to the end of the list.
/// </param>
/// <remarks>This method must be called for the thumbnail to be shown in the group. Call it after you have called ITaskbarList3::RegisterTab.</remarks>
void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
/// <summary>Informs the taskbar that a tab or document window has been made the active window.</summary>
/// <param name="hwndTab">
/// Handle of the active tab window. This handle must already be registered through ITaskbarList3::RegisterTab. This value can be NULL if no tab is active.
/// </param>
/// <param name="hwndMDI">
/// Handle of the application's main window. This value tells the taskbar which group the thumbnail is a member of. This value is required and cannot
/// be NULL.
/// </param>
/// <param name="dwReserved">Reserved; set to 0.</param>
void SetTabActive(IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved);
/// <summary>Adds a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window in a taskbar button flyout.</summary>
/// <param name="hwnd">
/// The handle of the window whose thumbnail representation will receive the toolbar. This handle must belong to the calling process.
/// </param>
/// <param name="cButtons">The number of buttons defined in the array pointed to by pButton. The maximum number of buttons allowed is 7.</param>
/// <param name="pButtons">
/// A pointer to an array of THUMBBUTTON structures. Each THUMBBUTTON defines an individual button to be added to the toolbar. Buttons cannot be
/// added or deleted later, so this must be the full defined set. Buttons also cannot be reordered, so their order in the array, which is the order
/// in which they are displayed left to right, will be their permanent order.
/// </param>
void ThumbBarAddButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
/// <summary>
/// Shows, enables, disables, or hides buttons in a thumbnail toolbar as required by the window's current state. A thumbnail toolbar is a toolbar
/// embedded in a thumbnail image of a window in a taskbar button flyout.
/// </summary>
/// <param name="hwnd">The handle of the window whose thumbnail representation contains the toolbar.</param>
/// <param name="cButtons">
/// The number of buttons defined in the array pointed to by pButton. The maximum number of buttons allowed is 7. This array contains only structures
/// that represent existing buttons that are being updated.
/// </param>
/// <param name="pButtons">
/// A pointer to an array of THUMBBUTTON structures. Each THUMBBUTTON defines an individual button. If the button already exists (the iId value is
/// already defined), then that existing button is updated with the information provided in the structure.
/// </param>
void ThumbBarUpdateButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
/// <summary>
/// Specifies an image list that contains button images for a toolbar embedded in a thumbnail image of a window in a taskbar button flyout.
/// </summary>
/// <param name="hwnd">
/// The handle of the window whose thumbnail representation contains the toolbar to be updated. This handle must belong to the calling process.
/// </param>
/// <param name="himl">The handle of the image list that contains all button images to be used in the toolbar.</param>
/// <remarks>
/// Applications must provide these button images:
/// <list type="bullet">
/// <item>
/// <term>The button in its default active state.</term>
/// </item>
/// <item>
/// <term>Images suitable for use with high-dpi (dots per inch) displays.</term>
/// </item>
/// </list>
/// <para>
/// Images must be 32-bit and of dimensions GetSystemMetrics(SM_CXICON) x GetSystemMetrics(SM_CYICON). The toolbar itself provides visuals for a
/// button's clicked, disabled, and hover states.
/// </para>
/// </remarks>
void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
/// <summary>Applies an overlay to a taskbar button to indicate application status or a notification to the user.</summary>
/// <param name="hwnd">
/// The handle of the window whose associated taskbar button receives the overlay. This handle must belong to a calling process associated with the
/// button's application and must be a valid HWND or the call is ignored.
/// </param>
/// <param name="hIcon">
/// The handle of an icon to use as the overlay. This should be a small icon, measuring 16x16 pixels at 96 dpi. If an overlay icon is already applied
/// to the taskbar button, that existing overlay is replaced.
/// <para>This value can be NULL.How a NULL value is handled depends on whether the taskbar button represents a single window or a group of windows.</para>
/// <list type="bullet">
/// <item>
/// <term>If the taskbar button represents a single window, the overlay icon is removed from the display.</term>
/// </item>
/// <item>
/// <term>
/// If the taskbar button represents a group of windows and a previous overlay is still available (received earlier than the current overlay, but not
/// yet freed by a NULL value), then that previous overlay is displayed in place of the current overlay.
/// </term>
/// </item>
/// </list>
/// <para>
/// It is the responsibility of the calling application to free hIcon when it is no longer needed.This can generally be done after you call
/// SetOverlayIcon because the taskbar makes and uses its own copy of the icon.
/// </para>
/// </param>
/// <param name="pszDescription">
/// A pointer to a string that provides an alt text version of the information conveyed by the overlay, for accessibility purposes.
/// </param>
void SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
/// <summary>
/// Specifies or updates the text of the tooltip that is displayed when the mouse pointer rests on an individual preview thumbnail in a taskbar
/// button flyout.
/// </summary>
/// <param name="hwnd">The handle to the window whose thumbnail displays the tooltip. This handle must belong to the calling process.</param>
/// <param name="pszTip">
/// The pointer to the text to be displayed in the tooltip. This value can be NULL, in which case the title of the window specified by hwnd is used
/// as the tooltip.
/// </param>
void SetThumbnailTooltip(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
/// <summary>Selects a portion of a window's client area to display as that window's thumbnail in the taskbar.</summary>
/// <param name="hwnd">The handle to a window represented in the taskbar.</param>
/// <param name="prcClip">
/// A pointer to a RECT structure that specifies a selection within the window's client area, relative to the upper-left corner of that client area.
/// To clear a clip that is already in place and return to the default display of the thumbnail, set this parameter to NULL.
/// </param>
void SetThumbnailClip(IntPtr hwnd, ref RECT prcClip);
}
/// <summary>Extends ITaskbarList3 by providing a method that allows the caller to control two property values for the tab thumbnail and peek feature.</summary>
/// <seealso cref="ITaskbarList3"/>
[SuppressUnmanagedCodeSecurity]
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf"), CoClass(typeof(CTaskbarList))]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd562040")]
public interface ITaskbarList4 : ITaskbarList3
{
/// <summary>Initializes the taskbar list object. This method must be called before any other ITaskbarList methods can be called.</summary>
new void HrInit();
/// <summary>Adds an item to the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be added to the taskbar.</param>
new void AddTab(IntPtr hwnd);
/// <summary>Deletes an item from the taskbar.</summary>
/// <param name="hwnd">A handle to the window to be deleted from the taskbar.</param>
new void DeleteTab(IntPtr hwnd);
/// <summary>
/// Activates an item on the taskbar. The window is not actually activated; the window's item on the taskbar is merely displayed as active.
/// </summary>
/// <param name="hwnd">A handle to the window on the taskbar to be displayed as active.</param>
new void ActivateTab(IntPtr hwnd);
/// <summary>Marks a taskbar item as active but does not visually activate it.</summary>
/// <param name="hwnd">A handle to the window to be marked as active.</param>
new void SetActiveAlt(IntPtr hwnd);
/// <summary>Marks a window as full-screen.</summary>
/// <param name="hwnd">The handle of the window to be marked.</param>
/// <param name="fFullscreen">A Boolean value marking the desired full-screen status of the window.</param>
new void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen);
/// <summary>Displays or updates a progress bar hosted in a taskbar button to show the specific percentage completed of the full operation.</summary>
/// <param name="hwnd">The handle of the window whose associated taskbar button is being used as a progress indicator.</param>
/// <param name="ullCompleted">
/// An application-defined value that indicates the proportion of the operation that has been completed at the time the method is called.
/// </param>
/// <param name="ullTotal">An application-defined value that specifies the value ullCompleted will have when the operation is complete.</param>
new void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal);
/// <summary>Sets the type and state of the progress indicator displayed on a taskbar button.</summary>
/// <param name="hwnd">
/// The handle of the window in which the progress of an operation is being shown. This window's associated taskbar button will display the progress bar.
/// </param>
/// <param name="tbpFlags">
/// Flags that control the current state of the progress button. Specify only one of the following flags; all states are mutually exclusive of all others.
/// </param>
new void SetProgressState(IntPtr hwnd, TBPFLAG tbpFlags);
/// <summary>Informs the taskbar that a new tab or document thumbnail has been provided for display in an application's taskbar group flyout.</summary>
/// <param name="hwndTab">Handle of the tab or document window. This value is required and cannot be NULL.</param>
/// <param name="hwndMDI">
/// Handle of the application's main window. This value tells the taskbar which application's preview group to attach the new thumbnail to. This
/// value is required and cannot be NULL.
/// </param>
/// <remarks>
/// By itself, registering a tab thumbnail alone will not result in its being displayed. You must also call ITaskbarList3::SetTabOrder to instruct
/// the group where to display it.
/// </remarks>
new void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI);
/// <summary>Removes a thumbnail from an application's preview group when that tab or document is closed in the application.</summary>
/// <param name="hwndTab">
/// The handle of the tab window whose thumbnail is being removed. This is the same value with which the thumbnail was registered as part the group
/// through ITaskbarList3::RegisterTab. This value is required and cannot be NULL.
/// </param>
/// <remarks>
/// It is the responsibility of the calling application to free hwndTab through DestroyWindow. UnregisterTab must be called before the handle is freed.
/// </remarks>
new void UnregisterTab(IntPtr hwndTab);
/// <summary>
/// Inserts a new thumbnail into a tabbed-document interface (TDI) or multiple-document interface (MDI) application's group flyout or moves an
/// existing thumbnail to a new position in the application's group.
/// </summary>
/// <param name="hwndTab">
/// The handle of the tab window whose thumbnail is being placed. This value is required, must already be registered through
/// ITaskbarList3::RegisterTab, and cannot be NULL.
/// </param>
/// <param name="hwndInsertBefore">
/// The handle of the tab window whose thumbnail that hwndTab is inserted to the left of. This handle must already be registered through
/// ITaskbarList3::RegisterTab. If this value is NULL, the new thumbnail is added to the end of the list.
/// </param>
/// <remarks>This method must be called for the thumbnail to be shown in the group. Call it after you have called ITaskbarList3::RegisterTab.</remarks>
new void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore);
/// <summary>Informs the taskbar that a tab or document window has been made the active window.</summary>
/// <param name="hwndTab">
/// Handle of the active tab window. This handle must already be registered through ITaskbarList3::RegisterTab. This value can be NULL if no tab is active.
/// </param>
/// <param name="hwndMDI">
/// Handle of the application's main window. This value tells the taskbar which group the thumbnail is a member of. This value is required and cannot
/// be NULL.
/// </param>
/// <param name="dwReserved">Reserved; set to 0.</param>
new void SetTabActive(IntPtr hwndTab, IntPtr hwndMDI, uint dwReserved);
/// <summary>Adds a thumbnail toolbar with a specified set of buttons to the thumbnail image of a window in a taskbar button flyout.</summary>
/// <param name="hwnd">
/// The handle of the window whose thumbnail representation will receive the toolbar. This handle must belong to the calling process.
/// </param>
/// <param name="cButtons">The number of buttons defined in the array pointed to by pButton. The maximum number of buttons allowed is 7.</param>
/// <param name="pButtons">
/// A pointer to an array of THUMBBUTTON structures. Each THUMBBUTTON defines an individual button to be added to the toolbar. Buttons cannot be
/// added or deleted later, so this must be the full defined set. Buttons also cannot be reordered, so their order in the array, which is the order
/// in which they are displayed left to right, will be their permanent order.
/// </param>
new void ThumbBarAddButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
/// <summary>
/// Shows, enables, disables, or hides buttons in a thumbnail toolbar as required by the window's current state. A thumbnail toolbar is a toolbar
/// embedded in a thumbnail image of a window in a taskbar button flyout.
/// </summary>
/// <param name="hwnd">The handle of the window whose thumbnail representation contains the toolbar.</param>
/// <param name="cButtons">
/// The number of buttons defined in the array pointed to by pButton. The maximum number of buttons allowed is 7. This array contains only structures
/// that represent existing buttons that are being updated.
/// </param>
/// <param name="pButtons">
/// A pointer to an array of THUMBBUTTON structures. Each THUMBBUTTON defines an individual button. If the button already exists (the iId value is
/// already defined), then that existing button is updated with the information provided in the structure.
/// </param>
new void ThumbBarUpdateButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] THUMBBUTTON[] pButtons);
/// <summary>
/// Specifies an image list that contains button images for a toolbar embedded in a thumbnail image of a window in a taskbar button flyout.
/// </summary>
/// <param name="hwnd">
/// The handle of the window whose thumbnail representation contains the toolbar to be updated. This handle must belong to the calling process.
/// </param>
/// <param name="himl">The handle of the image list that contains all button images to be used in the toolbar.</param>
/// <remarks>
/// Applications must provide these button images:
/// <list type="bullet">
/// <item>
/// <term>The button in its default active state.</term>
/// </item>
/// <item>
/// <term>Images suitable for use with high-dpi (dots per inch) displays.</term>
/// </item>
/// </list>
/// <para>
/// Images must be 32-bit and of dimensions GetSystemMetrics(SM_CXICON) x GetSystemMetrics(SM_CYICON). The toolbar itself provides visuals for a
/// button's clicked, disabled, and hover states.
/// </para>
/// </remarks>
new void ThumbBarSetImageList(IntPtr hwnd, IntPtr himl);
/// <summary>Applies an overlay to a taskbar button to indicate application status or a notification to the user.</summary>
/// <param name="hwnd">
/// The handle of the window whose associated taskbar button receives the overlay. This handle must belong to a calling process associated with the
/// button's application and must be a valid HWND or the call is ignored.
/// </param>
/// <param name="hIcon">
/// The handle of an icon to use as the overlay. This should be a small icon, measuring 16x16 pixels at 96 dpi. If an overlay icon is already applied
/// to the taskbar button, that existing overlay is replaced.
/// <para>This value can be NULL.How a NULL value is handled depends on whether the taskbar button represents a single window or a group of windows.</para>
/// <list type="bullet">
/// <item>
/// <term>If the taskbar button represents a single window, the overlay icon is removed from the display.</term>
/// </item>
/// <item>
/// <term>
/// If the taskbar button represents a group of windows and a previous overlay is still available (received earlier than the current overlay, but not
/// yet freed by a NULL value), then that previous overlay is displayed in place of the current overlay.
/// </term>
/// </item>
/// </list>
/// <para>
/// It is the responsibility of the calling application to free hIcon when it is no longer needed.This can generally be done after you call
/// SetOverlayIcon because the taskbar makes and uses its own copy of the icon.
/// </para>
/// </param>
/// <param name="pszDescription">
/// A pointer to a string that provides an alt text version of the information conveyed by the overlay, for accessibility purposes.
/// </param>
new void SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszDescription);
/// <summary>
/// Specifies or updates the text of the tooltip that is displayed when the mouse pointer rests on an individual preview thumbnail in a taskbar
/// button flyout.
/// </summary>
/// <param name="hwnd">The handle to the window whose thumbnail displays the tooltip. This handle must belong to the calling process.</param>
/// <param name="pszTip">
/// The pointer to the text to be displayed in the tooltip. This value can be NULL, in which case the title of the window specified by hwnd is used
/// as the tooltip.
/// </param>
new void SetThumbnailTooltip(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTip);
/// <summary>Selects a portion of a window's client area to display as that window's thumbnail in the taskbar.</summary>
/// <param name="hwnd">The handle to a window represented in the taskbar.</param>
/// <param name="prcClip">
/// A pointer to a RECT structure that specifies a selection within the window's client area, relative to the upper-left corner of that client area.
/// To clear a clip that is already in place and return to the default display of the thumbnail, set this parameter to NULL.
/// </param>
new void SetThumbnailClip(IntPtr hwnd, ref RECT prcClip);
/// <summary>
/// Allows a tab to specify whether the main application frame window or the tab window should be used as a thumbnail or in the peek feature under
/// certain circumstances.
/// </summary>
/// <param name="hwndTab">The handle of the tab window that is to have properties set. This handle must already be registered through RegisterTab.</param>
/// <param name="stpFlags">
/// One or more members of the STPFLAG enumeration that specify the displayed thumbnail and peek image source of the tab thumbnail.
/// </param>
void SetTabProperties(IntPtr hwndTab, STPFLAG stpFlags);
}
/// <summary>Used by methods of the ITaskbarList3 interface to define buttons used in a toolbar embedded in a window's thumbnail representation.</summary>
[StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)]
[PInvokeData("Shobjidl.h", MSDNShortId = "dd391559")]
public struct THUMBBUTTON
{
/// <summary>The THBN clicked</summary>
public const int THBN_CLICKED = 0x1800;
/// <summary>
/// A combination of THUMBBUTTONMASK values that specify which members of this structure contain valid data; other members are ignored, with the
/// exception of iId, which is always required.
/// </summary>
public THUMBBUTTONMASK dwMask;
/// <summary>The application-defined identifier of the button, unique within the toolbar.</summary>
public uint iId;
/// <summary>The zero-based index of the button image within the image list set through ITaskbarList3::ThumbBarSetImageList.</summary>
public uint iBitmap;
/// <summary>The handle of an icon to use as the button image.</summary>
public IntPtr hIcon;
/// <summary>A wide character array that contains the text of the button's tooltip, displayed when the mouse pointer hovers over the button.</summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szTip;
/// <summary>A combination of THUMBBUTTONFLAGS values that control specific states and behaviors of the button.</summary>
public THUMBBUTTONFLAGS dwFlags;
/// <summary>The default</summary>
public static THUMBBUTTON Default = new THUMBBUTTON { dwMask = THUMBBUTTONMASK.THB_FLAGS, dwFlags = THUMBBUTTONFLAGS.THBF_HIDDEN };
}
/// <summary>Class interface for ICustomDestinationList.</summary>
[ComImport, Guid("77f10cf0-3db5-4966-b520-b7c54fd35ed6"), ClassInterface(ClassInterfaceType.None)]
public class CDestinationList { }
/// <summary>Class interface for ITaskbarList and derivatives.</summary>
[ComImport, Guid("56FDF344-FD6D-11d0-958A-006097C9A090"), ClassInterface(ClassInterfaceType.None)]
public class CTaskbarList { }
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
// 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
{
public static partial class Shell32
{
/// <remarks>Methods in this class will only work on Vista and above.</remarks>
public static class ShellUtil
{
/// <summary>Gets the KNOWNFOLDERID enum from a KNOWNFOLDERID Guid.</summary>
/// <param name="knownFolder">The KNOWNFOLDERID Guid.</param>
/// <returns>The KNOWNFOLDERID enum.</returns>
public static KNOWNFOLDERID GetKnownFolderFromGuid(Guid knownFolder) =>
Enum.GetValues(typeof(KNOWNFOLDERID)).Cast<KNOWNFOLDERID>().Single(k => k.Guid() == knownFolder);
/// <summary>Gets the KNOWNFOLDERID enum from a path.</summary>
/// <param name="path">The folder path.</param>
/// <returns>The KNOWNFOLDERID enum.</returns>
public static KNOWNFOLDERID GetKnownFolderFromPath(string path)
{
if (Environment.OSVersion.Version.Major < 6)
return Enum.GetValues(typeof(KNOWNFOLDERID)).Cast<KNOWNFOLDERID>().Single(k => string.Equals(k.FullPath(), path, StringComparison.InvariantCultureIgnoreCase));
var ikfm = new IKnownFolderManager();
return GetKnownFolderFromGuid(ikfm.FindFolderFromPath(path, FFFP_MODE.FFFP_EXACTMATCH).GetId());
}
/// <summary>Gets the path for a KNOWNFOLDERID Guid.</summary>
/// <param name="knownFolder">The KNOWNFOLDERID Guid.</param>
/// <returns>The file system path.</returns>
[SecurityCritical]
public static string GetPathForKnownFolder(Guid knownFolder)
{
if (knownFolder == default(Guid))
return null;
var pathBuilder = new StringBuilder(260);
try { SHGetFolderPathEx(knownFolder, 0, null, pathBuilder, (uint)pathBuilder.Capacity); }
catch { return null; }
return pathBuilder.ToString();
}
/// <summary>Gets the path from shell item.</summary>
/// <param name="item">The shell item.</param>
/// <returns>The file system path.</returns>
[SecurityCritical]
public static string GetPathFromShellItem(IShellItem item) => item.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEEDITING);
/// <summary>Gets the shell item for a file system path.</summary>
/// <returns>The file system path.</returns>
/// <returns>The corresponding IShellItem.</returns>
[SecurityCritical]
public static IShellItem GetShellItemForPath(string path)
{
if (string.IsNullOrEmpty(path))
return null;
SHCreateItemFromParsingName(path, null, Marshal.GenerateGuidForType(typeof(IShellItem)), out object unk);
return (IShellItem)unk;
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,10 @@ using System.Runtime.InteropServices;
using Vanara.Extensions;
using Vanara.InteropServices;
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable FieldCanBeMadeReadOnly.Global
// ReSharper disable UnusedMember.Global
namespace Vanara.PInvoke
{
public static partial class Shell32
@ -21,18 +25,6 @@ namespace Vanara.PInvoke
STRRET_CSTR = 0x0002,
}
/// <summary>Used generically to filter elements.</summary>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
[PInvokeData("Shtypes.h", MSDNShortId = "bb773221")]
public struct COMDLG_FILTERSPEC
{
/// <summary>A pointer to a buffer that contains the friendly name of the filter.</summary>
public string pszName;
/// <summary>A pointer to a buffer that contains the filter pattern.</summary>
public string pszSpec;
}
/// <summary>Contains a list of item identifiers.</summary>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("Shtypes.h", MSDNShortId = "bb773321")]
@ -42,6 +34,7 @@ namespace Vanara.PInvoke
public SHITEMID mkid;
}
/// <summary>Defines an item identifier.</summary>
[StructLayout(LayoutKind.Sequential)]
[PInvokeData("Shtypes.h", MSDNShortId = "bb759800")]
public struct SHITEMID
@ -95,7 +88,6 @@ namespace Vanara.PInvoke
if (pNativeData == IntPtr.Zero) return;
pNativeData.ToStructure<STRRET>().pOleStr.Free();
Marshal.FreeCoTaskMem(pNativeData);
pNativeData = IntPtr.Zero;
}
public int GetNativeDataSize() => Marshal.SizeOf(typeof(STRRET));

View File

@ -1,7 +1,5 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Security;
using System.Text;
using Vanara.InteropServices;
@ -9,8 +7,13 @@ using static Vanara.PInvoke.AdvApi32;
using static Vanara.PInvoke.ComCtl32;
using static Vanara.PInvoke.Kernel32;
// 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
{
@ -20,64 +23,6 @@ namespace Vanara.PInvoke
// Defined in wingdi.h
private const int LF_FACESIZE = 32;
/// <summary>Specify special retrieval options for known folders. These values supersede CSIDL values, which have parallel meanings.</summary>
[Flags]
[PInvokeData("Shlobj.h", MSDNShortId = "dd378447")]
public enum KNOWN_FOLDER_FLAG : uint
{
/// <summary>No flags.</summary>
KF_FLAG_DEFAULT = 0x00000000,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_SIMPLE_IDLIST = 0x00000100,
/// <summary>Gets the folder's default path independent of the current location of its parent. KF_FLAG_DEFAULT_PATH must also be set.</summary>
KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_DEFAULT_PATH = 0x00000400,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_INIT = 0x00000800,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_NO_ALIAS = 0x00001000,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_DONT_UNEXPAND = 0x00002000,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_DONT_VERIFY = 0x00004000,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_CREATE = 0x00008000,
/// <summary>
/// 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.
/// </summary>
KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000,
/// <summary>Introduced in Windows 7. Return only aliased PIDLs. Do not use the file system path.</summary>
KF_FLAG_ALIAS_ONLY = 0x80000000
}
/// <summary>Used for options in SHOpenFolderAndSelectItems.</summary>
[PInvokeData("Shlobj.h", MSDNShortId = "bb762232")]
public enum OFASI
@ -152,113 +97,6 @@ namespace Vanara.PInvoke
SHARD_SHELLITEM = 8
}
/// <summary>Specifies option settings. Used with IShellLinkDataList::GetFlags and IShellLinkDataList::SetFlags.</summary>
[PInvokeData("Shlobj.h", MSDNShortId = "bb762540")]
[Flags]
public enum SHELL_LINK_DATA_FLAGS : uint
{
/// <summary>Default value used when no other flag is explicitly set.</summary>
SLDF_DEFAULT = 0x00000000,
/// <summary>The Shell link was saved with an ID list.</summary>
SLDF_HAS_ID_LIST = 0x00000001,
/// <summary>
/// The Shell link was saved with link information to enable distributed tracking. This information is used by .lnk files to locate the target if the
/// targets's path has changed. It includes information such as volume label and serial number, although the specific stored information can change
/// from release to release.
/// </summary>
SLDF_HAS_LINK_INFO = 0x00000002,
/// <summary>The link has a name.</summary>
SLDF_HAS_NAME = 0x00000004,
/// <summary>The link has a relative path.</summary>
SLDF_HAS_RELPATH = 0x00000008,
/// <summary>The link has a working directory.</summary>
SLDF_HAS_WORKINGDIR = 0x00000010,
/// <summary>The link has arguments.</summary>
SLDF_HAS_ARGS = 0x00000020,
/// <summary>The link has an icon location.</summary>
SLDF_HAS_ICONLOCATION = 0x00000040,
/// <summary>Stored strings are Unicode.</summary>
SLDF_UNICODE = 0x00000080,
/// <summary>
/// Prevents the storage of link tracking information. If this flag is set, it is less likely, though not impossible, that a target can be found by
/// the link if that target is moved.
/// </summary>
SLDF_FORCE_NO_LINKINFO = 0x00000100,
/// <summary>The link contains expandable environment strings such as %windir%.</summary>
SLDF_HAS_EXP_SZ = 0x00000200,
/// <summary>Causes a 16-bit target application to run in a separate Virtual DOS Machine (VDM)/Windows on Windows (WOW).</summary>
SLDF_RUN_IN_SEPARATE = 0x00000400,
/// <summary>Not supported. Note that as of Windows Vista, this value is no longer defined.</summary>
SLDF_HAS_LOGO3ID = 0x00000800,
/// <summary>The link is a special Windows Installer link.</summary>
SLDF_HAS_DARWINID = 0x00001000,
/// <summary>Causes the target application to run as a different user.</summary>
SLDF_RUNAS_USER = 0x00002000,
/// <summary>The icon path in the link contains an expandable environment string such as such as %windir%.</summary>
SLDF_HAS_EXP_ICON_SZ = 0x00004000,
/// <summary>Prevents the use of ID list alias mapping when parsing the ID list from the path.</summary>
SLDF_NO_PIDL_ALIAS = 0x00008000,
/// <summary>Forces the use of the UNC name (a full network resource name), rather than the local name.</summary>
SLDF_FORCE_UNCNAME = 0x00010000,
/// <summary>
/// Causes the target of this link to launch with a shim layer active. A shim is an intermediate DLL that facilitates compatibility between otherwise
/// incompatible software services. Shims are typically used to provide version compatibility.
/// </summary>
SLDF_RUN_WITH_SHIMLAYER = 0x00020000,
/// <summary>Introduced in Windows Vista. Disable object ID distributed tracking information.</summary>
SLDF_FORCE_NO_LINKTRACK = 0x00040000,
/// <summary>Introduced in Windows Vista. Enable the caching of target metadata into the link file.</summary>
SLDF_ENABLE_TARGET_METADATA = 0x000800000,
/// <summary>Introduced in Windows 7. Disable shell link tracking.</summary>
SLDF_DISABLE_LINK_PATH_TRACKING = 0x00100000,
/// <summary>Introduced in Windows Vista. Disable known folder tracking information.</summary>
SLDF_DISABLE_KNOWNFOLDER_RELATIVE_TRACKING = 0x00200000,
/// <summary>Introduced in Windows 7. Disable known folder alias mapping when loading the IDList during deserialization.</summary>
SLDF_NO_KF_ALIAS = 0x00400000,
/// <summary>Introduced in Windows 7. Allow link to point to another shell link as long as this does not create cycles.</summary>
SLDF_ALLOW_LINK_TO_LINK = 0x00800000,
/// <summary>Introduced in Windows 7. Remove alias when saving the IDList.</summary>
SLDF_UNALIAS_ON_SAVE = 0x01000000,
/// <summary>
/// Introduced in Windows 7. Recalculate the IDList from the path with the environmental variables at load time, rather than persisting the IDList.
/// </summary>
SLDF_PREFER_ENVIRONMENT_PATH = 0x02000000,
/// <summary>
/// Introduced in Windows 7. If the target is a UNC location on a local machine, keep the local IDList target in addition to the remote target.
/// </summary>
SLDF_KEEP_LOCAL_IDLIST_FOR_UNC_TARGET = 0x04000000,
/// <summary>Introduced in Windows 8. Persist the target IDlist in its volume-ID-relative form to avoid a dependency on drive letters.</summary>
SLDF_PERSIST_VOLUME_ID_RELATIVE = 0x08000000,
}
/// <summary>Receives a value that determines what type the item is in <see cref="SHDESCRIPTIONID"/>.</summary>
[PInvokeData("Shlobj_core.h", MSDNShortId = "bb759775")]
public enum SHDID
@ -307,6 +145,7 @@ namespace Vanara.PInvoke
SHDID_MOBILE_DEVICE = 21,
}
/// <summary>The format in which the data is being requested.</summary>
[PInvokeData("Shlobj.h", MSDNShortId = "bb762174")]
public enum SHGetDataFormat
{