|
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace JFileManager
{
class cJDirectoryInfo
{
public string DisplayName = "";
public string Path = "";
public ObjectType ObjectType = ObjectType.FOLDER;
public string TypeName = "";
public int IconIndex = 0;
public int SelectedIconIndex = 0;
public long Size = 0L;
public Image Image = null;
public DateTime LastWriteTime;
public string SortName = "";
public FileAttributes Attributes;
public cJDirectoryInfo(DirectoryInfo dInfo, bool blnGetImage)
{
SHFILEINFO shfi = new SHFILEINFO();
uint uFlags = (uint)(SHGFI.SHGFI_ICON | SHGFI.SHGFI_SMALLICON | SHGFI.SHGFI_TYPENAME | SHGFI.SHGFI_ADDOVERLAYS | SHGFI.SHGFI_SYSICONINDEX | SHGFI.SHGFI_DISPLAYNAME);
IntPtr ipTemp = cCommon.SHGetFileInfo(dInfo.FullName.ToString(), 0, out shfi, Marshal.SizeOf(shfi), uFlags);
this.Path = dInfo.FullName;
this.SortName = "0" + this.Path;
this.Image = null;
this.LastWriteTime = dInfo.LastWriteTime;
this.Attributes = dInfo.Attributes;
// Check result
if (ipTemp != IntPtr.Zero)
{
this.DisplayName = shfi.szDisplayName;
this.TypeName = shfi.szTypeName;
this.IconIndex = shfi.iIcon;
if (blnGetImage)
{
if (shfi.hIcon != IntPtr.Zero)
{
Icon icTemp = Icon.FromHandle(shfi.hIcon);
IconConverter imConvert = new IconConverter();
object obTemp = new object();
Type typ = typeof(Image);
obTemp = imConvert.ConvertTo(icTemp, typ);
this.Image = (Image)obTemp;
}
}
}
else
{
this.DisplayName = "";
this.TypeName = "";
this.IconIndex = 0;
}
if (shfi.hIcon != IntPtr.Zero)
cCommon.DestroyIcon(shfi.hIcon);
// Selected Icon
uFlags = (uint)(SHGFI.SHGFI_ICON | SHGFI.SHGFI_SMALLICON | SHGFI.SHGFI_ADDOVERLAYS | SHGFI.SHGFI_SYSICONINDEX | SHGFI.SHGFI_OPENICON);
ipTemp = cCommon.SHGetFileInfo(dInfo.FullName, 0, out shfi, Marshal.SizeOf(shfi), uFlags);
if (shfi.hIcon != IntPtr.Zero)
cCommon.DestroyIcon(shfi.hIcon);
this.SelectedIconIndex = shfi.iIcon;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have been a keen hobbyist programmer since getting my first computer - a Vic 20 (you had to be able to write programs then since few programs were available and all were expensive).
Retired and now living in Pewsey, Wiltshire, where I spend (far too much of) my time writing computer programs to keep my mind active.