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
Arkady
"Tom K" <To...@discussions.microsoft.com> wrote in message
news:0D16608E-DCD0-41FB...@microsoft.com...
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
"Tom K" <To...@discussions.microsoft.com> wrote in message
news:40CD0274-E3FC-4F09...@microsoft.com...
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:
--
Gerry Hickman (London UK)
> 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?
As API that enable or devcon examples from DDK for first and if driver
support setting of speed by OID ( OID_GEN_LINK_SPEED ) that can be done ,
otherwise -no
Arkady
>>DDK as oppose to pure WMI?
> Do you mean script ?
> WMI really is COM object so what you see is real COM based of C ( even not
> C++ ) .It have two parts : one is user mode service and second wmilib.sys -
> driver ( kernel ) part
No, I don't mean script. I mean I can't find the MSNDIS classes
documented anywhere in the WMI documentation on MSDN, in fact I can't
them documented ANYWHERE on Microsoft's site! The crazy thing, is that I
can connect to root\wmi and enum the class thanks to
<http://www.ndis.com/faq/QA01050301/default.htm>
Aha. So I am not alone ...
> According to the docs, you can get the MAC adddress quite easily from the Win32_NetworkAdapterConfiguration class.
Yes, the quick way is vbscript or wmic.
> A more interesting question, is how can you enable/disable a NIC or change it's speed using pure WMI?
No. There is no WMI object that can enable or disable physical device, including NIC.
If you really want it... write it yourself.
Changing the link speed in runtime is impossible, because the link speed OID is read only.
You need to change the speed parameter in the registry, and then (see above)
disable the NIC and re-enable it.
Unfortunately this parameter will have standard names and values only in Vista,
currently only the NIC vendors know how to set it.
Regards,
--PA
"Gerry Hickman" <gerry...@yahoo.co.uk> wrote in message
news:%23ktEzK$oFHA...@TK2MSFTNGP12.phx.gbl...
Did you ever figure out the issue of having a VARIANT and needing it to
be an IWbemClassObject?
I'm running in to the same thing trying to get the
MSNdis_EthernetPermanentAddress.
Rod
Here's the snippet once we have the NdisPermanentAddress object in a
variant pVal.
IWbemClassObject *pNetworkAddress;
hres = pVal.punkVal->QueryInterface( IID_IWbemClassObject,
(PVOID *) &pNetworkAddress);
BSTR addressName = SysAllocString(L"Address");
VARIANT pAddress;
VariantClear(&pAddress);
hres = pNetworkAddress->Get(addressName, 0L, &pAddress, NULL, NULL);
pNetworkAddress->Release();
char permAddress[6];
for (long index = 0; index < 6; index++) {
SafeArrayGetElement(pAddress.parray, &index, &permAddress[index]);
}
<rkr...@gmail.com> wrote in message
news:1124994109.2...@f14g2000cwb.googlegroups.com...