用 Tserversocket ,TClientsocket
相当好用
unit serv;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScktComp;
type
TForm1 = class(TForm)
ServerSocket1: TServerSocket;
Memo_receive: TMemo;
procedure ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
st : TMemoryStream;
implementation
{$R *.DFM}
procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo_receive.Lines.Add(socket.RemoteHost+':'+ socket.RemoteAddress );
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Fullscreen : Tbitmap;
FullscreenCanvas : TCanvas;
dc : HDC;
begin
{ Fullscreen := TBitmap.Create; // create a bimap to save picture
Fullscreen.Width := 100;
Fullscreen.Height := 100;
DC := GetDC (0); // get screen dc
FullscreenCanvas := TCanvas.Create; //create screen canvas
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect (Rect (0, 0, 100,100), fullscreenCanvas,
Rect (0, 0, Screen.Width, Screen.Height));
FullscreenCanvas.Free; //free screen canvasReleaseDC (0, DC);
Fullscreen.SaveToStream(st);
socket.SendStreamthendrop(st);}
memo_receive.Lines.Add(socket.ReceiveText);
socket.SendText('heofdjs');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
st := TMemoryStream.create;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
st.Destroy;
end;
end.
unit serv;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ScktComp;
type
TForm1 = class(TForm)
ServerSocket1: TServerSocket;
Memo_receive: TMemo;
procedure ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
procedure ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
st : TMemoryStream;
implementation
{$R *.DFM}
procedure TForm1.ServerSocket1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
begin
memo_receive.Lines.Add(socket.RemoteHost+':'+ socket.RemoteAddress );
end;
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var
Fullscreen : Tbitmap;
FullscreenCanvas : TCanvas;
dc : HDC;
begin
{ Fullscreen := TBitmap.Create; // create a bimap to save picture
Fullscreen.Width := 100;
Fullscreen.Height := 100;
DC := GetDC (0); // get screen dc
FullscreenCanvas := TCanvas.Create; //create screen canvas
FullscreenCanvas.Handle := DC;
Fullscreen.Canvas.CopyRect (Rect (0, 0, 100,100), fullscreenCanvas,
Rect (0, 0, Screen.Width, Screen.Height));
FullscreenCanvas.Free; //free screen canvasReleaseDC (0, DC);
Fullscreen.SaveToStream(st);
socket.SendStreamthendrop(st);}
memo_receive.Lines.Add(socket.ReceiveText);
socket.SendText('heofdjs');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
st := TMemoryStream.create;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
st.Destroy;
end;
end.
可以传输图像
做的深一点,可以远程控制