The IWbemServices interface is used by clients and providers to access WMI services. The interface is implemented by WMI and WMI providers, and is the primary WMI interface.
IWbemClassObject *pObj = NULL;
//The pWbemSvc pointer is of type IWbemServices*
pWbemSvc->GetObject(L"path", 0, 0, &pObj, 0);
Methods
The IWbemServices interface inherits the methods of the IUnknown interface.
In addition, IWbemServices defines the following methods.
Remarks
Providers that implement the
IWbemServices interface must follow the documented semantics of each method that they implement; and providers must support the specified error return codes. WMI implements all of the methods, and typically, each provider implements a small subset of the available functionality on the interface. Providers must return WBEM_E_PROVIDER_NOT_CAPABLE for any method that they do not implement.
All outbound interface pointers from any
IWbemServices method should be initialized to NULL before calling the interface method. For example,
calls to the IWbemServices::GetObject method return an
IWbemClassObject interface pointer that should be pre-initialized to NULL before the IWbemServices::GetObject method call.
Examples
The following code example shows how a provider can get an
IWbemServices pointer. The code requires the following #include statements and references to compile.
#include <iostream>
using namespace std;
#include <wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
IWbemLocator *pIWbemLocator = NULL;
HRESULT hRes = CoCreateInstance (
CLSID_WbemAdministrativeLocator,
NULL ,
CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER ,
IID_IUnknown ,
( void ** ) &pIWbemLocator
) ;
IWbemServices *pWbemServices = NULL;
if (SUCCEEDED(hRes))
{
hRes = pIWbemLocator->ConnectServer(
L"root\\CIMV2", // Namespace
NULL, // Userid
NULL, // PW
NULL, // Locale
0, // flags
NULL, // Authority
NULL, // Context
&pWbemServices
);
pIWbemLocator->Release(); // Free memory resources.
// Use pWbemServices
}
// Clean up
pWbemServices->Release();
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | Wbemcli.h (include Wbemidl.h) |
| Library | Wbemuuid.lib |
| DLL | Fastprox.dll, Esscli.dll, Framedyn.dll, Ntevt.dll, Stdprov.dll, Viewprov.dll, Wbemcomn.dll, Wbemcore.dll, Wbemess.dll, Wbemsvc.dll, Wmipicmp.dll, Wmidcprv.dll, Wmipjobj.dll, Wmiprvsd.dll |
See Also
- COM API for WMI
- Manipulating Class and Instance Information
Send comments about this topic to Microsoft
Build date: 11/3/2009