Changeset 135
- Timestamp:
- 3/8/2008 4:15:59 AM (5 years ago)
- Location:
- branches/eraser6/Util
- Files:
-
- 2 edited
-
File.cs (modified) (3 diffs)
-
Util.csproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Util/File.cs
r129 r135 2 2 using System.Collections.Generic; 3 3 using System.Text; 4 4 5 using System.Runtime.InteropServices; 6 using System.Drawing; 5 7 6 8 namespace Eraser.Util 7 9 { 8 using HICON = UIntPtr;9 using HIMAGELIST = UIntPtr;10 using HICON = IntPtr; 11 using HIMAGELIST = IntPtr; 10 12 11 13 public class File … … 21 23 { 22 24 SHFILEINFO shfi = new SHFILEINFO(); 23 HIMAGELIST imageList = (HIMAGELIST) SHGetFileInfo(path, 0, ref shfi, 24 Marshal.SizeOf(shfi), SHGetFileInfoFlags.SHGFI_SMALLICON | 25 SHGetFileInfoFlags.SHGFI_SYSICONINDEX | 25 SHGetFileInfo(path, 0, ref shfi, Marshal.SizeOf(shfi), 26 26 SHGetFileInfoFlags.SHGFI_DISPLAYNAME); 27 27 return shfi.szDisplayName; 28 } 29 30 /// <summary> 31 /// Uses SHGetFileInfo to retrieve the icon for the given file, folder or 32 /// drive. 33 /// </summary> 34 /// <param name="path">A string that contains the path and file name for 35 /// the file in question. Both absolute and relative paths are valid.</param> 36 /// <returns>An Icon object containing the bitmap</returns> 37 public static Icon GetFileIcon(string path) 38 { 39 SHFILEINFO shfi = new SHFILEINFO(); 40 SHGetFileInfo(path, 0, ref shfi, Marshal.SizeOf(shfi), 41 SHGetFileInfoFlags.SHGFI_SMALLICON | SHGetFileInfoFlags.SHGFI_ICON); 42 return Icon.FromHandle(shfi.hIcon); 28 43 } 29 44 … … 76 91 /// </returns> 77 92 [DllImport("Shell32.dll")] 78 private static extern UIntPtr SHGetFileInfo(string path, uint fileAttributes,93 private static extern IntPtr SHGetFileInfo(string path, uint fileAttributes, 79 94 ref SHFILEINFO psfi, int fileInfo, SHGetFileInfoFlags flags); 80 95 -
branches/eraser6/Util/Util.csproj
r129 r135 31 31 <Reference Include="System" /> 32 32 <Reference Include="System.Data" /> 33 <Reference Include="System.Drawing" /> 33 34 <Reference Include="System.Xml" /> 34 35 </ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.
