/// <summary>
        /// Returns the index of the icon for the specified file
        /// </summary>
        /// <param name="fileName">Filename to get icon for</param>
        /// <param name="forceLoadFromDisk">If True, then hit the disk to get the icon,
        /// otherwise only hit the disk if no cached icon is available.</param>
        /// <param name="iconState">Flags specifying the state of the icon
        /// returned.</param>
        /// <returns>Index of the icon</returns>
        public int IconIndex(
            string fileName,
            bool forceLoadFromDisk,
            ShellIconStateConstants iconState
            )
        {
            SHGetFileInfoConstants dwFlags = SHGetFileInfoConstants.SHGFI_SYSICONINDEX;
            int dwAttr = 0;

            if (size == SystemImageListSize.SmallIcons)
            {
                dwFlags |= SHGetFileInfoConstants.SHGFI_SMALLICON;
            }

            // We can choose whether to access the disk or not. If you don't
            // hit the disk, you may get the wrong icon if the icon is
            // not cached. Also only works for files.
            if (!forceLoadFromDisk)
            {
                dwFlags |= SHGetFileInfoConstants.SHGFI_USEFILEATTRIBUTES;
                dwAttr   = FILE_ATTRIBUTE_NORMAL;
            }
            else
            {
                dwAttr = 0;
            }

            // sFileSpec can be any file. You can specify a
            // file that does not exist and still get the
            // icon, for example sFileSpec = "C:\PANTS.DOC"
            SHFILEINFO shfi     = new SHFILEINFO();
            uint       shfiSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi.GetType());

            System.IntPtr retVal = SHGetFileInfo(
                fileName, dwAttr, ref shfi, shfiSize,
                ((uint)(dwFlags) | (uint)iconState));

            if (retVal.Equals(System.IntPtr.Zero))
            {
                //System.Diagnostics.Debug.Assert((!retVal.Equals(IntPtr.Zero)),"Failed to get icon index");
                return(0);
            }
            else
            {
                return(shfi.iIcon);
            }
        }
 /// <summary>
 /// 根据文件扩展名得到系统扩展名的图标
 /// </summary>
 /// <param name="fileName">文件名(如:win.rar;setup.exe;temp.txt)</param>
 /// <param name="largeIcon">图标的大小</param>
 /// <returns></returns>
 public static System.Drawing.Icon GetFileIcon(string fileName, bool largeIcon)
 {
     Thinksea.Windows.Win32API.SHFILEINFO       _SHFILEINFO = new Thinksea.Windows.Win32API.SHFILEINFO();
     Thinksea.Windows.Win32API.GetFileInfoFlags flags;
     if (largeIcon)
     {
         flags = Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_ICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_LARGEICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_USEFILEATTRIBUTES;
     }
     else
     {
         flags = Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_ICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_SMALLICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_USEFILEATTRIBUTES;
     }
     System.IntPtr IconIntPtr = Thinksea.Windows.Win32API.User32.SHGetFileInfo(fileName, (uint)Thinksea.Windows.Win32API.FileAttributeFlags.FILE_ATTRIBUTE_TEMPORARY, ref _SHFILEINFO, (uint)System.Runtime.InteropServices.Marshal.SizeOf(_SHFILEINFO), (uint)flags);
     if (IconIntPtr.Equals(System.IntPtr.Zero))
     {
         return(null);
     }
     return(System.Drawing.Icon.FromHandle(_SHFILEINFO.hIcon));
 }
        /// <summary>
        /// 获取目录图标
        /// </summary>
        /// <param name="largeIcon">指示获取大图标还是小图标。</param>
        /// <returns>图标</returns>
        public static System.Drawing.Icon GetDirectoryIcon(bool largeIcon)
        {
            Thinksea.Windows.Win32API.SHFILEINFO       _SHFILEINFO = new Thinksea.Windows.Win32API.SHFILEINFO();
            Thinksea.Windows.Win32API.GetFileInfoFlags flags;
            if (largeIcon)
            {
                flags = Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_ICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_LARGEICON;
            }
            else
            {
                flags = Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_ICON | Thinksea.Windows.Win32API.GetFileInfoFlags.SHGFI_SMALLICON;
            }

            System.IntPtr IconIntPtr = Thinksea.Windows.Win32API.User32.SHGetFileInfo(@"", (uint)0, ref _SHFILEINFO, (uint)System.Runtime.InteropServices.Marshal.SizeOf(_SHFILEINFO), (uint)flags);
            if (IconIntPtr.Equals(System.IntPtr.Zero))
            {
                return(null);
            }
            System.Drawing.Icon _Icon = System.Drawing.Icon.FromHandle(_SHFILEINFO.hIcon);
            return(_Icon);
        }
 public bool Equals(ExecutionEngineRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#5
0
 public bool Equals(TargetMachineRef other)
 {
     return(Value.Equals(other.Value));
 }
 public bool Equals(TargetDataRef other)
 {
     return Value.Equals(other.Value);
 }
示例#7
0
 public bool Equals(MyString other)
 {
     return(Value.Equals(other.Value));
 }
示例#8
0
 public bool Equals(DIBuilderRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#9
0
 public bool Equals(MemoryTargetRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#10
0
 public bool Equals(BasicBlockRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#11
0
 public bool Equals(ModuleProviderRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#12
0
 public bool Equals(MetadataRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#13
0
 public bool Equals(OrcJITStackRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#14
0
 public bool Equals(JITEventListenerRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#15
0
 public bool Equals(MemoryBufferRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#16
0
 public bool Equals(MCJITMemoryManagerRef other)
 {
     return(Value.Equals(other.Value));
 }
 public bool Equals(MCJITCompilerOptions other)
 {
     return(Value.Equals(other.Value));
 }
示例#18
0
 public bool Equals(TargetLibraryInfoRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#19
0
 public bool Equals(TypeRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#20
0
 public bool Equals(ObjectFileRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#21
0
 public bool Equals(SharedObjectBufferRef other)
 {
     return(Value.Equals(other.Value));
 }
 public bool Equals(PassRegistryRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#23
0
 public bool Equals(AttributeRef other)
 {
     return(Value.Equals(other.Value));
 }
 public bool Equals(GenericValueRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#25
0
 public bool Equals(PassManagerRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#26
0
 public bool Equals(ContextRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#27
0
 public bool Equals(OpInfo1 other)
 {
     return(Value.Equals(other.Value));
 }
示例#28
0
 public bool Equals(SharedModuleRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#29
0
 public bool Equals(DiagnosticInfoRef other)
 {
     return(Value.Equals(other.Value));
 }
示例#30
0
 public bool Equals(DIDescriptor other)
 {
     return(Value.Equals(other.Value));
 }