Re: how to read MAC address using WMI MSNdis



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)
.



Relevant Pages

  • Re: how to read MAC address using WMI MSNdis
    ... > DDK as oppose to pure WMI? ... As API that enable or devcon examples from DDK for first and if driver ... > Arkady Frenkel wrote: ...
    (microsoft.public.win32.programmer.wmi)
  • Coding for WMI
    ... connects to WMI on the ... IWbemClassObject* pInParamsDefinition = NULL; ... This is part of code and my defined error message number that pops up ... an adapter-that is, for which adapter is it issuing "EnableDHCP" ...
    (microsoft.public.win32.programmer.wmi)
  • How to add a user to Terminal Services RDP permissions by using WMI on LongHorn server
    ... permission / security by using WMI. ... // Obtain the initial locator to WMI ... IWbemClassObject *pclsInstObj = NULL; ... VARIANT varTerminalName; ...
    (microsoft.public.windows.terminal_services)
  • IWbemClassObject::Put a method
    ... MOF file has following definitions, ... [WMI, ... void MySetMethod( ... IWbemClassObject *pIWbemClassObject = NULL; ...
    (microsoft.public.windowsxp.wmi)
  • IWbemClassObject::Put failing for a method parameter
    ... MOF file has following definitions, ... [WMI, ... void MySetMethod( ... IWbemClassObject *pIWbemClassObject = NULL; ...
    (microsoft.public.windowsxp.wmi)