Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To capture unique identification in server.
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00923767
Message ID:
00923903
Views:
19
>>Hi !!
>>
>>How Get the MAC number of the network card ?
>>
>>
>>With API windows ?
>>
>>
>>Thank.
>>
>>Lázaro Santos.
>
>If you are using XP, you can use WMI to do this, but the problem is, of which network card? Servers might have more than one, and I think this will be true more often than not.


Actually, you need at least NT4 SP 4 or newer, I got confused. The code might look like this (if connecting to another PC, you need admin rights on the domain the way this is coded, you'll need error handling too)
lparameters tcComputer
local loWMI, colNetAdapters, loNetAdapter, lcComputer

lcComputer	= Iif(Vartype(tcComputer) = "C" and not Empty(tcComputer), tcComputer, ".")

loWMI		= Getobject("winmgmts://" + lcComputer + "/root/cimv2")
loNetAdapters	= loWMI.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled=True")

For Each loNetAdapter in loNetAdapters
	? loNetAdapter.Caption, loNetAdapter.MACAddress
	for each lcIP in loNetAdapter.IPAddress
		?? Chr(9), lcIP
	endfor
Endfor
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform