Click here to Skip to main content
Licence 
First Posted 30 Mar 2003
Views 89,738
Bookmarked 25 times

Using embedded resources with .NET

By | 30 Mar 2003 | Article
Using embedded resources with .NET.

Sample Image - EmbeddedIconDemo.gif

Introduction

Embedded resource in a project is a new thing in .NET. This sample shows how to use it.

Using the code

The form has a button which changes the form icon.

Dim oStream As System.IO.Stream
Dim oAssembly As System.Reflection.Assembly
Dim sIcon As String
Dim oBitmap As Bitmap

If vbON Then
    sIcon = "EmbeddedIconDemo.LIGHTON.ICO"
Else
    sIcon = "EmbeddedIconDemo.LIGHTOFF.ICO"
End If

'open the executing assembly
oAssembly = System.Reflection.Assembly.LoadFrom(Application.ExecutablePath)

'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
FetchIcon = Icon.FromHandle(oBitmap.GetHicon)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sander Schreurs

Web Developer

Netherlands Netherlands

Member

I started with VB4 in 1996, after that VB5 and VB6. Always advanced database applications (Oracle, Access and SQL-Server). The last 5 years as a technical architect and project manager for development teams.
 
Special interest for user interaction.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 5 Pinmemberdrummerboy051111:32 25 Mar '11  
Generalhello^^ PinmemberDemantorr13:06 17 Jan '10  
GeneralWrong title Pinmember-R-y-a-n-1:25 28 Oct '07  
GeneralAlways getting error when added new icon Pinmemberyj800122:39 8 Aug '07  
GeneralThis worked for me :) Pinmember3DWebGuy10:32 9 Jun '05  
GeneralSame problem with cursors Pinmembermfortin22:52 4 Sep '03  
Generalshowhelp embedded resource chm file Pinmembermdg178:08 10 Jul '03  
GeneralMinor Improvement PinmemberSander Schreurs4:55 31 Mar '03  
GeneralTell More PinmemberPoolbeer19:43 30 Mar '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 31 Mar 2003
Article Copyright 2003 by Sander Schreurs
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid