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秒一次就好了。这样不停刷新网页,就可以啦。

相关阅读 >>

Delphi indy 10.5.7的数据发送接收的用法

Delphi crc32算法

Delphi 计算加班时间工时的函数

Delphi 一个高效的正整数排序函数

Delphi splitstring 字符串分割成字符串组

Delphi 安卓获得设备 id

Delphi工具之tdump

Delphi 使用钩子函数建立一个全局的鼠标钩子

Delphi ansiendstext 用法之一(路径结尾自动加\)

Delphi inputbox 用法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...