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:
00996415
Vues:
27
>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.

Well, sorry I am just writing over the other program, I did not even change the variable names, but I have not much time.

See if the property NetConnectionID is what you want:
lparameters tcComputer, tcUser, tcPassword
local loWMI, loConnections, loConnection, 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)
    loConnections    = loWMI.ExecQuery("select * from Win32_NetworkAdapter where availability=3 and MACAddress<>null")
	clear
	  ? '-------------------------------------------------------'
    For Each loConnection in loConnections
    	with loConnection
		  ? .AdapterType
		  ? .AdapterTypeID
		  ? .Availability
		  ? .Caption
		  ? .Description
		  ? .DeviceID
		  ? .MACAddress
		  ? .Name
		  ? .NetConnectionID
		  ? .ServiceName
		  ? '******************************************************'
    	endwith
    Endfor
endif
You probably will want to make the SQL filter more detalied, for example, AdapterTypID = 0 (for Ethernet 802.3)
"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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform