Väldigt enkelt program som extrahera ikon ifrån vald fil, funkar på det mesta. Till exempel musik filer,bilder,program osv. Nedladdning (källkod endast även bifogat i tråden):https://mega.co.nz/#!AoZkEIJQ!ABRqgx24XUihoxvAwjatKnos_jRC0e1dvOKtnKNZPh8 Besök gärna min blogg om ni har intresse av det http://araschic.myshowroom.se Här har ni ett snippet för dom som har intresse av det, lite stökig stil hoppas det duger ändå.
//The might .dll shell32 behold !
[DllImport("Shell32.dll")]
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, uint uFlags);
// Constants that we need in the function call
private const int SHGFI_ICON = 0x100;
private const int SHGFI_SMALLICON = 0x1;
private const int SHGFI_LARGEICON = 0x0;
// This structure will contain information about the file
public struct SHFILEINFO
{
// Handle to the icon representing the file
public IntPtr hIcon;
// Index of the icon within the image list
public int iIcon;
// Various attributes of the file
public uint dwAttributes;
// Path to the file
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string szDisplayName;
// File type
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
};
//Sample Usage, not (to) advanced ? =)
private void DrawIcon(string strFilePath)
{
//Store the 'Icon'
Icon myIcon;
//Large icon
IntPtr hImgLarge;
//;) fancy shit
SHFILEINFO shinfo = new SHFILEINFO();
///////////////////////////////
//DRAW THE LARGE ICON
///////////////////////////////
//Get handle
hImgLarge = SHGetFileInfo(txtFilePath.Text, 0, ref shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_LARGEICON);
//myIcon equal icon from file
myIcon = Icon.FromHandle(shinfo.hIcon);
//Draw icon inside picture box
picLarge.Image = myIcon.ToBitmap();
//Clean up and jump out
GC.Collect();
}
ExtractIconFromPE.zip