Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno Zjištění MAC adresy v Pascal/assembler/DOS programu pod XP

Až do Windows98SE mi bez problémů fungovala funkce MS-DOS EEh, která vrací MAC adresu síťové karty. Pod XP mi to ale hází nějaký hausnumero.
Zřejmě Xp už nepodporují "staré" MS-DOS služby.
Poradíte někdo jestli existuje něco takového i pod XP? Zatím Googluju bezúspěchu :-(

PROCEDURE GetNode( var hex_addr: string; var retcode: integer );
{ get the physical station address }

Const
   Hex_Set  :packed array[0..15] of char = '0123456789ABCDEF';

Begin { GetNode }
   {Get the physical address from the Network Card}
   Regs.Ah := $EE;
   regs.ds := 0;
   regs.es := 0;
   MsDos(Regs);
   hex_addr := '';
   hex_addr := hex_addr + hex_set[(regs.ch shr 4)];
   hex_addr := hex_addr + hex_set[(regs.ch and $0f)];
   hex_addr := hex_addr + hex_set[(regs.cl shr 4) ];
   hex_addr := hex_addr + hex_set[(regs.cl and $0f)];
   hex_addr := hex_addr + hex_set[(regs.bh shr 4)];
   hex_addr := hex_addr + hex_set[(regs.bh and $0f)];
   hex_addr := hex_addr + hex_set[(regs.bl shr 4)];
   hex_addr := hex_addr + hex_set[(regs.bl and $0f)];
   hex_addr := hex_addr + hex_set[(regs.ah shr 4)];
   hex_addr := hex_addr + hex_set[(regs.ah and $0f)];
   hex_addr := hex_addr + hex_set[(regs.al shr 4)];
   hex_addr := hex_addr + hex_set[(regs.al and $0f)];
   retcode := 0;
End; { Getnode }

Jsou zobrazeny jen nové odpovědi. Zobrazit všechny
Předmět Autor Datum
Uses Winsock; Function SendARP (DestIp: DWORD; srcIP: DWORD; pMacAddr: pointer; PhyAddrLen: Pointer)…
pme 11.03.2009 18:38
pme
Tohle je pokud tomu dobře rozumím zjišťování MAC adresy síťovky jiného počítače podle zadané IP. Já… nový
JoDiK 12.03.2009 11:30
JoDiK
Tak hlásím, že problém je vyřešen, použil jsem jinou službu: E3h, která funguje i pod XP. Vlastně ob… poslední
JoDiK 12.03.2009 12:44
JoDiK
Uses Winsock;

Function SendARP (DestIp: DWORD; srcIP: DWORD; pMacAddr: pointer; PhyAddrLen: Pointer): DWORD;stdcall; external 'iphlpapi.dll';

Function getRemoteMacAdress (var address: String): Boolean;
var
  dwRemoteIP: DWORD;
  PhyAddrLen: Longword;
  pMacAddr : array [0..1] of Longword;
  temp: array [0..5] of byte;
  I: Byte;
begin
  Result := false;
  dwremoteIP := inet_addr (@address[1]);
  if dwremoteIP <> 0 then begin
    PhyAddrLen := 6;
    if SendARP (dwremoteIP, 0, @pMacAddr, @PhyAddrLen) = NO_ERROR then begin
      if (PhyAddrLen <> 0) and (pMacAddr[0] <> 0) then begin
         Move (pMacAddr, temp, 6);
         address := '';
         For I := 0 to 5 do address := address + inttohex (temp[i], 2)+'-';
         Delete (address, Length (address), 1);
         Result := true;
      end;
    end;
  end;
end;

Funguje pod Vista, preložené v Delphi2007 ;-)

Zpět do poradny Odpovědět na původní otázku Nahoru