win2000下
接收端
procedure TWait.Button1Click(Sender: TObject);
begin
close;
ClientSocket1.Active:=false;
end;
procedure TWait.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode:=0;
end;
procedure TWait.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
var
s:string;
begin
if socket.ReceiveText='send' then
begin
WNetAddConnection('//192.168.0.60/chan','','192.168.0.20');
copyfile(PChar(filepath+'chan/'+sendfile),PChar('//192.168.0.60/chan/'+sendfile),false);
label1.Caption:='与监控端连接成功!';
button1.Caption:='关闭';
timer1.Enabled:=false;
ClientSocket1.Active:=false;
runselect.jingli();
runselect.runmenu();
wait.SetFocus;
end;
end;
procedure TWait.ClientSocket1Write(Sender: TObject;
Socket: TCustomWinSocket);
begin
socket.SendText('send');
end;
procedure TWait.FormCreate(Sender: TObject);
begin
filepath := ExtractFilePath(Application.ExeName);
Clientsocket1.Active:=true;
end;
发送端
procedure Tlisten.Button1Click(Sender: TObject);
begin
close;
serversocket1.Active:=false;
end;
procedure Tlisten.ServerSocket1ClientError(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
ErrorCode:=0;
end;
procedure Tlisten.FormCreate(Sender: TObject);
begin
ServerSocket1.Active:=true;
end;
procedure Tlisten.Timer1Timer(Sender: TObject);
begin
showmessage('监听失败!');
close;
end;
procedure Tlisten.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
if socket.ReceiveText='send' then
begin
label1.Caption:='与被监控端连接成功!';
button1.Caption:='关闭';
timer1.Enabled:=false;
socket.SendText('send');
serversocket1.Active:=false;
Close;
end;
end;