Home All Groups Group Topic Archive Search About

Is it possible to compile an image file into a DLL or EXE file?

Author
18 Apr 2006 9:04 PM
Mark Denardo
I have a DLL that I created that contains a reference to an image file on my
hard drive and when I go to use that DLL in another program it complains
that it can't find it.  (I'm using a relative path in the DLL).  I
understand why it's happening, but instead of referencing a global path or
moving the file to the programs directory where I'm using the DLL, I was
wondering if it's possible to compile the image right into the DLL (or EXE
for that matter)?  Is that even possible, or do you always have to reference
media files and such by pointing to them in some local directory that you
package up with the program?

Mark

Author
18 Apr 2006 9:24 PM
vbnetdev
IN your DLL project right click the Project in the Solution Explorer, select
Add, and then select Add Existing Item to browse to your image file.
In Solution Explorer, select the image file you just added, and then press
F4 to display its Properties.
Set the Build Action property to Embedded Resource.

Dim rm AsNew ResourceManager("EsriSamples.PanTool", Me.GetType().Assembly)
m_bitmap = CType(rm.GetObject("Pan_Bmp"), System.Drawing.Bitmap)



--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"Mark Denardo" <markdena***@runbox.com> wrote in message
news:8sydnV5mYecSztjZnZ2dnUVZ_uidnZ2d@starstream.net...
>I have a DLL that I created that contains a reference to an image file on
>my hard drive and when I go to use that DLL in another program it complains
>that it can't find it.  (I'm using a relative path in the DLL).  I
>understand why it's happening, but instead of referencing a global path or
>moving the file to the programs directory where I'm using the DLL, I was
>wondering if it's possible to compile the image right into the DLL (or EXE
>for that matter)?  Is that even possible, or do you always have to
>reference media files and such by pointing to them in some local directory
>that you package up with the program?
>
> Mark
>
Author
18 Apr 2006 10:22 PM
Mythran
Show quote Hide quote
"vbnetdev" <vbnetdev@community.nospam> wrote in message
news:uDCT85yYGHA.4652@TK2MSFTNGP04.phx.gbl...
> IN your DLL project right click the Project in the Solution Explorer,
> select Add, and then select Add Existing Item to browse to your image
> file.
> In Solution Explorer, select the image file you just added, and then press
> F4 to display its Properties.
> Set the Build Action property to Embedded Resource.
>
> Dim rm AsNew ResourceManager("EsriSamples.PanTool", Me.GetType().Assembly)
> m_bitmap = CType(rm.GetObject("Pan_Bmp"), System.Drawing.Bitmap)
>
>
>
> --
> Get a powerful web, database, application, and email hosting with KJM
> Solutions
> http://www.kjmsolutions.com
>
>
>
> "Mark Denardo" <markdena***@runbox.com> wrote in message
> news:8sydnV5mYecSztjZnZ2dnUVZ_uidnZ2d@starstream.net...
>>I have a DLL that I created that contains a reference to an image file on
>>my hard drive and when I go to use that DLL in another program it
>>complains that it can't find it.  (I'm using a relative path in the DLL).
>>I understand why it's happening, but instead of referencing a global path
>>or moving the file to the programs directory where I'm using the DLL, I
>>was wondering if it's possible to compile the image right into the DLL (or
>>EXE for that matter)?  Is that even possible, or do you always have to
>>reference media files and such by pointing to them in some local directory
>>that you package up with the program?
>>
>> Mark
>>
>
>

Keep in mind, while compiling the resource into the dll is useful, it can
become troublesome when you get a large amount of files and want to access
each one.  Also, keep in mind, doing it this way increases the assembly for
each resource you include....it would take longer startup times, and a
larger memory footprint (please, someone correct me if I'm wrong here).

HTH,
Mythran
Author
18 Apr 2006 10:26 PM
vbnetdev
You are not wrong. He asked how to do it. Not that it would necessarily be
wise. But it may be necessary for him in his situation.


--
Get a powerful web, database, application, and email hosting with KJM
Solutions
http://www.kjmsolutions.com



Show quoteHide quote
"Mythran" <kip_potter@hotmail.comREMOVETRAIL> wrote in message
news:%23oxknazYGHA.3400@TK2MSFTNGP02.phx.gbl...
>
> "vbnetdev" <vbnetdev@community.nospam> wrote in message
> news:uDCT85yYGHA.4652@TK2MSFTNGP04.phx.gbl...
>> IN your DLL project right click the Project in the Solution Explorer,
>> select Add, and then select Add Existing Item to browse to your image
>> file.
>> In Solution Explorer, select the image file you just added, and then
>> press F4 to display its Properties.
>> Set the Build Action property to Embedded Resource.
>>
>> Dim rm AsNew ResourceManager("EsriSamples.PanTool",
>> Me.GetType().Assembly)
>> m_bitmap = CType(rm.GetObject("Pan_Bmp"), System.Drawing.Bitmap)
>>
>>
>>
>> --
>> Get a powerful web, database, application, and email hosting with KJM
>> Solutions
>> http://www.kjmsolutions.com
>>
>>
>>
>> "Mark Denardo" <markdena***@runbox.com> wrote in message
>> news:8sydnV5mYecSztjZnZ2dnUVZ_uidnZ2d@starstream.net...
>>>I have a DLL that I created that contains a reference to an image file on
>>>my hard drive and when I go to use that DLL in another program it
>>>complains that it can't find it.  (I'm using a relative path in the DLL).
>>>I understand why it's happening, but instead of referencing a global path
>>>or moving the file to the programs directory where I'm using the DLL, I
>>>was wondering if it's possible to compile the image right into the DLL
>>>(or EXE for that matter)?  Is that even possible, or do you always have
>>>to reference media files and such by pointing to them in some local
>>>directory that you package up with the program?
>>>
>>> Mark
>>>
>>
>>
>
> Keep in mind, while compiling the resource into the dll is useful, it can
> become troublesome when you get a large amount of files and want to access
> each one.  Also, keep in mind, doing it this way increases the assembly
> for each resource you include....it would take longer startup times, and a
> larger memory footprint (please, someone correct me if I'm wrong here).
>
> HTH,
> Mythran
>
Author
18 Apr 2006 10:43 PM
Mythran
"vbnetdev" <vbnetdev@community.nospam> wrote in message
news:ex3HbczYGHA.3684@TK2MSFTNGP05.phx.gbl...
> You are not wrong. He asked how to do it. Not that it would necessarily be
> wise. But it may be necessary for him in his situation.
>
>
> --
> Get a powerful web, database, application, and email hosting with KJM
> Solutions
> http://www.kjmsolutions.com


Yeah, which is why I posted under your post instead of replying directly
under the op's post.  This way, he may follow your example, but "keeping in
mind" my post so he doesn't drown himself before he realizes it :)

Mythran
Author
19 Apr 2006 1:02 AM
Mark Denardo
Ok I have the image loaded into the project ("sunset.ico"), and under it's
build properties I have it set to Embedded Resource, but I'm a little
confused as to how I load an embedded file into one of my objects (your code
didn't help me much).

Here's the line of code I'm having trouble with:

Me.Icon = New System.Drawing.Icon(CurDir() + "\..\Images\sunset.ico")

btw, this is an EXE I'm building just to save me a step in testing.  And I'm
using VS 2005.

Mark


Show quoteHide quote
"vbnetdev" <vbnetdev@community.nospam> wrote in message
news:uDCT85yYGHA.4652@TK2MSFTNGP04.phx.gbl...
> IN your DLL project right click the Project in the Solution Explorer,
> select Add, and then select Add Existing Item to browse to your image
> file.
> In Solution Explorer, select the image file you just added, and then press
> F4 to display its Properties.
> Set the Build Action property to Embedded Resource.
>
> Dim rm AsNew ResourceManager("EsriSamples.PanTool", Me.GetType().Assembly)
> m_bitmap = CType(rm.GetObject("Pan_Bmp"), System.Drawing.Bitmap)
>
>
>
> --
> Get a powerful web, database, application, and email hosting with KJM
> Solutions
> http://www.kjmsolutions.com
>
>
>
> "Mark Denardo" <markdena***@runbox.com> wrote in message
> news:8sydnV5mYecSztjZnZ2dnUVZ_uidnZ2d@starstream.net...
>>I have a DLL that I created that contains a reference to an image file on
>>my hard drive and when I go to use that DLL in another program it
>>complains that it can't find it.  (I'm using a relative path in the DLL).
>>I understand why it's happening, but instead of referencing a global path
>>or moving the file to the programs directory where I'm using the DLL, I
>>was wondering if it's possible to compile the image right into the DLL (or
>>EXE for that matter)?  Is that even possible, or do you always have to
>>reference media files and such by pointing to them in some local directory
>>that you package up with the program?
>>
>> Mark
>>
>
>