Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to retrieve a NIC Mac Address and its IP
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Environment versions
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00996178
Message ID:
00996318
Views:
30
Hugo,
Do you know if there is a way to get the name of the network connection (the name column from the network connections in the control panel. This is a user defined name , i.e. the user can rename the network connection) I have had requests to get the name instead of the caption or the description.

Einar
>
>
>lparameters tcComputer, tcUser, tcPassword
>local loWMI, colNetAdapters, loNetAdapter, lcComputer
>
>lcComputer    = Iif(Vartype(tcComputer) = "C" and not Empty(tcComputer), tcComputer, ".")
>lcUser        = iif(vartype(tcUser) = "C", tcUser, "")
>lcPassword    = iif(vartype(tcPassword) = "C", tcPassword, "")
>
>lcDomain     = getenv('USERDNSDOMAIN')
>loLocator    = createobject('WbemScripting.SWbemLocator')
>try
>    if empty(lcUser)
>        loWMI        = loLocator.ConnectServer(lcComputer)
>    else
>        loWMI        = loLocator.ConnectServer(lcComputer, 'root\cimv2', lcUser, lcPassword)
>    endif
>catch
>    loWMI        = null
>endtry
>
>if not isnull(loWMI)
>    loNetAdapters    = loWMI.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled='true' and DNSDomain='" + lcDomain + "'"")
>
>    For Each loNetAdapter in loNetAdapters
>        ? loNetAdapter.Caption, loNetAdapter.MACAddress
>        for each lcIP in loNetAdapter.IPAddress
>            ?? Chr(9), lcIP
>        endfor
>        ?
>    Endfor
>endif
>
>
>This code contains parts that are not required if you are interested just in the local computer, it is intended to be used to get MAC/IP(s) of any computer in the network, if you have enough rights. You can see that the IP can be more than one, that is why there is an inner loop.
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform