rifter1818
Well-known member
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()...
Currently im using the following code to get Icons (and extra info) for files.
C#:
[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();
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()...