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:
00996429
Vues:
26
Hugo,
Thank you for the reply. I have to tell you that I am acctually not using VFP. I am using .NET but the methods seemed so similar. I noticed after reading your post again that you query Win32_NetworkAdapter in VFP. I query Win32_NetworkAdapterConfiguration in .NET which I guess does not expose NetConnectionID or AdapterTypeID.

Does NetConnectionID return Local Area Connection and Local Area Connection 2 if you have 2 LAN connections?

I guess I have to research more what the difference in method between VFP and .NET

Einar

>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)
Semper ubi sub ubi.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform