How to attach a file inside a DLL or executable (Views: 101)
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:
procedure TForm1.Button1Click(Sender: TObject);
theFiles := TStringList.Create;
if theFiles.Count > 0 then
mStream := TMemoryStream.Create;
for f := 0 to theFiles.Count - 1 do
fStream := TFileStream.Create(theFiles[f], fmOpenRead);
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.
<< Back to main page