Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Network Adapter Address (MAC?)
Message
 
 
To
21/02/2001 10:32:42
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00477977
Message ID:
00477983
Views:
48
>I've been unable to find any way to reliably get the current Adapter address. While under NT I find it appears in the registry (although it's not straight forward), the technique doesn't work under Win 95/98.
>e.g.
>[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\N1001\Parameters]
>"ProposeQNFTAddress"="0008C7DF8B6E"
>
>While I could run IPCONFIG.EXE /ALL > c:\IPCONFIG.TXT in a DOS window and parse out the information, this seems like a quite inelegant solution, and it's obviously getting it from somewhere.
>
>Rick

Rick,
Because a GUID uses the MAC address of the primary network adapter to make sure its unique, you can create a GUID and parse it for the MAC address.
clear
local lcguid
lcguid = GetGUID()
return substr(lcguid,26,2)+'-'+substr(lcguid,28,2)+'-'+substr(lcguid,30,2);
	+'-'+substr(lcguid,32,2)+'-'+substr(lcguid,34,2)+'-'+substr(lcguid,36,2)

function GetGUID
local lcStrucGUID, lcGUID, lnsize
declare integer CoCreateGuid in Ole32.dll string @lcGUIDStruc
declare integer StringFromGUID2 in Ole32.dll string lcGUIDStruc, string @lcGUID, long lnSize

lcStrucGUID=space(16)
lcGUID=space(80)
lnSize=40

if CoCreateGuid(@lcStrucGUID) # 0 then
   return ""
endif
if StringFromGUID2(lcStrucGUID,@lcGuid,lnSize) = 0 then
  return ""
endif
return strconv(left(lcGUID,76),6)
GetGUID code was posted by John Koziol (who I believe got it from Rick Strahl) here last year.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform