반응형
function GetLocalIP : String;
var
WSAData: TWSAData;
HostName, IPAddress: String;
HostEnt: PHostEnt;
begin
WSAStartup(2, WSAData);
SetLength(HostName, 255);
GetHostname(PChar(HostName), 255);
SetLength(HostName, StrLen(PChar(HostName)));
HostEnt := GetHostByName(PChar(HostName));
with HostEnt^ do
IPAddress := Format('%d.%d.%d.%d',[Byte(h_addr^[0]), Byte(h_addr^[1]),
Byte(h_addr^[2]), Byte(h_addr^[3])]);
WSACleanup;
Result := IPAddress;
end;
반응형
'Programming > Delphi' 카테고리의 다른 글
| E2220:Never-build package '%s' requires always-build package '%s' (0) | 2011.01.11 |
|---|---|
| 현재 OS 알아내기 (0) | 2010.12.16 |
| 파일 버전 알아내기 (0) | 2010.12.16 |
| 현재 떠있는 익스플로러 타이틀과 URL 가져오기 (0) | 2010.12.16 |
| 사운드 플레이 (0) | 2010.12.16 |