Solved

Including file in .exe

Posted on 1998-09-07
4
152 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
ID: 1338977
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
ID: 1338978
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
ID: 1338979
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
ID: 1338980
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Element alignment and word wrapping 9 81
.php tree directory? 5 89
Firemonkey allowing RTL on android 6 56
Twebbrowser add css to the header 3 39
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 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