Je vyžadována podpora jazyka JavaScript
Některé stránky na tomto webu vyžadují podporu jazyka JavaScript. Váš webový prohlížeč jazyk JavaScript nepodporuje nebo jazyk JavaScript není povolen.
Chcete-li zjistit, zda webový prohlížeč podporuje jazyk JavaScript nebo jazyk JavaScript chcete povolit, přečtěte si nápovědu k vašemu webovému prohlížeči.
CommonDialogNativeMethods.cs
Download fileToto je zdrojový kód souboru CommonDialogNativeMethods.cs
Helper Vista API imports and types for Common Dialogs.
using System;
using System.Runtime.InteropServices;
namespace IMP.Windows.Interop
{
internal class CommonDialogNativeMethods
{
#region extern methods
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetActiveWindow();
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
public static extern int SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IntPtr pbc, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv);
#endregion
#region Shell Enums
[Flags]
internal enum FOS : uint
{
FOS_OVERWRITEPROMPT = 0x00000002,
FOS_STRICTFILETYPES = 0x00000004,
FOS_NOCHANGEDIR = 0x00000008,
FOS_PICKFOLDERS = 0x00000020,
// Ensure that items returned are filesystem items.
FOS_FORCEFILESYSTEM = 0x00000040,
// Allow choosing items that have no storage.
FOS_ALLNONSTORAGEITEMS = 0x00000080,
FOS_NOVALIDATE = 0x00000100,
FOS_ALLOWMULTISELECT = 0x00000200,
FOS_PATHMUSTEXIST = 0x00000800,
FOS_FILEMUSTEXIST = 0x00001000,
FOS_CREATEPROMPT = 0x00002000,
FOS_SHAREAWARE = 0x00004000,
FOS_NOREADONLYRETURN = 0x00008000,
FOS_NOTESTFILECREATE = 0x00010000,
FOS_HIDEMRUPLACES = 0x00020000,
FOS_HIDEPINNEDPLACES = 0x00040000,
FOS_NODEREFERENCELINKS = 0x00100000,
FOS_DONTADDTORECENT = 0x02000000,
FOS_FORCESHOWHIDDEN = 0x10000000,
FOS_DEFAULTNOMINIMODE = 0x20000000
}
internal enum SIGDN : uint
{
SIGDN_NORMALDISPLAY = 0x00000000, // SHGDN_NORMAL
SIGDN_PARENTRELATIVEPARSING = 0x80018001, // SHGDN_INFOLDER | SHGDN_FORPARSING
SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, // SHGDN_FORPARSING
SIGDN_PARENTRELATIVEEDITING = 0x80031001, // SHGDN_INFOLDER | SHGDN_FOREDITING
SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, // SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
SIGDN_FILESYSPATH = 0x80058000, // SHGDN_FORPARSING
SIGDN_URL = 0x80068000, // SHGDN_FORPARSING
SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, // SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR
SIGDN_PARENTRELATIVE = 0x80080001 // SHGDN_INFOLDER
}
internal enum SIATTRIBFLAGS
{
// if multiple items and the attirbutes together.
SIATTRIBFLAGS_AND = 0x00000001,
// if multiple items or the attributes together.
SIATTRIBFLAGS_OR = 0x00000002,
// Call GetAttributes directly on the
// ShellFolder for multiple attributes.
SIATTRIBFLAGS_APPCOMPAT = 0x00000003,
}
internal enum FDE_SHAREVIOLATION_RESPONSE
{
FDESVR_DEFAULT = 0x00000000,
FDESVR_ACCEPT = 0x00000001,
FDESVR_REFUSE = 0x00000002
}
internal enum FDE_OVERWRITE_RESPONSE
{
FDEOR_DEFAULT = 0x00000000,
FDEOR_ACCEPT = 0x00000001,
FDEOR_REFUSE = 0x00000002
}
internal enum FDAP
{
FDAP_BOTTOM = 0x00000000,
FDAP_TOP = 0x00000001,
}
[Flags]
internal enum SFGAO : uint
{
/// <summary>
/// The specified items can be copied.
/// </summary>
SFGAO_CANCOPY = 0x00000001,
/// <summary>
/// The specified items can be moved.
/// </summary>
SFGAO_CANMOVE = 0x00000002,
/// <summary>
/// Shortcuts can be created for the specified items. This flag has the same value as DROPEFFECT.
/// The normal use of this flag is to add a Create Shortcut item to the shortcut menu that is displayed
/// during drag-and-drop operations. However, SFGAO_CANLINK also adds a Create Shortcut item to the Microsoft
/// Windows Explorer's File menu and to normal shortcut menus.
/// If this item is selected, your application's IContextMenu::InvokeCommand is invoked with the lpVerb
/// member of the CMINVOKECOMMANDINFO structure set to "link." Your application is responsible for creating the link.
/// </summary>
SFGAO_CANLINK = 0x00000004,
/// <summary>
/// The specified items can be bound to an IStorage interface through IShellFolder::BindToObject.
/// </summary>
SFGAO_STORAGE = 0x00000008,
/// <summary>
/// The specified items can be renamed.
/// </summary>
SFGAO_CANRENAME = 0x00000010,
/// <summary>
/// The specified items can be deleted.
/// </summary>
SFGAO_CANDELETE = 0x00000020,
/// <summary>
/// The specified items have property sheets.
/// </summary>
SFGAO_HASPROPSHEET = 0x00000040,
/// <summary>
/// The specified items are drop targets.
/// </summary>
SFGAO_DROPTARGET = 0x00000100,
/// <summary>
/// This flag is a mask for the capability flags.
/// </summary>
SFGAO_CAPABILITYMASK = 0x00000177,
/// <summary>
/// Windows 7 and later. The specified items are system items.
/// </summary>
SFGAO_SYSTEM = 0x00001000,
/// <summary>
/// The specified items are encrypted.
/// </summary>
SFGAO_ENCRYPTED = 0x00002000,
/// <summary>
/// Indicates that accessing the object = through IStream or other storage interfaces,
/// is a slow operation.
/// Applications should avoid accessing items flagged with SFGAO_ISSLOW.
/// </summary>
SFGAO_ISSLOW = 0x00004000,
/// <summary>
/// The specified items are ghosted icons.
/// </summary>
SFGAO_GHOSTED = 0x00008000,
/// <summary>
/// The specified items are shortcuts.
/// </summary>
SFGAO_LINK = 0x00010000,
/// <summary>
/// The specified folder objects are shared.
/// </summary>
SFGAO_SHARE = 0x00020000,
/// <summary>
/// The specified items are read-only. In the case of folders, this means
/// that new items cannot be created in those folders.
/// </summary>
SFGAO_READONLY = 0x00040000,
/// <summary>
/// The item is hidden and should not be displayed unless the
/// Show hidden files and folders option is enabled in Folder Settings.
/// </summary>
SFGAO_HIDDEN = 0x00080000,
/// <summary>
/// This flag is a mask for the display attributes.
/// </summary>
SFGAO_DISPLAYATTRMASK = 0x000FC000,
/// <summary>
/// The specified folders contain one or more file system folders.
/// </summary>
SFGAO_FILESYSANCESTOR = 0x10000000,
/// <summary>
/// The specified items are folders.
/// </summary>
SFGAO_FOLDER = 0x20000000,
/// <summary>
/// The specified folders or file objects are part of the file system
/// that is, they are files, directories, or root directories).
/// </summary>
SFGAO_FILESYSTEM = 0x40000000,
/// <summary>
/// The specified folders have subfolders = and are, therefore,
/// expandable in the left pane of Windows Explorer).
/// </summary>
SFGAO_HASSUBFOLDER = 0x80000000,
/// <summary>
/// This flag is a mask for the contents attributes.
/// </summary>
SFGAO_CONTENTSMASK = 0x80000000,
/// <summary>
/// When specified as input, SFGAO_VALIDATE instructs the folder to validate that the items
/// pointed to by the contents of apidl exist. If one or more of those items do not exist,
/// IShellFolder::GetAttributesOf returns a failure code.
/// When used with the file system folder, SFGAO_VALIDATE instructs the folder to discard cached
/// properties retrieved by clients of IShellFolder2::GetDetailsEx that may
/// have accumulated for the specified items.
/// </summary>
SFGAO_VALIDATE = 0x01000000,
/// <summary>
/// The specified items are on removable media or are themselves removable devices.
/// </summary>
SFGAO_REMOVABLE = 0x02000000,
/// <summary>
/// The specified items are compressed.
/// </summary>
SFGAO_COMPRESSED = 0x04000000,
/// <summary>
/// The specified items can be browsed in place.
/// </summary>
SFGAO_BROWSABLE = 0x08000000,
/// <summary>
/// The items are nonenumerated items.
/// </summary>
SFGAO_NONENUMERATED = 0x00100000,
/// <summary>
/// The objects contain new content.
/// </summary>
SFGAO_NEWCONTENT = 0x00200000,
/// <summary>
/// It is possible to create monikers for the specified file objects or folders.
/// </summary>
SFGAO_CANMONIKER = 0x00400000,
/// <summary>
/// Not supported.
/// </summary>
SFGAO_HASSTORAGE = 0x00400000,
/// <summary>
/// Indicates that the item has a stream associated with it that can be accessed
/// by a call to IShellFolder::BindToObject with IID_IStream in the riid parameter.
/// </summary>
SFGAO_STREAM = 0x00400000,
/// <summary>
/// Children of this item are accessible through IStream or IStorage.
/// Those children are flagged with SFGAO_STORAGE or SFGAO_STREAM.
/// </summary>
SFGAO_STORAGEANCESTOR = 0x00800000,
/// <summary>
/// This flag is a mask for the storage capability attributes.
/// </summary>
SFGAO_STORAGECAPMASK = 0x70C50008,
/// <summary>
/// Mask used by PKEY_SFGAOFlags to remove certain values that are considered
/// to cause slow calculations or lack context.
/// Equal to SFGAO_VALIDATE | SFGAO_ISSLOW | SFGAO_HASSUBFOLDER.
/// </summary>
SFGAO_PKEYSFGAOMASK = 0x81044000,
}
#endregion
#region Shell Structs
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct COMDLG_FILTERSPEC
{
[MarshalAs(UnmanagedType.LPWStr)]
internal string pszName;
[MarshalAs(UnmanagedType.LPWStr)]
internal string pszSpec;
internal COMDLG_FILTERSPEC(string name, string spec)
{
pszName = name;
pszSpec = spec;
}
}
#endregion
}
}