急~帮我看看这个函数
我要实现获取本机拨号网络IP地址,在大富翁论坛找到了这个函数,但是我在implementation后加上了这个函数后,在编译的时候提示
[Error] Unit1.pas(41): Undeclared identifier: 'PInAddr'
[Error] Unit1.pas(44): Undeclared identifier: 'PHostEnt'
[Error] Unit1.pas(48): Undeclared identifier: 'TWSADATA'
[Error] Unit1.pas(51): Undeclared identifier: 'WSAStartup'
[Error] Unit1.pas(53): Undeclared identifier: 'GetHostName'
[Error] Unit1.pas(54): Undeclared identifier: 'GetHostByName'
[Error] Unit1.pas(55): Operator not applicable to this operand type
[Error] Unit1.pas(56): Pointer type required
请教到底是什么问题?
function GetIP : 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
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;