コード例 #1
0
        public void GetInfo(bool folder)
        {
            FileIcon.SHFILEINFO shfileinfo;

            if (fileIcon != null)
            {
                fileIcon.Dispose();
            }
            fileIcon    = null;
            typeName    = "";
            displayName = "";
            shfileinfo  = new FileIcon.SHFILEINFO();
            uint ui = (uint)Marshal.SizeOf(shfileinfo.GetType());
            int  i1 = FileIcon.SHGetFileInfo(fileName, folder ? 0x10 : 0, ref shfileinfo, ui, (uint)flags);

            if (i1 != 0)
            {
                if (shfileinfo.hIcon != IntPtr.Zero)
                {
                    fileIcon = Icon.FromHandle(shfileinfo.hIcon);
                }
                typeName    = shfileinfo.szTypeName;
                displayName = shfileinfo.szDisplayName;
            }
            else
            {
                int i2 = FileIcon.GetLastError();
                Console.WriteLine("Error {0}", i2);
                string s  = new String('\0', 0x100);
                int    i3 = FileIcon.FormatMessage(0x1200, IntPtr.Zero, i2, 0, s, 0x100, 0);
                Console.WriteLine("Len {0} text {1}", i3, s);
            }
        }
コード例 #2
0
        private void AddIcon(bool folder, string extension)
        {
            FileIcon icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES | FileIcon.SHGetFileInfoConstants.SHGFI_SMALLICON);

            this.ilIcons.Images.Add(icon.ShellIcon);
            icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_SELECTED | FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES | FileIcon.SHGetFileInfoConstants.SHGFI_SMALLICON);
            this.ilIcons.Images.Add(icon.ShellIcon);
            icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES);
            this.ilLargeIcons.Images.Add(icon.ShellIcon);
            icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_SELECTED | FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES);
            this.ilLargeIcons.Images.Add(icon.ShellIcon);
        }
コード例 #3
0
ファイル: FileIcon.cs プロジェクト: mkbu95/Img-Tools-Gunbound
 private static extern int SHGetFileInfo(string pszPath, int dwFileAttributes, ref FileIcon.SHFILEINFO psfi, uint cbFileInfo, uint uFlags);
コード例 #4
0
ファイル: FileIcon.cs プロジェクト: mkbu95/Img-Tools-Gunbound
 public FileIcon(bool folder, string fileName, FileIcon.SHGetFileInfoConstants flags)
 {
     this.fileName = fileName;
     this.flags = flags;
     GetInfo(folder);
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: mkbu95/Img-Tools-Gunbound
 private void AddIcon(bool folder, string extension)
 {
     FileIcon icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES | FileIcon.SHGetFileInfoConstants.SHGFI_SMALLICON);
     this.ilIcons.Images.Add(icon.ShellIcon);
     icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_SELECTED | FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES | FileIcon.SHGetFileInfoConstants.SHGFI_SMALLICON);
     this.ilIcons.Images.Add(icon.ShellIcon);
     icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES);
     this.ilLargeIcons.Images.Add(icon.ShellIcon);
     icon = new FileIcon(folder, extension, FileIcon.SHGetFileInfoConstants.SHGFI_SELECTED | FileIcon.SHGetFileInfoConstants.SHGFI_TYPENAME | FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES);
     this.ilLargeIcons.Images.Add(icon.ShellIcon);
 }