Пример #1
0
        public void RefreshInfo()
        {
            // Name
            if (_parent != null && _parent is FShellFolder)
            {
                FShellFolder folder = (FShellFolder)_parent;
                _name = folder.GetSubObjectName(_handle);
            }
            // Info
            SShFileInfo    info = new SShFileInfo();
            EShGetFileInfo flag = EShGetFileInfo.Pidl |
                                  EShGetFileInfo.DisplayName |
                                  EShGetFileInfo.TypeName |
                                  EShGetFileInfo.Pidl |
                                  EShGetFileInfo.Icon |
                                  EShGetFileInfo.SmallIcon |
                                  EShGetFileInfo.SysIconIndex;
            IntPtr rsPtr = RShell32.SHGetFileInfo(FullPidl.Ptr, 0, ref info, Marshal.SizeOf(typeof(SShFileInfo)), flag);

            if (_name == null)
            {
                _name = info.szDisplayName;
            }
            _icon = info.iIcon;
        }
Пример #2
0
        public static string GetSpecialFolderPath(IntPtr hwnd, EShellSpecialFolders nFolder)
        {
            StringBuilder sb = new StringBuilder(RShell32.MAX_PATH);

            RShell32.SHGetSpecialFolderPath(hwnd, sb, nFolder, false);
            return(sb.ToString());
        }
Пример #3
0
        protected void Link()
        {
            IntPtr facePtr;

            RShell32.SHGetDesktopFolder(out facePtr);
            _face = (IShellFolder)Marshal.GetObjectForIUnknown(facePtr);
            RShell32.SHGetSpecialFolderLocation(IntPtr.Zero, ECsidl.CSIDL_DESKTOP, out _handle);
        }
Пример #4
0
        public static int GetLargeIconIndex(IntPtr ipIDList)
        {
            SShFileInfo    psfi   = new SShFileInfo();
            EShGetFileInfo dwflag = EShGetFileInfo.Icon | EShGetFileInfo.LargeIcon | EShGetFileInfo.Pidl | EShGetFileInfo.SysIconIndex;
            IntPtr         ipIcon = RShell32.SHGetFileInfo(ipIDList, 0, ref psfi, Marshal.SizeOf(psfi), dwflag);

            return(psfi.iIcon);
        }
Пример #5
0
        public static string GetNameByPIDL(IntPtr pidl)
        {
            SShFileInfo info = new SShFileInfo();

            RShell32.SHGetFileInfo(pidl, 0, ref info, Marshal.SizeOf(typeof(SShFileInfo)),
                                   EShGetFileInfo.Pidl | EShGetFileInfo.DisplayName | EShGetFileInfo.TypeName);
            return(info.szDisplayName);
        }
Пример #6
0
        public static Icon[] ExtractIconFromFile(string filename)
        {
            IntPtr pLargeIcon = IntPtr.Zero;
            IntPtr pSmallIcon = IntPtr.Zero;
            int    iconCount  = RShell32.ExtractIconEx(filename, -1, ref pLargeIcon, ref pSmallIcon, 1);

            Icon[] icons = new Icon[iconCount];
            for (int n = 0; n < iconCount; n++)
            {
                RShell32.ExtractIconEx(filename, n, ref pLargeIcon, ref pSmallIcon, 1);
                icons[n] = Icon.FromHandle(pLargeIcon);
            }
            return(icons);
        }