?
Solved

Including file in .exe

Posted on 1998-09-07
4
Medium Priority
?
155 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
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…
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…
Suggested Courses

801 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