本文整理自网络,侵删。
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 tidhttpserver开发http服务端外网无法访问
Delphi 生成xml 方法 与 Delphi txt文件操作
更多相关阅读请进入《Delphi》频道 >>