Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MAC Address
Message
From
04/08/1999 21:00:27
 
 
To
04/08/1999 20:33:10
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Miscellaneous
Thread ID:
00249967
Message ID:
00250025
Views:
31
>>>Can you obtain the ethernet address using native VFP code? I found an article on how to do it in C and noticed that it uses structures. Has anyone done this?
>>>
>>
>>The easiest ways are to either use the WinSock Active control to retrieve the MAC address through ActiveX automation, or to dump the output of IPCONFIG /ALL to a file and parse the results on a line-by-line basis (you can issue a command line switch to dump the output to a standard file; IPCONFIG /HELP will provide the basic details.)
>>
>>Realize that not all systems have real MAC addresses, and you may have more than one MAC address on systems with more than one LAN adapter.
>>
>>You can access Win32 API calls through VFP using structures built in static memory blocks; you can look at my CLSHEAP library, Paul-Vlad Tatavu's POINTERS class, and especially Christof Lange's STRUCT class to see several approaches to implementing structures beyond the simple declarations available directly through VFP's DECLARE...DLL syntax.
>
>Ed,
>
>The MAC address is available from IPCONFIG (NT) and WINIPCFG (95-98) and can easily be dumped to a file (although messy). I was unable to get Winsock to deliver the MAC address to me but it does have the IP address. I got your message while I was reading Christof's doc's and might play with that some (although it is beyond my current understanding).
>
>Since this question has been posted several times and the C code is provided in the Q118623 article - I figured it would be a snap for you <grin>...
>

The NetBIOS code in the article is not completely trivial; I haven't needed to implement anything in VFP that needed a MAC address, and in C++, I'd use the NdisReadNetworkAddress() API call IAC, which uses C++ style calling conventions and couldn't be called directly via VFP-only code. Maybe someone else has the time to develop the necessary classes for you.

You might try looking for the value in the registry if you don't want to write the API code yourself and don't want to parse the output from IPCONFIG; try the HKEY_LOCAL_MACHINE\Enum subkeys.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform