예제 #1
0
 /// <summary>Requests an object that can be used to obtain information from or interact with a folder object.</summary>
 /// <typeparam name="TInterface">The interface to retrieve, typically IShellView.</typeparam>
 /// <param name="parentWindow">The owner window.</param>
 /// <returns>The interface pointer requested.</returns>
 public TInterface GetViewObject <TInterface>(System.Windows.Forms.IWin32Window parentWindow) where TInterface : class
 {
     try
     {
         return(iShellFolder.CreateViewObject(IWin2Ptr(parentWindow), typeof(TInterface).GUID) as TInterface);
     }
     catch (InvalidCastException e)
     {
         throw new NotImplementedException(null, e);
     }
 }
예제 #2
0
    //==========================================================
    //renvoie une instance de l'interface d'extraction d'icône pour item
    //==========================================================
    //IN item : instance de IShellFolder depuis laquelle on extrait l'extracteur d'icône
    //IN pidl : pointeur vers un ITEMLIST contenant le nom de fichier dont on veut l'icône
    //renvoie une instance de IExtractIcon
    //==========================================================
    private IExtractIcon getIcon(IShellFolder item, IntPtr pidl)
    {
        int  prgf             = 0;
        Guid uuidIExtractIcon = new Guid("000214FA-0000-0000-C000-000000000046");

        try {
            if (pidl != IntPtr.Zero)
            {
                return((IExtractIcon)item.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref uuidIExtractIcon, out prgf));
            }
            else
            {
                return((IExtractIcon)item.CreateViewObject(IntPtr.Zero, ref uuidIExtractIcon));
            }
        } catch { return(null); }
    }
예제 #3
0
    //==========================================================
    //renvoie une instance de l'interface d'extraction de miniature pour item
    //==========================================================
    //IN item : instance de IShellFolder depuis laquelle on extrait l'extracteur de miniature
    //IN pidl : pointeur vers un ITEMLIST contenant le nom de fichier dont on veut la miniature
    //renvoie une instance de IExtractImage
    //==========================================================
    private IExtractImage getThumbnail(IShellFolder item, IntPtr pidl)
    {
        int  prgf = 0;
        Guid uuidIExtractImage = new Guid("BB2E617C-0920-11D1-9A0B-00C04FC2D6C1");

        try {
            // If we have a file's pidl
            if (pidl != IntPtr.Zero)
            {
                // Extract the file's thumbnail
                return((IExtractImage)item.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref uuidIExtractImage, out prgf));
            }
            else
            {
                // Or use the parent folder
                return((IExtractImage)item.CreateViewObject(IntPtr.Zero, ref uuidIExtractImage));
            }
        } catch { return(null); }
    }
예제 #4
0
        public static int CreateViewObject(IShellFolder folder, IntPtr Handle, ref Guid shellViewGuid, out IntPtr iShellViewPtr)
        {
            int hr = WinError.S_FALSE;

            try
            {
                hr = folder.CreateViewObject(Handle,
                                             ref shellViewGuid, out iShellViewPtr);
            }
            catch (System.AccessViolationException)
            {
                // A first chance exception of type 'System.AccessViolationException' occurred
                iShellViewPtr = IntPtr.Zero;
            }
            catch (Exception)
            {
                iShellViewPtr = IntPtr.Zero;
            }
            return(hr); // WinError
        }
예제 #5
0
        private IUnknown GetUIObject(IShellFolder shellFolder, string filename, Guid uuid)
        {
            IUnknown iunk = null;

            if (System.IO.File.Exists(filename))
            {
                IntPtr pidl      = IntPtr.Zero;
                int    cParsed   = 0;
                int    pdwAttrib = 0;
                shellFolder.ParseDisplayName(IntPtr.Zero, IntPtr.Zero, System.IO.Path.GetFileName(filename), out cParsed, out pidl, out pdwAttrib);
                if (pidl != IntPtr.Zero)
                {
                    int prgf = 0;
                    shellFolder.GetUIObjectOf(IntPtr.Zero, 1, ref pidl, ref uuid, out prgf, ref iunk);
                }
            }
            else
            {
                shellFolder.CreateViewObject(IntPtr.Zero, ref uuid, ref iunk);
            }
            return(iunk);
        }
예제 #6
0
 /// <summary>Requests an object that can be used to obtain information from or interact with a folder object.</summary>
 /// <typeparam name="TInterface">The interface to retrieve, typically IShellView.</typeparam>
 /// <param name="parentWindow">The owner window.</param>
 /// <returns>The interface pointer requested.</returns>
 public TInterface GetViewObject <TInterface>(HWND parentWindow) where TInterface : class =>
 iShellFolder.CreateViewObject <TInterface>(parentWindow);
예제 #7
0
파일: ShellFolder.cs 프로젝트: Starwer/Lime
 public int CreateViewObject(IntPtr hwndOwner, Guid riid, out IntPtr ppv)
 {
     checkDisposed();
     return(_iShellFolder.CreateViewObject(hwndOwner, riid, out ppv));
 }
예제 #8
0
 /// <summary>Requests an object that can be used to obtain information from or interact with a folder object.</summary>
 /// <typeparam name="TInterface">The interface to retrieve, typically IShellView.</typeparam>
 /// <param name="parentWindow">The owner window.</param>
 /// <returns>The interface pointer requested.</returns>
 public TInterface GetViewObject <TInterface>(System.Windows.Forms.IWin32Window parentWindow) where TInterface : class =>
 iShellFolder.CreateViewObject <TInterface>(IWin2Ptr(parentWindow));
예제 #9
0
 public static T CreateViewObject <T>(this IShellFolder psf, IntPtr hwndOwner) where T : class
 {
     return((T)psf.CreateViewObject(hwndOwner, typeof(T).GUID));
 }