rifter1818 Posted October 25, 2004 Posted October 25, 2004 1) How do i get the icon Assosiated with Folders and "Special things"(My Computer, My Network Places, Recycle Bin etc)... Currently im using the following code to get Icons (and extra info) for files. [structLayout(LayoutKind.Sequential)] public struct SHFILEINFO { public IntPtr hIcon; public IntPtr iIcon; public uint dwAttributes; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szDisplayName; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] public string szTypeName; }; class Win32 { public const uint SHGFI_ICON = 0x100; public const uint SHGFI_LARGEICON = 0x0; // 'Large icon public const uint SHGFI_SMALLICON = 0x1; // 'Small icon [DllImport("shell32.dll")] public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags); }; //...... IntPtr iconhandle; iconhandle = Win32.SHGetFileInfo(FileName,0,ref shinfo,(uint)Marshal.SizeOf(shinfo),Win32.SHGFI_ICON|Win32.SHGFI_LARGEICON); //.... icon.Image = Icon.FromHandle(shinfo.hIcon).ToBitmap(); I assume this will not work if i sart plugging in directories under filenames... 2) What is the path of the current Desktop.. foreach(string S in System.io.Directory.getfiles(???????)) 3) What do things like My Computer and Recycle Bin fall under for System.IO.Directory.getfiles(),System.IO.Directory.getdirectories()... Quote
Mothra Posted October 27, 2004 Posted October 27, 2004 1) How do i get the icon Assosiated with Folders and "Special things"(My Computer, My Network Places, Recycle Bin etc)... Currently im using the following code to get Icons (and extra info) for files. I assume this will not work if i sart plugging in directories under filenames... 2) What is the path of the current Desktop.. foreach(string S in System.io.Directory.getfiles(???????)) 3) What do things like My Computer and Recycle Bin fall under for System.IO.Directory.getfiles(),System.IO.Directory.getdirectories()... I'm not sure about how to get the Icons but, to get to the folders (in VB at least, I think it's pretty much the same in C#...) you can use this: Environment.SpecialFolder.[the special folder] The Windows folders (My Documents, Desktop, My Pictures, etc...) are in an enumeration so the intellisense should kick in at that point and you can just pick the folder you're looking for. Hope that helps... Quote Being smarter than you look is always better than looking smarter than you are.
Recommended Posts