Loading Icons from an Icon library at runtime

  • Thread starter Thread starter xs
  • Start date Start date
X

xs

Does anybody know how to add Icons to a dll and then load the icons from the
dll at runtime? That means the ico files are stored inside the dll and not
outside of the library. Even better does anybody know how to load the icons
from Shell32 from Windows XP at runtime?

Thanks
 
Does anybody know how to add Icons to a dll and then load the icons from the
dll at runtime? That means the ico files are stored inside the dll and not
outside of the library. Even better does anybody know how to load the icons
from Shell32 from Windows XP at runtime?

Thanks

You can extract icons from a file with P/Invoke and ExtractIcon
or ExtractIconEx.

[DllImport("Shell32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr ExtractIcon(int hInst, string
lpszExeFileName, int nIconIndex);


// ExtractIconEx
[DllImport("Shell32.dll", CharSet=CharSet.Auto)]
public static extern int ExtractIconEx(string lpszFile, int
nIconIndex, out IntPtr phiconLarge, out IntPtr phiconSmall, int
nIcons);
 
Back
Top