Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
Member Area
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Become a Member
-Why sign up!
-Chat Online!
-Indexes NEW!!
-Build your resume
-Find a job
-Post a job
-Resume Search
-Link to us
Visit Embarcadero
Embarcadero Community
How to attach a file inside a DLL or executable Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Files Operation
Delphi 2.x
User Rating
No Votes
# Votes
DSP, Administrator
Reference URL:
			Author: Jonas Bilinkevicius

I don't know if it is possible to attach a file to a DLL or exe. Example: You 
create a function (useOtherdll (bool)) in Test.dll with a parameter that tells you 
to use a DLL named Needed.dll. If the function parameter is 'true' then the DLL 
Needed.dll must be in the current directory, if the function parameter is 'false' 
then the DLL Needed.dll must not to be in the current directory. So if it is 
possible to attach in test.dll my other DLL Needed.dll, and then I can copy it if 
it is necessary or not.


You can use streams to copy any data to the end of any other data - ie., copy a DLL 
to the end of a DLL. Example:

1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     f: integer;
4     fStream: TFileStream;
5     mStream: TMemoryStream;
6     theFiles: TStringList;
7   begin
8     theFiles := TStringList.Create;
9     try
10      theFiles.Add('Needed.dll');
11      theFiles.Add('TEST.dll');
12      if theFiles.Count > 0 then
13      begin
14        mStream := TMemoryStream.Create;
15        try
16          for f := 0 to theFiles.Count - 1 do
17          begin
18            fStream := TFileStream.Create(theFiles[f], fmOpenRead);
19            try
20              mStream.CopyFrom(fStream, fStream.Size);
21            finally
22              fStream.Free;
23            end;
24          end;
25          mStream.Seek(0, soFromBeginning);
26          mStream.SaveToFile('NEW.dll');
27        finally
28          mStream.Free;
29        end;
30      end;
31    finally
32      theFiles.Free;
33    end;
34  end;

You would need to mark the start of the second DLL somewhere. Then when needed, load the combined DLL into a stream. Seek to second DLL block, and copy it in a stream. Save that block steam back to the disk as the second DLL name.

Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10


Share this page
Download from Google

Copyright © Mendozi Enterprises LLC