var AI, Work: PIPAdapterInfo; Size: Integer; Res: Integer; I: Integer;
implementation
function SendARP; external 'Iphlpapi.dll' Name 'SendARP';
function GetAdaptersInfo(AI: PIPAdapterInfo; var BufLen: Integer): Integer; stdcall; external 'iphlpapi.dll' Name 'GetAdaptersInfo';
function MACToStr(ByteArr: PByte; Len: Integer): string; begin Result := ''; while (Len > 0) do begin Result := Result + IntToHex(ByteArr^, 2) + '-'; ByteArr := Pointer(Integer(ByteArr) + SizeOf(Byte)); Dec(Len); end; SetLength(Result, Length(Result) - 1); { remove last dash } end;
function GetAddrString(Addr: PIPAddrString): string; begin Result := ''; while (Addr <> nil) do begin Result := Result + 'A: ' + Addr^.IPAddress + ' M: ' + Addr^.IPMask + #13; Addr := Addr^.Next; end; end;
function TimeTToDateTimeStr(TimeT: Integer): string; const UnixDateDelta = 25569; { days between 12/31/1899 and 1/1/1970 } var DT: TDateTime; TZ: TTimeZoneInformation; Res: DWord;
begin if (TimeT = 0) then Result := '' else begin { Unix TIME_T is secs since 1/1/1970 } DT := UnixDateDelta + (TimeT / (24 * 60 * 60)); { in UTC } { calculate bias } Res := GetTimeZoneInformation(TZ); if (Res = TIME_ZONE_ID_INVALID) then RaiseLastWin32Error; if (Res = TIME_ZONE_ID_STANDARD) then begin DT := DT - ((TZ.Bias + TZ.StandardBias) / (24 * 60)); Result := DateTimeToStr(DT) + ' ' + WideCharToString(TZ.StandardName); end else begin { daylight saving time } DT := DT - ((TZ.Bias + TZ.DaylightBias) / (24 * 60)); Result := DateTimeToStr(DT) + ' ' + WideCharToString(TZ.DaylightName); end; end; end;