Home > Back-end >  Resources update and read the question
Resources update and read the question

Time:10-08

 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 path

CodePudding user response:

reference 1st floor simonhehe response:
mstrm1. LoadFromFile (workdir + '\ myexe exe'); To ensure correct path

This must be right

CodePudding user response:

To a warrior ah,,,,

CodePudding user response:

After finishing the load flow monitoring object is nil, it is 0, the length of the judgment for any load, describe your problem, process how the final results, the results you want is what, what is the middle exception, are to describe others just good analysis

CodePudding user response:

More than a backslash
You see workdir the value of a variable, workdir already contains \

CodePudding user response:

Myexe in capital,

CodePudding user response:

refer to 6th floor iamduo response:
myexe in capital,

In capital or not

CodePudding user response:

  • Related