unit1.pas(157,31) Hint: Local variable "WSAData" does not seem to be initialized
- Код: Выделить всё
function TForm1.GetIPFromHost(HostName, IPaddr: string): Boolean;
type
cName = array[0..100] of Char;
PName = ^cName;
var
HEnt: pHostEnt;
HName: PName;
WSAData: TWSAData;
i: Integer;
begin
Result := False;
if WSAStartup($0202, WSAData) <> 0 then begin // <<< ругается сюда
WSAErr := 'Сокет не отвечает!"';
Exit;
end;
New(HName);
if GetHostName(HName^, SizeOf(cName)) = 0 then
begin
HostName := StrPas(HName^);
s_comp := HostName;
HEnt := GetHostByName(HName^);
for i := 0 to HEnt^.h_length - 1 do
IPaddr := Concat(IPaddr, IntToStr(Ord(HEnt^.h_addr_list^[i])) + '.');
SetLength(IPaddr, Length(IPaddr) - 1);
Result := True;
end
else begin
case WSAGetLastError of
WSANOTINITIALISED:WSAErr:='WSANotInitialised';
WSAENETDOWN :WSAErr:='WSAENetDown';
WSAEINPROGRESS :WSAErr:='WSAEInProgress';
end;
end;
Dispose(HName);
WSACleanup;
end;
ну подможите с winsock