public static void GetFileInfo(string path, uint fileAttributes, out FileInfo fileInfo, GFI flags) { fileInfo = new FileInfo(); // don't support these two, they smash the return value. Debug.Assert((flags & GFI.ExeType) == 0); Debug.Assert((flags & GFI.SysIconIndex) == 0); IntPtr ret = SHGetFileInfo(path, fileAttributes, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), (uint)flags); if (ret.ToInt32() == 0) // todo: find out some way to display a fine error! throw new Exception("Win32 Error: " + Marshal.GetLastWin32Error()); }
static extern IntPtr SHGetFileInfo( string pszPath, uint dwFileAttributes, ref FileInfo psfi, uint cbFileInfo, uint uFlags);