Re: how to read MAC address using WMI MSNdis
- From: Gerry Hickman <gerry666uk@xxxxxxxxxxx>
- Date: Wed, 17 Aug 2005 19:42:31 +0100
Hi,
Looking at some of these examples, it seems that this is using Win API and DDK as oppose to pure WMI? I can't find anything related to NDIS in the WMI documentation.
According to the docs, you can get the MAC adddress quite easily from the Win32_NetworkAdapterConfiguration class.
A more interesting question, is how can you enable/disable a NIC or change it's speed using pure WMI?
Arkady Frenkel wrote:
You can't get property as an instance AFAIK , btw you can look at my example ( as origin I used project I mentioned ) : http://www.ndis.com/faq/Contributors/CheckNet/default.htm
Arkady
"Tom K" <TomK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:40CD0274-E3FC-4F09-B2F4-68A12C36BA98@xxxxxxxxxxxxxxxx
Hi Arkady,
I have taken a look at the example but I still do not understand exactly what steps I must take to get an Instance of class that is a property of another WMI class.
In my case, the NdisCurrentAddress property of
MSNdis_EthernetCurrentAddress is an instance of MSNdis_NetworkAddress. If I
use IWbemClassObject::Get i will get the property as a VARIANT. I need to
get this property as an instance.
I experimented with the IWbemService::GetObject function but I cannot figure
out how to make it get an instance that is a property of another class.
Thanks, Tom
"Arkady Frenkel" wrote:
Try \src\general\wmicli\console from DDK , as example it use MSNdis_MediaSupported
Arkady
"Tom K" <TomK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0D16608E-DCD0-41FB-AB18-4212E950864E@xxxxxxxxxxxxxxxx
I am trying to read a network adapters MAC address using WMI.
A code snippet is below. I query the MSNdis_EthernetCurrentAddress class
to get the address. All is good until I have to use the
MSNdis_NetworkAddress.
I don't know what to do with the value returned by:
hr = object->Get( L"NdisCurrentAddress", 0, &var_val, NULL, NULL );
I know that the return (var_val) is a class of type MSNdis_NetworkAddress.
How do I instantiate/use this class. I am sorry is this is dumb question
but
I am new to COM and very new to WMI.
Thanks,
Tom
code snippet start -------->
hr = service->ExecQuery( _bstr_t(L"WQL"), _bstr_t(L"SELECT * FROM MSNdis_EthernetCurrentAddress"), WBEM_FLAG_FORWARD_ONLY, NULL, &enumerator ); if ( SUCCEEDED( hr ) ) { // read the first instance from the enumeration (only one on single processor machines) IWbemClassObject* processor = NULL; ULONG retcnt; VARIANT var_val; IWbemClassObject* object = NULL; while(hr != WBEM_S_NO_MORE_DATA && hr != S_FALSE) { hr = enumerator->Next( WBEM_INFINITE, 1L, &object, &retcnt ); if ( SUCCEEDED( hr ) ) { if ( retcnt > 0 ) {
hr = object->Get( L"InstanceName", 0, &var_val, NULL, NULL );
_bstr_t str = var_val.bstrVal; std::cerr << str << std::endl;
hr = object->Get( L"NdisCurrentAddress", 0, &var_val, NULL, NULL ); std::cerr << "got something: ";
<--------- code snippet end
-- Gerry Hickman (London UK) .
- Follow-Ups:
- Re: how to read MAC address using WMI MSNdis
- From: Pavel A.
- Re: how to read MAC address using WMI MSNdis
- From: Arkady Frenkel
- Re: how to read MAC address using WMI MSNdis
- References:
- how to read MAC address using WMI MSNdis
- From: Tom K
- Re: how to read MAC address using WMI MSNdis
- From: Arkady Frenkel
- Re: how to read MAC address using WMI MSNdis
- From: Tom K
- Re: how to read MAC address using WMI MSNdis
- From: Arkady Frenkel
- how to read MAC address using WMI MSNdis
- Prev by Date: Re: Win32_NetworkAdapterConfiguration - SetDNSServerSearchOrder()
- Next by Date: Re: StdRegProv and SetDwordValue
- Previous by thread: Re: how to read MAC address using WMI MSNdis
- Next by thread: Re: how to read MAC address using WMI MSNdis
- Index(es):
Relevant Pages
|