[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Including file in .exe

Posted on 1998-09-07
4
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 100 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

Industry Leaders: 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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

649 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