delphi HTTP远程屏幕源码


使用了灰鸽子的HTTP控件ics

procedure TForm1.FormCreate(Sender: TObject);
begin
try
httpserver1.Start;//启动运行服务。设置httpserver1的属性。端口自己定义,最好不要为80目录为C盘c:\windows\
//文档为ceshi.jpg
except
showmessage('启动失败,查看端口是否占用');
end;
end;

接下来,设置一个timer控件,因为需要截图。定时截图。
procedure TForm1.Timer1Timer(Sender: TObject);
var
Fullscreen:Tbitmap;
FullscreenCanvas:TCanvas;
dc:HDC;
MyJPEG : TJPEGImage;//USES里添加jpeg引用!
begin
Fullscreen:=TBitmap.Create;
Fullscreen.Width:=screen.width;
Fullscreen.Height:=screen.Height;
DC:=GetDC(0);
FullscreenCanvas:=TCanvas.Create;
FullscreenCanvas.Handle:=DC;
Fullscreen.Canvas.CopyRect(Rect(0,0,screen.Width,screen.Height),
fullscreenCanvas,Rect(0,0,Screen.Width,Screen.Height));
FullscreenCanvas.Free;
ReleaseDC(0,DC);
myjpeg:= TJPEGImage.Create;
myjpeg.Assign(Fullscreen);
myjpeg.CompressionQuality:=10; //压缩比例,保证传输速度快
myjpeg.Compress;
try
myjpeg.SaveToFile('c:\windows\ceshi.JPG');//保存路径
myjpeg.Free;
fullscreen.free;
except
end;
end;


好了,这样基本就完成了。

再写个函数来获取本地IP,显示在程序上,这样直接点击

function GetLocalIP: string;
type
TaPInAddr = array[0..255] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: array[0..63] of char;
i: integer;
GInitData: TWSADATA;
begin
wsastartup($101, GInitData);
result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if not assigned(phe) then
exit;
pptr := PaPInAddr(Phe^.h_addr_list);
i := 0;
while pptr^[I] <> nil do
begin
result := {Result +}StrPas(inet_ntoa(pptr^[I]^)) + ',';
inc(i);
end;
Delete(Result, Length(Result), 1);
wsacleanup;
end;

访问就是IP:端口号码,就可以了哦。timer设置个大概5秒一次就好了。这样不停刷新网页,就可以啦。

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678