📄 createserver.pas
字号:
unit CreateServer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TCtreatSForm = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
ProgressBar1: TProgressBar;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure Setfile1;
{ Public declarations }
end;
var
CtreatSForm: TCtreatSForm;
implementation
{$R *.dfm}
function GetLength(Text: String): String;
Begin
If (Length(Text) > 9) Then
Result := IntToStr(Length(Text))
Else
Result := '0'+IntToStr(Length(Text));
End;
procedure TCtreatSForm.Setfile1;
var
i:integer;
F:File;
S,temp:string;
Str,Str1,str2,str3:array [1..100] of char;
begin
s:=Edit2.Text;
AssignFile(F,ExtractFilePath(Paramstr(0))+'server.exe');
Reset(F,1);
Seek(F,Filesize(F));
For i:=1 to length(S) do Str[i]:=S[i];
Blockwrite(F,Str,length(S));
temp:= GetLength(S);
For i:=1 to 2 do Str1[i]:=temp[i];
Blockwrite(F,Str1,2);
ProgressBar1.Position :=75 ;
S:=Edit1.Text;
For i:=1 to length(S) do Str2[i]:=S[i];
Blockwrite(F,Str2,length(S));
temp:= GetLength(S);
For i:=1 to 2 do Str3[i]:=temp[i];
Blockwrite(F,Str3,2);
ProgressBar1.Position :=90;
CloseFile(F);
ProgressBar1.Position := 0;
MessageBox(Application.Handle, '服务端生成完毕!', '提示', mb_ok);
end;
procedure TCtreatSForm.Button1Click(Sender: TObject);
var
Res:TRESourceStream;
begin
ProgressBar1.Position := 0;
if FileExists(ExtractFilePath(Paramstr(0))+'Server.exe') then
DeleteFile(ExtractFilePath(Paramstr(0))+'Server.exe');
Res:= TRESourceStream.Create(Hinstance,'Server','exefile');
ProgressBar1.Position :=20;
Res.SaveToFile(ExtractFilePath(Paramstr(0))+'Server.exe');
Res.Free;
ProgressBar1.Position :=50;
Sleep(200);
if FileExists(ExtractFilePath(Paramstr(0))+'Server.exe') then
Setfile1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -