Deutsch | English | Español | Français |
Italiano | 日本語 | 한국어 | Português |
Pусский | 简体中文 | 繁體中文 |
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);
Members
The IWbemServices interface inherits from the IUnknown interface. IWbemServices also has these types of members:
Methods
The IWbemServices interface has these methods.
Method | Description |
---|---|
CancelAsyncCall |
Cancels a currently executing asynchronous call. |
CreateClassEnum |
Creates a class enumerator. |
CreateClassEnumAsync |
Creates a class enumerator that executes asynchronously. |
CreateInstanceEnum |
Creates an instance enumerator. |
CreateInstanceEnumAsync |
Creates an instance enumerator that executes asynchronously. |
DeleteClass |
Deletes a class. |
DeleteClassAsync |
Deletes a class and receives confirmation asynchronously. |
DeleteInstance |
Deletes a specific instance of a class. |
DeleteInstanceAsync |
Deletes an instance and provides confirmation asynchronously. |
ExecMethod |
Executes an object method. |
ExecMethodAsync |
Executes an object method asynchronously. |
ExecNotificationQuery |
Executes a query to receive events. |
ExecNotificationQueryAsync |
Executes a query to receive events asynchronously. |
ExecQuery |
Executes a query to retrieve classes or instances. |
ExecQueryAsync |
Executes a query to retrieve classes or instances asynchronously. |
GetObject |
Retrieves an object—an instance or class definition. |
GetObjectAsync |
Asynchronously retrieves an object—an instance or class definition. |
OpenNamespace |
Opens a specific child namespace for operations. |
PutClass |
Creates or updates a class definition. |
PutClassAsync |
Asynchronously creates or updates a class definition. |
PutInstance |
Creates or updates an instance of a specific class. |
PutInstanceAsync |
Asynchronously creates or updates an instance of a specific class. |
QueryObjectSink |
Allows a caller to obtain a notification handler sink. |
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
For multiple C++ examples that use IWbemServices, see the WMI C++ Application Examples section.
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 Vista |
---|---|
Minimum supported server |
Windows Server 2008 |
Header |
|
Library |
|
DLL |
|
See also
- COM API for WMI
- Creating WMI Providers
- Manipulating Class and Instance Information
- Supplying Data to WMI by Writing a Provider