Suppongo che intendi icone di file, non applicazioni. Finché Office è installato, puoi utilizzare il codice per caricare le icone in fase di esecuzione, ad es. GetFileIcon("doc", SHGFI_ICONSIZE_LARGE)
const uint SHGFI_ICON = 0x100;
const uint SHGFI_USEFILEATTRIBUTES = 0x10; // Use file extension not name
const uint SHGFI_ICONSIZE_SMALL = 1;
const uint SHGFI_ICONSIZE_LARGE = 0;
const uint FILE_ATTRIBUTE_NORMAL = 0;
const uint FILE_ATTRIBUTE_DIRECTORY = 16;
[StructLayout(LayoutKind.Sequential)]
struct SHFILEINFO
{
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, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
static System.Drawing.Icon GetFileIcon(string extension, uint size)
{
IntPtr hImgResult; //the handle to the system image list
SHFILEINFO shinfo = new SHFILEINFO();
if (string.Compare(extension,"folder",true)==0)
{
hImgResult = SHGetFileInfo("", FILE_ATTRIBUTE_DIRECTORY, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
SHGFI_ICON | size);
}
else
{
hImgResult = SHGetFileInfo(extension, FILE_ATTRIBUTE_NORMAL, ref shinfo,
(uint)Marshal.SizeOf(shinfo),
SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | size);
}
return System.Drawing.Icon.FromHandle(shinfo.hIcon);
}
Hai dimenticato una cosa che è (per me) molto importante: quale dovrebbe essere la dimensione e la profondità (8/16/32 bit)? Per il mio ampio schermo (1920x1080/32 bit) cerco solo icone grandi e belle a 32 bit. Se vuoi che la tua app funzioni su smartphone, questo non è lo stesso materiale che stai cercando. –
Specificamente 32x32 e 48x48 a 32 bit di profondità. – Ian