Почему содержимое в виде иероглифов внутри переменной
`host` ?function GetAdaInfo2(out AInfoStr: AnsiString; const AOnlyMac: Boolean):Boolean;
NI_MAXHOST = 1025;
NI_MAXSERV = 32;
NI_NUMERICHOST = $2;
NI_NUMERICSERV = $8;
var
i: Integer;
bf: Cardinal;
LpAdapterAddresses: PIP_ADAPTER_ADDRESSES;
//*********************
host, serv: String;
hostlen, servlen: integer;
r: integer;
m_data: WSADATA;
begin
if WSAStartup($0202, m_data) <> 0 then
Exit;
bufferSize := sizeof(text);
Result := True;
AInfoStr := '';
try
bf := 0;
if GetAdaptersAddresses(0, 0, nil, nil, @bf) <> ERROR_BUFFER_OVERFLOW then Abort;
try
GetMem(LpAdapterAddresses, bf);
if GetAdaptersAddresses(0, 0, nil, LpAdapterAddresses, @bf) <> ERROR_SUCCESS then Abort;
while LpAdapterAddresses <> nil do
begin
try
//********************************************************************
hostlen := NI_MAXHOST; // 1025
servlen := NI_MAXSERV; // 32
setlength(host, hostlen);
setlength(serv, servlen);
r := GetNameInfo(LpAdapterAddresses.FirstUnicastAddress.Address.lpSockaddr,
LpAdapterAddresses.FirstUnicastAddress.Address.iSockaddrLength,
PWideChar(host), hostlen,
PWideChar(serv), servlen, NI_NUMERICHOST); // NI_NUMERICSERV
//********************************************************************
finally
LpAdapterAddresses := LpAdapterAddresses^.Next;
end;
end;
finally
FreeMem(LpAdapterAddresses, bf);
end;
except
Result := False;
end;
WSACleanup;
end;
Delphi XE / Windows 7 SP1 64-bit