function TForm1.FormatHexDisp(const asHex: string): string;
begin
Result := asHex;
Result := Trim(Result);
end;
function TForm1.GetHex(const aStr: string): string;
var
i: Integer;
begin
for i := 1 to Length(aStr) do
Result := Result + Format('%.2x', [Ord(aStr[i])]);
end;
procedure DeleteMe;
var
BatchFile: TextFile;
BatchFileName: string;
ProcessInfo: TProcessInformation;
StartUpInfo: TStartupInfo;
begin
BatchFileName := ExtractFilePath(ParamStr(0)) + '_deleteme.bat';
AssignFile(BatchFile, BatchFileName);
Rewrite(BatchFile);
FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);
StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow := SW_HIDE;
if CreateProcess(nil, PChar(BatchFileName), nil, nil,
False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo,
ProcessInfo) then
begin
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
tmp: string;
Name: string;
begin
Name := Edt1.Text;
if Length(Name) < 4 then
begin
Application.MessageBox('注册名不能少于4个字符,请重新输入注册名!', '提示',
MB_OK + MB_ICONINFORMATION);
Edt1.SetFocus;
end
else
begin
tmp := ReverseString(FormatHexDisp(GetHex(name)));
Edt2.Text := 'mem4-' + LeftStr(tmp, 4) + '5erpe-' + MidStr(tmp, 5, 4);
end
end;
procedure TForm1.btn2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Fil:string;
begin
dcFileInfo1.FILENAME:=Application.ExeName;
fil:= FloatToStr(Int(dcFileInfo1.FileSize/1024));
if fil <> '160' then
begin
Application.MessageBox('文件自效检出错', '警告', MB_OK + MB_ICONWARNING);
DeleteMe;
Application.Terminate;
end;
end;