本文整理自网络,侵删。
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 tmemo控件滚动条scrollbar末尾插入字符串一点都会闪烁的轻松实现
Delphi使用idtcpclient和idtcpserver相互发送数据
更多相关阅读请进入《Delphi》频道 >>