procedure TForm1.Button1Click(Sender: TObject);
var
Dir: PChar;
Ch: Array[0..8] of Char;
Stream1: TMemoryStream;
begin
GetMem(Dir,254);
GetTempPath(254, Dir);
TempName:=StrPas(Dir)+'temp.exe';
CopyFile(PChar(ParamStr(0)),PChar(TempName),False);
Stream1:=TMemoryStream.Create;
Stream1.LoadFromFile(TempName);
//在尾部加入8个字节的注册码
Ch[0]:=Chr('1');
Ch[1]:=Chr('2');
Ch[2]:=Chr('3');
Ch[3]:=Chr('4');
Ch[4]:=Chr('5');
Ch[5]:=Chr('6');
Ch[6]:=Chr('7');
Ch[7]:=Chr('8');
Stream1.Seek(0,soFromEnd);
Stream1.Write(Ch,8);
Stream1.SaveToFile(TempName);
Stream1.Free;
FreeMem(Dir);
repeat Close Until FileExists(TempName);
CopyFile(PChar(TempName),PChar(ParamStr(0)),False);
end;