2023-11-07 17:10:47 +08:00
|
|
|
unit RconConfig;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
2023-12-16 23:28:14 +08:00
|
|
|
Dialogs, StdCtrls, ShellAPI;
|
2023-11-07 17:10:47 +08:00
|
|
|
|
|
|
|
type
|
2023-11-07 23:44:02 +08:00
|
|
|
TfmRconConfig = class(TForm)
|
2023-12-02 20:35:55 +08:00
|
|
|
edHost: TEdit;
|
|
|
|
lbHost: TLabel;
|
|
|
|
lbPassword: TLabel;
|
|
|
|
edPassword: TEdit;
|
|
|
|
bnConnect: TButton;
|
|
|
|
bnCancel: TButton;
|
2023-12-02 19:57:04 +08:00
|
|
|
procedure edHostKeyPress(Sender: TObject; var Key: Char);
|
|
|
|
procedure bnCancelClick(Sender: TObject);
|
|
|
|
procedure bnConnectClick(Sender: TObject);
|
|
|
|
procedure edPasswordChange(Sender: TObject);
|
2023-11-07 17:10:47 +08:00
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
2023-11-07 23:44:02 +08:00
|
|
|
fmRconConfig: TfmRconConfig;
|
2023-11-07 17:10:47 +08:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2023-12-16 23:28:14 +08:00
|
|
|
uses
|
|
|
|
Rcon;
|
|
|
|
|
2023-11-07 17:10:47 +08:00
|
|
|
{$R *.dfm}
|
|
|
|
|
2023-12-02 19:57:04 +08:00
|
|
|
procedure TfmRconConfig.edHostKeyPress(Sender: TObject; var Key: Char);
|
|
|
|
begin
|
2023-12-16 23:28:14 +08:00
|
|
|
if not (Key in ['0'..'9','a'..'z','A'..'Z','.',':'])
|
|
|
|
and (Key <> #8) and (Key <> #46) then
|
|
|
|
Key:= #0;
|
2023-12-02 19:57:04 +08:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfmRconConfig.bnCancelClick(Sender: TObject);
|
|
|
|
begin
|
2023-12-16 23:28:14 +08:00
|
|
|
Close;
|
2023-12-02 19:57:04 +08:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfmRconConfig.bnConnectClick(Sender: TObject);
|
2023-12-16 23:28:14 +08:00
|
|
|
var
|
|
|
|
//fmRcon: TfmRcon;
|
|
|
|
Server, Addr, Port: String;
|
2023-12-02 19:57:04 +08:00
|
|
|
begin
|
2023-12-16 23:28:14 +08:00
|
|
|
//fmRcon:= TfmRcon.Create(Application);
|
|
|
|
//fmRcon.Host:= edHost.Text;
|
|
|
|
//fmRcon.Password:= edPassword.Text;
|
|
|
|
//fmRcon.Show;
|
|
|
|
Server:= edHost.Text;
|
|
|
|
if Pos(':', Server) <> 0 then begin
|
|
|
|
Addr:= Copy(Server, 1, Pos(':', Server)-1);
|
|
|
|
Port:= Copy(Server, Pos(':', Server)+1, 5);
|
|
|
|
end else begin
|
|
|
|
Addr:= Server;
|
|
|
|
Port:= '5193';
|
|
|
|
end;
|
|
|
|
ShellExecute(0, 'open', 'rcon.exe', PChar(Addr + ' ' + Port + ' ' + edPassword.text), PChar(ExtractFilePath(ParamStr(0))), SW_SHOWNORMAL);
|
|
|
|
Close;
|
2023-12-02 19:57:04 +08:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TfmRconConfig.edPasswordChange(Sender: TObject);
|
|
|
|
begin
|
2023-12-16 23:28:14 +08:00
|
|
|
bnConnect.Enabled:= (edHost.Text <> '') and (edPassword.Text <> '');
|
2023-12-02 19:57:04 +08:00
|
|
|
end;
|
|
|
|
|
2023-11-07 17:10:47 +08:00
|
|
|
end.
|