adding a resource to an exe and using it

  • Thread starter Thread starter Joshua Ellul
  • Start date Start date
J

Joshua Ellul

Hi There,

Could someone tell me how I could add an image to my exe as a resource and
use it?

Thanks,

Joshua
 
Joshua said:
Hi There,

Could someone tell me how I could add an image to my exe as a resource and
use it?

Add the image file as a resource to the .exe by specifying the file in a
/resource option to the csc command line, or if using VS.NET specify
"Embedded Resource" as the Build Action property for the file.

Then use Assembly.GetManifestResourceStream() to read in the image data.
 
Please look that:
rm = new ResourceManager("MyImages", this.GetType().Assembly);
PictureBox.Image = (System.Drawing.Image)rm.GetObject("MyObject");

ResourceWriter rw=new ResourceWriter ("TestDemo.resources");
using(Image image=Image .FromFile ("Bitmap1.bmp"))
{
rw.AddResource ("TangLogo",image );
rw.AddResource ("Title","TTTTTTTTT");
rw.Close ();
}
Assembly objAssembly=Assembly .GetExecutingAssembly();

ResourceManager ms=new ResourceManager
(S"WinTest.TestDemo",objAssembly);
pictureBox1 .Image =(Image)ms.GetObject("TangLogo");
Icon icon = new Icon(this.GetType(), "App.ico");
pictureBox1 .Image =icon.ToBitmap ()

Satan Tang
=====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top