DELPHI 获取本地IP地址源码
2022-11-23 16:33:24 作者:admin
本文整理自网络,侵删。
uses WinSock; function LocalIP: string;type TaPInAddr = array [0..10] of PInAddr; PaPInAddr = ^TaPInAddr;var phe: PHostEnt; pptr: PaPInAddr; Buffer: array [0..63] of char; I: Integer; GInitData: TWSADATA;begin try WSAStartup($101, GInitData); Result := ''; GetHostName(Buffer,SizeOf(Buffer)); phe := GetHostByName(buffer); if phe <> nil Then begin pptr := PaPInAddr(Phe^.h_addr_list); I := 0; while pptr^[I] <> nil do begin if i=0 then result := StrPas(inet_ntoa(pptr^[I]^)) else result:=result+ ', '+ StrPas(inet_ntoa(pptr^[I]^)); Inc(I); end; end; finally WSACleanup; end;end;
――――――――――――――――
原文链接:https://blog.csdn.net/xxkku521/article/details/11609499
相关阅读 >>
Delphi获取计算机的工作组信息和获取工作组中的计算机名称
Delphi中time消息的使用方法
Delphi文本文件读与写
Delphi中ocx的动态注册方法
Delphi firedac tfdconnection连接mysql数据库
截取程序的网络封包(Delphi hook api)
Delphi xe 取得 app 自己的版本号 (狠跨 4 个平台)
Delphi shellexecute openurl 的跨平台实现
Delphi 以十六进制显示数据内容
Delphi xe5 for android 调用java类库必看的文件
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码