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); Syntax
interface IWbemServices : IUnknown
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 [C++]
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
| Client | Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation 4.0 SP4 and later, Windows Me, Windows 98, or Windows 95. |
| Server | Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0 SP4 and later. |
| Header | Declared in Wbemcli.h; include Wbemidl.h. |
| Library | Use Wbemuuid.lib. |
| DLL | Requires Fastprox.dll. Requires Esscli.dll. Requires Framedyn.dll. Requires Ntevt.dll. Requires Stdprov.dll. Requires Viewprov.dll. Requires Wbemcomn.dll. Requires Wbemcore.dll. Requires Wbemess.dll. Requires Wbemsvc.dll. Requires Wmipicmp.dll. Requires Wmidcprv.dll. Requires Wmipjobj.dll. Requires Wmiprvsd.dll. |
See Also
COM API for WMI
Manipulating Class and Instance Information
Send comments about this topic to Microsoft
Build date: 8/20/2008