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.
FileDialogsCOMClasses.cs
Download fileToto je zdrojový kód souboru FileDialogsCOMClasses.cs
Helper P/Invoke Vista API COM interface interop for Common Dialogs.
using System; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Runtime.InteropServices.ComTypes; namespace IMP.Windows.Interop { #region HRESULT, PropertyKey /// <summary> /// HRESULT Wrapper /// This is intended for Library Internal use only. /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "HRESULT"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32", Justification = "The base type for all of these value is uint")] internal enum HRESULT : uint { /// <summary> /// S_FALSE /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "FALSE")] S_FALSE = 0x0001, /// <summary> /// S_OK /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "OK")] S_OK = 0x0000, /// <summary> /// E_INVALIDARG /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "INVALIDARG")] E_INVALIDARG = 0x80070057, /// <summary> /// E_OUTOFMEMORY /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "OUTOFMEMORY")] E_OUTOFMEMORY = 0x8007000E, /// <summary> /// E_NOINTERFACE /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "NOINTERFACE")] E_NOINTERFACE = 0x80004002, /// <summary> /// E_FAIL /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "FAIL")] E_FAIL = 0x80004005, /// <summary> /// E_ELEMENTNOTFOUND /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ELEMENTNOTFOUND")] E_ELEMENTNOTFOUND = 0x80070490, /// <summary> /// TYPE_E_ELEMENTNOTFOUND /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "TYPE")] TYPE_E_ELEMENTNOTFOUND = 0x8002802B, /// <summary> /// NO_OBJECT /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "NO_OBJECT")] NO_OBJECT = 0x800401E5, /// <summary> /// Win32 Error code: ERROR_CANCELLED /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ERROR")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CANCELLED")] ERROR_CANCELLED = 1223, /// <summary> /// ERROR_CANCELLED /// </summary> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ERROR")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CANCELLED")] E_ERROR_CANCELLED = 0x800704C7, /// <summary> /// The requested resource is in use /// </summary> RESOURCE_IN_USE = 0x800700AA, } [StructLayout(LayoutKind.Sequential, Pack = 4)] internal struct PropertyKey { internal Guid fmtid; internal uint pid; } #endregion #region IModalWindow, IShellItem, IShellItemArray, IShellFolder [ComImport(), Guid("B4DB1657-70D7-485E-8E3E-6FCB5A5C1802"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IModalWindow { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] int Show([In] IntPtr parent); } [ComImport, Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IShellItem { // Not supported: IBindCtx [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void BindToHandler([In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid bhid, [In] ref Guid riid, out IntPtr ppv); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetParent([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetDisplayName([In] CommonDialogNativeMethods.SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetAttributes([In] uint sfgaoMask, out uint psfgaoAttribs); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void Compare([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In] uint hint, out int piOrder); } [ComImport, Guid("B63EA76D-1F85-456F-A19C-48159EFA858B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IShellItemArray { // Not supported: IBindCtx. [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT BindToHandler( [In, MarshalAs(UnmanagedType.Interface)] IntPtr pbc, [In] ref Guid rbhid, [In] ref Guid riid, out IntPtr ppvOut); [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT GetPropertyStore( [In] int Flags, [In] ref Guid riid, out IntPtr ppv); [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT GetPropertyDescriptionList( [In] ref PropertyKey keyType, [In] ref Guid riid, out IntPtr ppv); [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT GetAttributes( [In] CommonDialogNativeMethods.SIATTRIBFLAGS dwAttribFlags, [In] CommonDialogNativeMethods.SFGAO sfgaoMask, out CommonDialogNativeMethods.SFGAO psfgaoAttribs); [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT GetCount(out uint pdwNumItems); [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT GetItemAt( [In] uint dwIndex, [MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); // Not supported: IEnumShellItems (will use GetCount and GetItemAt instead). [PreserveSig] [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] HRESULT EnumItems([MarshalAs(UnmanagedType.Interface)] out IntPtr ppenumShellItems); } #endregion #region IFileDialog, IFileDialogEvents [ComImport(), Guid("42F85136-DB7E-439C-85F1-E4075D135FC8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IFileDialog : IModalWindow { // Defined on IModalWindow - repeated here due to requirements of COM interop layer. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] new int Show([In] IntPtr parent); // IFileDialog-Specific interface members. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileTypes( [In] uint cFileTypes, [In, MarshalAs(UnmanagedType.LPArray)] CommonDialogNativeMethods.COMDLG_FILTERSPEC[] rgFilterSpec); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileTypeIndex([In] uint iFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetFileTypeIndex(out uint piFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void Advise( [In, MarshalAs(UnmanagedType.Interface)] IFileDialogEvents pfde, out uint pdwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void Unadvise([In] uint dwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetOptions([In] CommonDialogNativeMethods.FOS fos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetOptions(out CommonDialogNativeMethods.FOS pfos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileName([In, MarshalAs(UnmanagedType.LPWStr)] string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetTitle([In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetOkButtonLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszText); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileNameLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void AddPlace([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, CommonDialogNativeMethods.FDAP fdap); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetDefaultExtension([In, MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void Close([MarshalAs(UnmanagedType.Error)] int hr); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetClientGuid([In] ref Guid guid); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void ClearClientData(); // Not supported: IShellItemFilter is not defined, converting to IntPtr. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter); } [ComImport, Guid("973510DB-7D7F-452B-8975-74A85828D354"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IFileDialogEvents { // NOTE: some of these callbacks are cancelable - returning S_FALSE means that // the dialog should not proceed (e.g. with closing, changing folder); to // support this, we need to use the PreserveSig attribute to enable us to return // the proper HRESULT. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] HRESULT OnFileOk([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] HRESULT OnFolderChanging( [In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psiFolder); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void OnFolderChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void OnSelectionChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void OnShareViolation( [In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, out CommonDialogNativeMethods.FDE_SHAREVIOLATION_RESPONSE pResponse); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void OnTypeChange([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void OnOverwrite([In, MarshalAs(UnmanagedType.Interface)] IFileDialog pfd, [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, out CommonDialogNativeMethods.FDE_OVERWRITE_RESPONSE pResponse); } #endregion #region IFileOpenDialog [ComImport(), Guid("D57C7288-D4AD-4768-BE02-9D969532D960"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IFileOpenDialog : IFileDialog { // Defined on IModalWindow - repeated here due to requirements of COM interop layer. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] new int Show([In] IntPtr parent); // Defined on IFileDialog - repeated here due to requirements of COM interop layer. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileTypes([In] uint cFileTypes, [In] ref CommonDialogNativeMethods.COMDLG_FILTERSPEC rgFilterSpec); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileTypeIndex([In] uint iFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFileTypeIndex(out uint piFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Advise( [In, MarshalAs(UnmanagedType.Interface)] IFileDialogEvents pfde, out uint pdwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Unadvise([In] uint dwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetOptions([In] CommonDialogNativeMethods.FOS fos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetOptions(out CommonDialogNativeMethods.FOS pfos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileName([In, MarshalAs(UnmanagedType.LPWStr)] string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetTitle([In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetOkButtonLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszText); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileNameLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void AddPlace([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, CommonDialogNativeMethods.FDAP fdap); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetDefaultExtension([In, MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Close([MarshalAs(UnmanagedType.Error)] int hr); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetClientGuid([In] ref Guid guid); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void ClearClientData(); // Not supported: IShellItemFilter is not defined, converting to IntPtr. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter); // Defined by IFileOpenDialog. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetResults([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppenum); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetSelectedItems([MarshalAs(UnmanagedType.Interface)] out IShellItemArray ppsai); } #endregion #region IFileSaveDialog [ComImport(), Guid("84BCCD23-5FDE-4CDB-AEA4-AF64B83D78AB"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IFileSaveDialog : IFileDialog { // Defined on IModalWindow - repeated here due to requirements of COM interop layer. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), PreserveSig] new int Show([In] IntPtr parent); // Defined on IFileDialog - repeated here due to requirements of COM interop layer. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetFileTypes( [In] uint cFileTypes, [In] ref CommonDialogNativeMethods.COMDLG_FILTERSPEC rgFilterSpec); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileTypeIndex([In] uint iFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFileTypeIndex(out uint piFileType); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Advise( [In, MarshalAs(UnmanagedType.Interface)] IFileDialogEvents pfde, out uint pdwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Unadvise([In] uint dwCookie); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetOptions([In] CommonDialogNativeMethods.FOS fos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetOptions(out CommonDialogNativeMethods.FOS pfos); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetDefaultFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFolder([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFolder([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetCurrentSelection([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileName([In, MarshalAs(UnmanagedType.LPWStr)] string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetFileName([MarshalAs(UnmanagedType.LPWStr)] out string pszName); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetTitle([In, MarshalAs(UnmanagedType.LPWStr)] string pszTitle); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetOkButtonLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszText); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFileNameLabel([In, MarshalAs(UnmanagedType.LPWStr)] string pszLabel); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void GetResult([MarshalAs(UnmanagedType.Interface)] out IShellItem ppsi); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void AddPlace( [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, CommonDialogNativeMethods.FDAP fdap); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetDefaultExtension([In, MarshalAs(UnmanagedType.LPWStr)] string pszDefaultExtension); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void Close([MarshalAs(UnmanagedType.Error)] int hr); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetClientGuid([In] ref Guid guid); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void ClearClientData(); // Not supported: IShellItemFilter is not defined, converting to IntPtr. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] new void SetFilter([MarshalAs(UnmanagedType.Interface)] IntPtr pFilter); // Defined by IFileSaveDialog interface. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetSaveAsItem([In, MarshalAs(UnmanagedType.Interface)] IShellItem psi); // Not currently supported: IPropertyStore [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetProperties([In, MarshalAs(UnmanagedType.Interface)] IntPtr pStore); // Not currently supported: IPropertyDescriptionList [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetCollectedProperties([In, MarshalAs(UnmanagedType.Interface)] IntPtr pList, [In] int fAppendDefault); // Not currently supported: IPropertyStore [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetProperties([MarshalAs(UnmanagedType.Interface)] out IntPtr ppStore); // Not currently supported: IPropertyStore, IFileOperationProgressSink. [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void ApplyProperties( [In, MarshalAs(UnmanagedType.Interface)] IShellItem psi, [In, MarshalAs(UnmanagedType.Interface)] IntPtr pStore, [In, ComAliasName("ShellObjects.wireHWND")] ref IntPtr hwnd, [In, MarshalAs(UnmanagedType.Interface)] IntPtr pSink); } #endregion [ComImport, Guid("D57C7288-D4AD-4768-BE02-9D969532D960"), CoClass(typeof(FileOpenDialogRCW))] internal interface NativeFileOpenDialog : IFileOpenDialog { } [ComImport, Guid("84BCCD23-5FDE-4CDB-AEA4-AF64B83D78AB"), CoClass(typeof(FileSaveDialogRCW))] internal interface NativeFileSaveDialog : IFileSaveDialog { } // .NET classes representing runtime callable wrappers. [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7")] internal class FileOpenDialogRCW { } [ComImport, ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FCanCreate), Guid("C0B4E2F3-BA21-4773-8DBA-335EC946EB8B")] internal class FileSaveDialogRCW { } }