Se può essere d'aiuto a chi ancora non avesse affrontato
l'argomento...
(N.B. recuperato dal web e leggermente modificato)
Private Function GetIconFromExecutingAssembly(ByVal iconName As String) As Icon Dim oStream As System.IO.Stream Dim oAssembly As System.Reflection.Assembly Dim sIcon As String Dim oBitmap As Bitmap 'open the executing assembly oAssembly = System.Reflection.Assembly.LoadFrom(Application.ExecutablePath) sIcon = String.Format("{0}.{1}", oAssembly.GetName.Name, iconName) 'create stream for image (icon) in assembly oStream = oAssembly.GetManifestResourceStream(sIcon) 'create new bitmap from stream oBitmap = CType(Image.FromStream(oStream), Bitmap) 'create icon from bitmap Return Icon.FromHandle(oBitmap.GetHicon) End Function
powered by IMHO
Modificato il 07/01/2005
Su suggerimento di Enzo Colluto (vedi feedback) ecco un modo ancora più immediato:
Dim myIcon As Icon = New Icon(GetType(myForm), "MYICO.ICO")