Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

Including file in .exe

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
dob1
Asked:
dob1
1 Solution
 
viktornetCommented:
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
 
d003303Commented:
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
 
clopezCommented:
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
 
manolis_afentakisCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now