MCPcopy Create free account
hub / github.com/Squirrel/Squirrel.Windows / GetInfo

Method GetInfo

src/Squirrel/ShellFile.cs:1189–1223  ·  view source on GitHub ↗

Gets the information for the specified file name and flags.

()

Source from the content-addressed store, hash-verified

1187 /// file name and flags.
1188 /// </summary>
1189 public void GetInfo()
1190 {
1191 fileIcon = null;
1192 typeName = "";
1193 displayName = "";
1194
1195 SHFILEINFO shfi = new SHFILEINFO();
1196 uint shfiSize = (uint)Marshal.SizeOf(shfi.GetType());
1197
1198 IntPtr ret = SHGetFileInfo(
1199 fileName, 0, ref shfi, shfiSize, (uint)(flags));
1200 if (ret != IntPtr.Zero)
1201 {
1202 if (shfi.hIcon != IntPtr.Zero)
1203 {
1204 fileIcon = System.Drawing.Icon.FromHandle(shfi.hIcon);
1205 // Now owned by the GDI+ object
1206 //DestroyIcon(shfi.hIcon);
1207 }
1208 typeName = shfi.szTypeName;
1209 displayName = shfi.szDisplayName;
1210 }
1211 else
1212 {
1213 int err = GetLastError();
1214 Console.WriteLine("Error {0}", err);
1215 string txtS = new string('\0', 256);
1216 int len = FormatMessage(
1217 FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
1218 IntPtr.Zero, err, 0, txtS, 256, IntPtr.Zero);
1219 Console.WriteLine("Len {0} text {1}", len, txtS);
1220
1221 // throw exception
1222 }
1223 }
1224
1225 /// <summary>
1226 /// Constructs a new, default instance of the FileIcon

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected