угу, пасиб. сделал так как в примере, вроде работает норм, с кракозябрами думал долго..
---------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
const
MAX_ADAPTER_NAME_LENGTH = 256;
MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
MAX_ADAPTER_ADDRESS_LENGTH = 8;
IPHelper = 'iphlpapi.dll';
MIB_IF_TYPE_OTHER = 1;
MIB_IF_TYPE_ETHERNET = 6;
MIB_IF_TYPE_TOKENRING = 9;
MIB_IF_TYPE_FDDI = 15;
MIB_IF_TYPE_PPP = 23;
MIB_IF_TYPE_LOOPBACK = 24;
MIB_IF_TYPE_SLIP = 28;
type
IP_ADDRESS_STRING = record
S: array [0..15] of Char;
end;
IP_MASK_STRING = IP_ADDRESS_STRING;
PIP_MASK_STRING = ^IP_MASK_STRING;
PIP_ADDR_STRING = ^IP_ADDR_STRING;
IP_ADDR_STRING = record
Next: PIP_ADDR_STRING;
IpAddress: IP_ADDRESS_STRING;
IpMask: IP_MASK_STRING;
Context: DWORD;
end;
time_t = Longint;
PIP_ADAPTER_INFO = ^IP_ADAPTER_INFO;
IP_ADAPTER_INFO = record
Next: PIP_ADAPTER_INFO;
ComboIndex: DWORD;
AdapterName:array [0..MAX_ADAPTER_NAME_LENGTH + 3] of ansiChar;
Description: array [0..MAX_ADAPTER_DESCRIPTION_LENGTH + 3] of ansiChar;
AddressLength: UINT;
Address: array [0..MAX_ADAPTER_ADDRESS_LENGTH - 1] of BYTE;
Index: DWORD;
Type_: UINT;
DhcpEnabled: UINT;
CurrentIpAddress: PIP_ADDR_STRING;
IpAddressList: IP_ADDR_STRING;
GatewayList: IP_ADDR_STRING;
DhcpServer: IP_ADDR_STRING;
HaveWins: BOOL;
PrimaryWinsServer: IP_ADDR_STRING;
SecondaryWinsServer: IP_ADDR_STRING;
LeaseObtained: time_t;
LeaseExpires: time_t;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
function GetAdaptersInfo(pAdapterInfo: PIP_ADAPTER_INFO;var pOutBufLen: ULONG): DWORD; stdcall; external IPHelper;
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
TmpPointer, InterfaceInfo: PIP_ADAPTER_INFO;
IP: PIP_ADDR_STRING;
Len: ULONG;
begin
if GetAdaptersInfo(nil, Len) = ERROR_BUFFER_OVERFLOW then
begin
GetMem(InterfaceInfo, Len);
if GetAdaptersInfo(InterfaceInfo, Len) = ERROR_SUCCESS then begin
TmpPointer := InterfaceInfo;
repeat
showmessage(string(TmpPointer^.AdapterName)+' '+string(TmpPointer^.Description));
TmpPointer := TmpPointer.Next;
until TmpPointer = nil;
end;
FreeMem(InterfaceInfo);
end;
end;
end.