Ok! Всё, спасибо. Разобрался. Кому тоже нужно:
http://www.torry.net/authorsmore.php?id=1753 Программа WNetStat v.2.3. Замечательная вещь! Респект автору - Vadim Crits!
Вот что я из неё выдрал (консольное приложение):
| Код | Program ARPS; {$APPTYPE CONSOLE} Uses Windows, SysUtils, uARP;
Function FormatIpAddress(Value: DWORD): String; Begin Result:=Format('%d.%d.%d.%d', [Value and $FF, (Value shr 8) and $FF, (Value shr 16) and $FF, (Value shr 24) and $FF]); End;
Function FormatMacAddress(const Value: array of Byte): String; Begin Result:=Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x', [Value[0], Value[1], Value[2], Value[3], Value[4], Value[5]]); End;
Function FormatDecimal(Value: Int64): String; Var I, J: Integer; Begin Result:=IntToStr(Value); J:=0; For I:= Length(Result) DownTo 1 Do Begin Inc(J); If (J = 3) And (I <> 1) Then Begin Insert(ThousandSeparator, Result, I); J:=0; End; End; End;
Var IpNetTable: PMibIpNetTable; dwSize: DWORD; I: Integer; Begin WriteLn('ARPS starting...'); dwSize:=0; GetIpNetTable(Nil, @dwSize, True); If dwSize = 0 Then Begin WriteLn('Local error!'); Exit; End;
IpNetTable:=AllocMem(dwSize);
WriteLn('IP Address', #9, 'MAC Address', #9#9, 'Type', #9, 'Interface');
Try GetIpNetTable(IpNetTable, @dwSize, True);
With IpNetTable^ Do Begin For I:=0 To dwNumEntries-1 Do Begin Write(FormatIpAddress(Table[i].dwAddr), #9); If table[i].dwPhysAddrLen <> 0 Then Write(FormatMacAddress(table[i].bPhysAddr), #9); Write(ArpTypeNames[table[i].dwType], #9); WriteLn(FormatDecimal(table[i].dwIndex)); End; End;
Finally FreeMem(IpNetTable); End; End. |
И юнит, который понадобится:
| Код | Unit uARP;
{$ALIGN ON} {$MINENUMSIZE 4} {$WEAKPACKAGEUNIT}
Interface Uses Windows;
Const ANI_SIZE = 1; MAXLEN_PHYSADDR = 8;
ArpTypeNames: array[0..4] of string[7] = ( '?', 'other', 'invalid', 'dynamic', 'static');
Type
PMibIpNetRow = ^TMibIpNetRow; TMibIpNetRow = packed record dwIndex: DWORD; { adapeter index } dwPhysAddrLen: DWORD; { physical address length } bPhysAddr: array[0..MAXLEN_PHYSADDR - 1] of BYTE; { physical address } dwAddr: DWORD; { IP address } dwType: DWORD; { ARP entry type } End;
PMibIpNetTable = ^TMibIpNetTable; TMibIpNetTable = Packed Record dwNumEntries: DWORD; { number of entries in table } Table: Array[0..ANI_SIZE - 1] of TMibIpNetRow; { array of ARP entries } End;
Function GetIpNetTable(pIpNetTable: PMibIpNetTable; pdwSize: PULONG; bOrder: BOOL): DWORD; stdcall;
Implementation
Const IPHelper = 'iphlpapi.dll';
Function GetIpNetTable; External IPHelper name 'GetIpNetTable';
End. |
Всем спасибо! |