Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MAC Address
Message
From
20/04/2001 10:06:14
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00497050
Message ID:
00497853
Views:
62
Larry,
I haven't heard back yet, but for those that may have CS access, the details for the MACAddress.OCX are:
The CompuServe DevApps forum. It was posted by the "Fayette Co Clerk Account" (Compuserve 102227,3510 or 102227.3510@compuserve.com). Here is the posted info:

Summary: This free control will query the network card on the local computer and retrieve its MAC address. The control as one property MACAddress and works with either IP or NetBeui protocols. On NT/2000 you can have either protocol loaded, however, on Win9x you must have Netbeui. Currently it does not support IP under Win9x.
--------------------------------------------
Type: Binary
Contributor: Fayette Co Clerk Account (102227,3510)
Keywords: MAC NIC Network Card Physical Address
Section: ActiveX Components/OLE


The following routine is how I call it (Notes: It occasionally gives a "wrong" result - the reason for the retries, I tried variants on this code and I finally got this to work, but if someone's got a better implementation, I'm always willing to learn.)
* Program....: GETMAC.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: February 27, 2001

#DEFINE c_nMaxTries 3

PRIVATE oForm1, lcMACAddress, lnLength, lnTries, lCSaveAddress

oform1 = CREATEOBJECT("dummyform")

lnTries = 0
DO WHILE lnTries < c_nMaxTries
   lcMACAddress = oForm1.Olecontrol1.MACAddress && returned in form of XX-XX-XX-XX-XX-XX
   lcMACAddress = strtran(lcMACAddress, "-", "") && Kill the dashes
   lnLength = LEN(lcMACAddress)
   DO CASE
   CASE lnLength = 12
      * Good enuff - just one NIC and we got the value
      EXIT
		   
   CASE lnLength = 25
      * Got two addresses - just use the last one if it's 12 long (first probably a modem)
      IF AT(";", lcMACAddress) = 13
         lcMACAddress = RIGHT(lcMACAddress, 12)
         EXIT
      ENDIF
		
   OTHERWISE && Could be a Bad Call - try again for c_MaxTries
      * Got more than 2 or got wrong length
      IF MOD((lnLength+1), 13) = 0 && Probably good
         IF RAT(";", lcMACAddress) = 13 && just use the last one if it's 12 long
            lcMACAddress = RIGHT(lcMACAddress, 12)
            EXIT
         ENDIF
      ENDIF
		
   ENDCASE
   lnTries = lnTries + 1

ENDDO && .T.
IF LEN(lcMACAddress) <> 12
   lcMACAddress = " " && make it empty - I can't get a good "read"
ENDIF && LEN(lcMACAddress) <> 12

RETURN lcMACAddress

*************************************
DEFINE CLASS dummyform AS form

   DoCreate = .T.
   Caption = "dummyform"
   Name = "dummyform"

   ADD OBJECT olecontrol1 AS MYMAC WITH ;
      Top = 8, ;
      Left = 8, ;
      Height = 100, ;
      Width = 100, ;
      Name = "Olecontrol1"

ENDDEFINE

*************************************
DEFINE CLASS MYMAC as OLEControl

   OleClass = 'MACAddressOCX.MACAddress'

ENDDEFINE

*!* EOP: GETMAC.PRG
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform