delphi 通过机器名读取IP地址的代码


本文整理自网络,侵删。

 function procedure TForm1.nametoip(name:string):string;
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
result:='';
WSAStartup(2, WSAData);
HostEnt := gethostbyname(PChar(name));
if HostEnt <> nil then
begin
with HostEnt^ do
result:= Format('%d.%d.%d.%d', [Byte(h_addr^[0]), Byte(h_addr^[1]), Byte(h_addr^
[2]), Byte(h_addr^[3])]);
end;
WSACleanup;
end;

相关阅读 >>

Delphi多线程

Delphi以鼠标为中心缩放图片以及拖动(采用区域抠图拉伸的方式)

Delphi xe taskbar按钮用法

Delphi [数据库连接字符串] access 连接字符串

Delphi外挂编写

Delphi createprocesswithlogonw用法

Delphi xe firemonkey的stylebook皮肤控件的使用

Delphi createthread的线程传参数(小熊论坛的)

Delphi 2009 之 tstringbuilder 类[6]: equals

Delphi 读文件到十六进制的函数(Delphi 7 下可用)

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



打赏

取消

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

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

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

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

评论

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