Board index » delphi » MAC ADDRESS

MAC ADDRESS

How can i get the MAC ADDRESS of a NIC with a PASCAL routine?
 

Re:MAC ADDRESS


Quote
In article <96k6br$46...@nereid.worldonline.nl>, Peter Wens wrote:
>How can i get the MAC ADDRESS of a NIC with a PASCAL routine?

I don't know what you use for networking, but the most logical one would be
to send your own IP a packet, listen for it on a port, and then dissect the
TCP/IP msg.

Re:MAC ADDRESS


Quote
Peter Wens wrote:

> How can i get the MAC ADDRESS of a NIC with a PASCAL routine?

USES crt;

TYPE Tphysaddr=array[0..5] of byte;

CONST pa=$E800;   {put your NIC's port address here}

FUNCTION hexbyte(b:byte):string;
CONST digits:array[0..15] of char=

('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
VAR s:string;
BEGIN
  s:='00';
  s[2]:=digits[b AND $0F];
  s[1]:=digits[(b SHR 4) AND $0F];
  hexbyte:=s;
END;

PROCEDURE NormalMode;
BEGIN
  port[pa+$00]:=$C0 OR $21;
  port[pa+$01]:=$00;
END;

PROCEDURE Readphysaddr(var physaddr:Tphysaddr);
VAR i:byte;
BEGIN
  port[pa+$00]:=$40 OR $21;
  FOR i:=0 TO 5 DO
    physaddr[i]:=port[pa+i+1];
END;

VAR physaddr:Tphysaddr;

BEGIN
  NormalMode;
  readphysaddr(physaddr);
  writeln('MAC Address: ',hexbyte(physaddr[0]),'-',
           hexbyte(physaddr[1]),'-',
           hexbyte(physaddr[2]),'-',
           hexbyte(physaddr[3]),'-',
           hexbyte(physaddr[4]),'-',
           hexbyte(physaddr[5]));
END.

Michael
--
+--------------------------------------------------------------------+
|  Michael Knapp - Mauerbach - Nieder?sterreich - Austria - Europe   |
|  E-Mail: mkn...@gmx.at                             ICQ: 36542787   |
+--------------------------------------------------------------------+
| G r a p h i X            http://programmierer.freepage.de/graphix/ |
| Graphics Library for Freepascal, Virtual Pascal and Borland Pascal |
| http://graphix4pascal.cjb.net/    http://www.graphix4pascal.de.vu/ |
+--------------------------------------------------------------------+

Other Threads