Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get Network Adapter Address (MAC?)
Message
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00477977
Message ID:
00560916
Views:
44
I have run this code multiple times on a Dell 8100 Inspiron, Win2k machine, and I get a totally different return value every time. I have found absolutely nothing that can consistently return the correct MAC address of the primary adapter.

P.S. I do realize this thread is 7 months old. I am still searching for a way to do this and finally found this and other thread with the search engine.

>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.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform