示例#1
0
		public static Icon GetIcon(string path, bool selected)
		{
			ShellFileInformationStructure info = new ShellFileInformationStructure(true);
			int cbFileInfo = Marshal.SizeOf(info);
			SHGFI flags;
			if (!selected)
				flags = SHGFI.SHGFI_ICON | SHGFI.SHGFI_SMALLICON;
			else
				flags = SHGFI.SHGFI_ICON | SHGFI.SHGFI_SMALLICON | SHGFI.SHGFI_OPENICON;

			ShellApiNativeMethods.SHGetFileInfo (path, 256, out info,(uint)cbFileInfo, flags);
			return Icon.FromHandle(info.IconHandle);
		}
示例#2
0
		internal static extern Int32		SHGetFileInfo (string pszPath, uint dwFileAttributes, out ShellFileInformationStructure psfi, uint cbfileInfo, SHGFI uFlags);