procedure TForm1. Button1Click (Sender: TObject);
Var
Mstrm1: TMemoryStream;
Update: dword;
Workdir: string;
The begin
Workdir:=ExtractFilePath (ParamStr (0));
Mstrm1:=TMemoryStream. Create;
Mstrm1. LoadFromFile (workdir + '\ myexe exe');//to add resources
Mstrm1. Seek (0, soFromEnd);
Mstrm1. Position:=0;
Used by CopyFile (PChar (workdir + '\ test. Exe'), PChar (workdir + '\ test_add exe'), True);
Update:=BeginUpdateResourceW (PWideChar (widestring (workdir + '\ test_add exe')), False);
UpdateResourceW (update, PWideChar (RT_RCDATA), 'myexe' 0, mstrm1. Memory, mstrm1. Size);
EndUpdateResourceW (update, False);
Mstrm1. Free;
ShowMessage (' configuration completed ');
end;
Procedure TForm1. Button2Click (Sender: TObject);
Var
Exe: tresourcestream;
The begin
Exe:=TResourceStream. Create (HInstance, 'myexe RT_RCDATA);
Exe. SaveToFile (' e.E XE ');
Exe. Free;
end;
Now read is less than myexe resources
CodePudding user response:
Mstrm1. LoadFromFile (workdir + '\ myexe exe'); To ensure correct pathCodePudding user response: