Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / February 2005

Tip: Looking for answers? Try searching our database.

Holding a file as a resource in a C++ .exe

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve McLellan - 23 Feb 2005 15:58 GMT
Hi,

Many apologies if this is the wrong group; if anyone can suggest a better
one please do.

I need to write a very small C++ (Win32, not .NET) application that will
essentially do a file copy after running some code to decide where to copy
the file to. Ideally I'd like to contain the file inside the EXE so that
from the user's point of view they download one file and it does what it's
supposed to do. I could equally do the same with a zip file containing the
file and a batch file to do the copy.

I can't find any information about whether it's possible to include a file
as a resource, and be able to treat it as a file from within the
application. Has anyone got any ideas?

Thanks,

Steve
David Lowndes - 23 Feb 2005 17:22 GMT
>I can't find any information about whether it's possible to include a file
>as a resource

It is possible Steve, see "User-Defined Resource" in MSDN.

> and be able to treat it as a file from within the
>application.

You'll need to treat it as a stream of data.

Dave
Steve McLellan - 23 Feb 2005 17:49 GMT
> >I can't find any information about whether it's possible to include a
> >file
[quoted text clipped - 6 lines]
>
> You'll need to treat it as a stream of data.

Hi David,

OK, thanks, I'll check that out.

Steve
Serge Baltic - 24 Feb 2005 11:56 GMT
DL> It is possible Steve, see "User-Defined Resource" in MSDN.
>> and be able to treat it as a file from within the application.
DL> You'll need to treat it as a stream of data.

You could make use of the following functions to extract it at runtime:

FindResource
LoadResource
LockResource
SizeofResource

(the first three should be used in the given sequence)

Also, a file can be addressed via the res:// protocol from the browser.

Signature

Serge

Steve McLellan - 24 Feb 2005 12:23 GMT
> DL> It is possible Steve, see "User-Defined Resource" in MSDN.
>>> and be able to treat it as a file from within the application.
[quoted text clipped - 10 lines]
>
> Also, a file can be addressed via the res:// protocol from the browser.

Hi Serge,

Thanks for the reply. I'd prefer not to read it at all if possible - the
application doesn't need to read the contents of the file, just be able to
copy it to a local disk location. But I guess writing it as a stream is a
reasonable solution and certainly seems to be much easier looking at the
API.

Thanks again,

Steve

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.