Raise Exception.Create('Memory allocation failed for IP_ADAPTER_ADDRESSES struct') ÄwRetVal := GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_ALL_INTERFACES, nil, pAddresses, (dwRetVal ERROR_BUFFER_OVERFLOW) or (i = MAX_TRIES) Procedure TForm1.Button1Click(Sender: TObject) On typical computers, this dramatically reduces the chances that the GetAdaptersAddresses function returns ERROR_BUFFER_OVERFLOW, which would require calling GetAdaptersAddresses function multiple times. The recommended method of calling the GetAdaptersAddresses function is to pre-allocate a 15KB working buffer pointed to by the AdapterAddresses parameter. ![]() The GetAdaptersAddresses function can retrieve information for IPv4 and IPv6 addresses. ![]() The adapter's information is returned in the IP_ADAPTER_ADDRESSES structure by the AdapterAddresses parameter. The GetAdaptersAddresses function is the preferred way to obtain adapters information since 2001 with Windows XP.
0 Comments
Leave a Reply. |