public void GetInfo()
{
ShellIcon = null;
TypeName = "";
DisplayName = "";
SHFILEINFO shfi = new SHFILEINFO();
uint shfiSize = (uint)Marshal.SizeOf(shfi.GetType());
int ret = SHGetFileInfo(FileName, 0, ref shfi, shfiSize, (uint)(Flags));
if (ret != 0)
{
if (shfi.hIcon != IntPtr.Zero)
{
ShellIcon = System.Drawing.Icon.FromHandle(shfi.hIcon);
// Now owned by the GDI+ object
//DestroyIcon(shfi.hIcon);
}
TypeName = shfi.szTypeName;
DisplayName = shfi.szDisplayName;
}
else
{
int err = GetLastError();
Console.WriteLine($"Error {err}");
string txtS = new string('\0', 256);
int len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, IntPtr.Zero, err, 0, txtS, 256, 0);
Console.WriteLine($"Len {len} text {txtS}");
}
}