Solved

Including file in .exe

Posted on 1998-09-07
4
144 Views
Last Modified: 2013-11-18
Is there a way to include a microsoft word doc or some other file inside a .exe??? I couldn't get it to work with a .res file but I didn't know if there was another way... any suggestions???
0
Comment
Question by:dob1
4 Comments
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
I don't think there is a way to do that, except saving it with the code, or in a TMemo(TRichEdit)component when you compile the code..

Regards,
Viktor Ivanov
0
 
LVL 4

Expert Comment

by:d003303
Comment Utility
to get it working with a .res file, use this script:

////////////////////////////////////////////////////////
// sample resource script to include a custom resource
// Compile with "brcc32 (scriptname).rc"
// Make sure that the .\Delphi\bin direcroty is in
// your path !

// usage:
// Resource-ID, Resource type, flags, included external file

100    DOC    DISCARDABLE    "MyDocument.doc"

// EOF

Save it as MyInclude.rc, compile it into a .res file with "brcc32 MyInclude.rc" as described in the comments, include it with {$R MyInclude.res} in your project and load the resource in your code with
ResHandle := LoadResource(FindResource(0, PChar(100), 'DOC'));
PointerToDocMemory := LockResource(ResHandle);
and PointerToDocMemory points to the included DOC file data. You can use the resource hanle in ResHandle with any Win32 memory function, like GlobalSize, GlobalUnlock, GlobalLock etc.

Have fun,
Slash/d003303
0
 

Expert Comment

by:clopez
Comment Utility
The commento from /d003303 is the way.

But if you would like to work with streams, which is easier, then use this code to get the document:

   ResName:='#100';
// Try to find the resource
   HRsrc:=FindResource(HInstance,PChar(ResName),'DOC');
// If the resource is not found exit
   if not (HRsrc<>0) then Exit;
// Otherway free the handle
   FreeResource(HRsrc);
// And load it as a Stream
   rs:=TResourceStream.Create(HInstance,ResName,'DOC');
   { Use it }
//Free it
   rs.Free;  

0
 

Accepted Solution

by:
manolis_afentakis earned 50 total points
Comment Utility
hi an idea is to look at how self extracted zip-programm
works you can find a freeware version of it
in delphi super page
or i can mail it to you,


regarts, manolis
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now