Почему то выдаёт отрицательные значения индекса иконки в системном ImageList. Почему так происходит? Если допустим взять папку и поставить на неё ту же самую иконку, выдаёт корректный результат. Помогите плиз. | Код | public const uint SHGFI_ICONLOCATION = 0x000001000; // get icon location
[StructLayout(LayoutKind.Sequential)] private struct ShellFileInfoStructure { 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; };
[DllImport("shell32.dll")] private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, out ShellFileInfoStructure psfi, uint cbSizeFileInfo, uint uFlags);
public void GetIndex(string Way) { ShellFileInfoStructure rr = new ShellFileInfoStructure(); SHGetFileInfo(Way, 0, out rr, (uint)Marshal.SizeOf(rr), SHGFI_ICONLOCATION); MessageBox.Show(rr.iIcon.ToString()); MessageBox.Show(rr.szDisplayName);
}
|
|