Exemplo n.º 1
0
        /// <summary>
        /// Constructor for the desktop shell item.
        /// </summary>
        /// <param name="explorer">
        /// Explorer class that uses the shell item.
        /// </param>
        /// <param name="pidl">
        /// Pointer to the desktop PIDL.
        /// </param>
        /// <param name="folderPtr">
        /// Pointer to the IShellFolder interface for the desktop.
        /// </param>
        internal ShellItem(ShellExplorer explorer, IntPtr pidl, IntPtr folderPtr)
        {
            this.explorer  = explorer;
            parent         = null;
            this.folderPtr = folderPtr;
            // get managed object
            this.folder =
                (IShellFolder)Marshal.GetTypedObjectForIUnknown(folderPtr, typeof(IShellFolder));
            subFiles   = new ShellItemList(this);
            subFolders = new ShellItemList(this);
            relPidl    = new PIDL(pidl, false);

            text = "Desktop";
            path = "Desktop";
            SetDesktopAttributes();

            ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO();
            ShellAPI.SHGetFileInfo(relPidl.Ptr,
                                   0,
                                   ref info,
                                   ShellAPI.cbFileInfo,
                                   ShellAPI.SHGFI.PIDL |
                                   ShellAPI.SHGFI.TYPENAME |
                                   ShellAPI.SHGFI.SYSICONINDEX);
            type = info.szTypeName;

            ShellImageList.SetIconIndex(this, info.iIcon, false);
            ShellImageList.SetIconIndex(this, info.iIcon, true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve the string that describes the file's type.
        /// </summary>
        private void SetInfo()
        {
            PIDL fullPidl = FullPidl;

            ShellAPI.SHFILEINFO info = new ShellAPI.SHFILEINFO();

            ShellAPI.SHGetFileInfo(fullPidl.Ptr,
                                   0,
                                   ref info,
                                   ShellAPI.cbFileInfo,
                                   ShellAPI.SHGFI.PIDL |
                                   ShellAPI.SHGFI.TYPENAME |
                                   ShellAPI.SHGFI.SYSICONINDEX);
            fullPidl.Free();
            type = info.szTypeName;
            ShellImageList.SetIconIndex(this, info.iIcon, false);
            ShellImageList.SetIconIndex(this, info.iIcon, true);
        }