User Tools

Site Tools


finding_20the_20mac_20address

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
finding_20the_20mac_20address [2018/03/31 13:19] – external edit 127.0.0.1finding_20the_20mac_20address [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 4: Line 4:
 ===== Method 1 ===== ===== Method 1 =====
 \\  This method is the simplest, and works on all versions of Windows from Windows 95 to Windows Vista or later. However if two or more network adaptors are fitted it returns only the MAC address of the primary adaptor. Also, it relies on a feature of Windows which isn't guaranteed to be reliable, so should be used at your own risk!\\ \\  \\  This method is the simplest, and works on all versions of Windows from Windows 95 to Windows Vista or later. However if two or more network adaptors are fitted it returns only the MAC address of the primary adaptor. Also, it relies on a feature of Windows which isn't guaranteed to be reliable, so should be used at your own risk!\\ \\ 
 +<code bb4w>
         SYS "LoadLibrary", "RPCRT4.DLL" TO rpcrt4%         SYS "LoadLibrary", "RPCRT4.DLL" TO rpcrt4%
         SYS "GetProcAddress", rpcrt4%, "UuidCreate" TO UuidCreate%         SYS "GetProcAddress", rpcrt4%, "UuidCreate" TO UuidCreate%
Line 21: Line 22:
  
         PRINT "MAC address = " MACaddress$         PRINT "MAC address = " MACaddress$
 +</code>
 \\  \\ 
 ===== Method 2 ===== ===== Method 2 =====
 \\  This method is almost as simple as the preceding one, but works **only under Windows 2000 Professional, Windows XP or Windows Vista or later**. It also returns the MAC address of the primary adaptor, but uses documented functions which should be trustworthy:\\ \\  \\  This method is almost as simple as the preceding one, but works **only under Windows 2000 Professional, Windows XP or Windows Vista or later**. It also returns the MAC address of the primary adaptor, but uses documented functions which should be trustworthy:\\ \\ 
 +<code bb4w>
         INSTALL @lib$+"SOCKLIB"         INSTALL @lib$+"SOCKLIB"
         PROC_initsockets         PROC_initsockets
Line 46: Line 49:
  
         PRINT "MAC address = " MACaddress$         PRINT "MAC address = " MACaddress$
 +</code>
 \\  \\ 
 ===== Method 3 ===== ===== Method 3 =====
 \\  This method works on versions of Windows from Windows 95 to Windows XP, but //only if NetBIOS is installed//. It is also documented as being "unreliable" on Windows 95, 98 and Me. Therefore it is generally not a good choice:\\ \\  \\  This method works on versions of Windows from Windows 95 to Windows XP, but //only if NetBIOS is installed//. It is also documented as being "unreliable" on Windows 95, 98 and Me. Therefore it is generally not a good choice:\\ \\ 
 +<code bb4w>
         NCBNAMSZ = 16         NCBNAMSZ = 16
         NCBRESET = &32         NCBRESET = &32
Line 80: Line 85:
  
         PRINT "MAC address = " MACaddress$         PRINT "MAC address = " MACaddress$
 +</code>
 \\  \\ 
 ===== Method 4 ===== ===== Method 4 =====
 \\  This method can return the MAC address of multiple network adaptors, so is useful if you need information other than just for the primary adaptor. It works on versions of Windows from 98 to Vista or later (with acknowledgements to Jon Ripley on whose code this is based):\\ \\  \\  This method can return the MAC address of multiple network adaptors, so is useful if you need information other than just for the primary adaptor. It works on versions of Windows from 98 to Vista or later (with acknowledgements to Jon Ripley on whose code this is based):\\ \\ 
 +<code bb4w>
         SYS "LoadLibrary", "iphlpapi.dll" TO iphlpapi%         SYS "LoadLibrary", "iphlpapi.dll" TO iphlpapi%
         SYS "GetProcAddress", iphlpapi%, "GetAdaptersInfo" TO GetAdaptersInfo%         SYS "GetProcAddress", iphlpapi%, "GetAdaptersInfo" TO GetAdaptersInfo%
Line 115: Line 122:
           PRINT "MAC address = " MACaddress$           PRINT "MAC address = " MACaddress$
         NEXT i%         NEXT i%
 +</code>
 \\  \\ 
 ===== Method 5 ===== ===== Method 5 =====
 \\  This method uses SNMP (the **Simple Network Management Protocol**). It too can return the MAC address of more than one adaptor, and runs on Windows 2000, Windows XP and Windows Vista or later. It uses the most complex code of any of the methods:\\ \\  \\  This method uses SNMP (the **Simple Network Management Protocol**). It too can return the MAC address of more than one adaptor, and runs on Windows 2000, Windows XP and Windows Vista or later. It uses the most complex code of any of the methods:\\ \\ 
 +<code bb4w>
         SYS "LoadLibrary", "INETMIB1.DLL" TO inetmib1%         SYS "LoadLibrary", "INETMIB1.DLL" TO inetmib1%
         SYS "GetProcAddress", inetmib1%, "SnmpExtensionInit" TO `SnmpExtensionInit`         SYS "GetProcAddress", inetmib1%, "SnmpExtensionInit" TO `SnmpExtensionInit`
Line 204: Line 213:
         SYS "GlobalFree", varBind.name0.pids%         SYS "GlobalFree", varBind.name0.pids%
         SYS "GlobalFree", varBind.name1.pids%         SYS "GlobalFree", varBind.name1.pids%
 +</code>
finding_20the_20mac_20address.1522502361.txt.gz · Last modified: 2024/01/05 00:17 (external edit)