窗体上放MPHexEditorEx控件
用以下函数替换EXE文件字符
设置MPHexEditorEx的CrateBackup为False;
function TFormMain.ReplacePass(Filename,Find, Replace: string): boolean;
var
LIntSize,
LIntPos,
LIntPos2: Integer;
var
LIntSize,
LIntPos,
LIntPos2: Integer;
strdata,
LStrFind,
LStrReplace: string;
LStrFind,
LStrReplace: string;
begin
//result:=false;
mphexeditorex1.LoadFromFile(filename); //exe file name
strdata:=find ; // want to find string
LstrReplace:=replace ; // want to replace string
LIntPos := 0 ;
with mphexeditorex1 do
begin
LStrFind := PrepareFindReplaceData(StrData, false, true);
LIntPos2 := Find(pchar(LStrFind), Length(LStrFind), LIntPos, DataSize -1,false);
SelStart := LIntPos2;
SelEnd := LIntPos2 + Length(LStrFind)-1;
if LStrReplace <> '' then ReplaceSelection(PChar(LStrReplace), Length(LStrReplace), '', False);
mphexeditorex1.SaveToFile(filename);
end;
result:=true
end;
//result:=false;
mphexeditorex1.LoadFromFile(filename); //exe file name
strdata:=find ; // want to find string
LstrReplace:=replace ; // want to replace string
LIntPos := 0 ;
with mphexeditorex1 do
begin
LStrFind := PrepareFindReplaceData(StrData, false, true);
LIntPos2 := Find(pchar(LStrFind), Length(LStrFind), LIntPos, DataSize -1,false);
SelStart := LIntPos2;
SelEnd := LIntPos2 + Length(LStrFind)-1;
if LStrReplace <> '' then ReplaceSelection(PChar(LStrReplace), Length(LStrReplace), '', False);
mphexeditorex1.SaveToFile(filename);
end;
result:=true
end;