⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.pas

📁 delphi 完全原代码,可以在d7 and windows xp下编译通过
💻 PAS
字号:
unit client;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ScktComp, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Label2: TLabel;
    Button3: TButton;
    ClientSocket1: TClientSocket;
    Edit3: TEdit;
    Label1: TLabel;
    Label3: TLabel;
    GroupBox1: TGroupBox;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    Button4: TButton;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure ClientSocket1Connecting(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure ClientSocket1Connect(Sender: TObject;
      Socket: TCustomWinSocket);
    procedure ClientSocket1Error(Sender: TObject; Socket: TCustomWinSocket;
      ErrorEvent: TErrorEvent; var ErrorCode: Integer);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
     connectflag:boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
id:integer;

begin
edit2.Text:=inttostr(clientsocket1.port);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if clientsocket1.Active then
begin
clientsocket1.Active :=false;
edit1.Text:='';edit3.Text:=''; form1.Caption:='client' ;
end
else
showmessage('你还没有连接到服务器,无法完成你的操作!!!')
end;

procedure TForm1.Button1Click(Sender: TObject);
begin

if edit1.Text<>'' then
begin
clientsocket1.Address :=edit1.text;
clientsocket1.Active :=true ;
end;
if edit3.text<>'' then begin
clientsocket1.Host:=edit3.text ;
clientsocket1.Active :=true;
end;
if (edit1.text='')and(edit3.Text='') then begin
showmessage('请输入服务器名称或IP地址!!') end;

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;

procedure TForm1.ClientSocket1Connecting(Sender: TObject;
  Socket: TCustomWinSocket);
begin
form1.Caption:=form1.Caption+'[正在连接......]'
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
clientsocket1.Active :=false;
end;

procedure TForm1.ClientSocket1Connect(Sender: TObject;
  Socket: TCustomWinSocket);
begin
connectflag:=true;

form1.Caption:='client[已连接]';

end;

procedure TForm1.ClientSocket1Error(Sender: TObject;
  Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
  var ErrorCode: Integer);
begin
connectflag:=false;
showmessage('无法连接到服务器,'+#13+'请检查你输入的服务器地址或'+#13+'服务器名称是否正解,'+#13+'或你已连接到服务器了!');
form1.Caption :='client'
end;

procedure TForm1.Button4Click(Sender: TObject);
var
char:string;
begin
if checkbox1.Checked then begin
char:='黑屏' end;
if checkbox2.checked then begin
char:='不黑屏'    end;
if checkbox3.Checked then begin
char:='重启'  end;
if checkbox4.Checked then begin
char:='关机'  end;
if checkbox5.Checked then begin
char:='注销' end;
if checkbox6.Checked then begin
char:='无法关机' end;

if connectflag then  begin
clientsocket1.Socket.SendText(char) end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -