Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to retrieve a NIC Mac Address and its IP
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
00996178
Message ID:
00996318
Vues:
31
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform