コード例 #1
0
ファイル: CFile.cs プロジェクト: XiaoFaye/DiscManageMaster
        static CFile()
        {
            dwFlags =
                SystemImageList.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES |
                SystemImageList.SHGetFileInfoConstants.SHGFI_SYSICONINDEX |
                SystemImageList.SHGetFileInfoConstants.SHGFI_SMALLICON |
                SystemImageList.SHGetFileInfoConstants.SHGFI_TYPENAME;

            shfi     = new SystemImageList.SHFILEINFO();
            shfiSize = (uint)Marshal.SizeOf(shfi.GetType());
        }
コード例 #2
0
        public static int GetIconIndex(string Extension)
        {
            const int FILE_ATTRIBUTE_NORMAL = 0x80;

            SystemImageList.SHGetFileInfoConstants dwFlags =
                SystemImageList.SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES |
                SystemImageList.SHGetFileInfoConstants.SHGFI_SYSICONINDEX |
                SystemImageList.SHGetFileInfoConstants.SHGFI_SMALLICON;
            SystemImageList.SHFILEINFO shfi = new SystemImageList.SHFILEINFO();
            uint shfiSize = (uint)Marshal.SizeOf(shfi.GetType());

            SystemImageList.SHGetFileInfo(
                Extension,
                FILE_ATTRIBUTE_NORMAL,
                ref shfi,
                shfiSize,
                (uint)dwFlags);

            return(shfi.iIcon);
        }