IEnumWbemClassObject interface (wbemcli.h)
The IEnumWbemClassObject interface is used to enumerate Common Information Model (CIM) objects and is similar to a standard COM enumerator.
An object of type IEnumWbemClassObject is received from calls to the following methods:
- IWbemServices::ExecQuery
- IWbemServices::CreateInstanceEnum
- IWbemServices::CreateClassEnum
- IWbemServices::ExecNotificationQuery
Inheritance
The IEnumWbemClassObject interface inherits from the IUnknown interface. IEnumWbemClassObject also has these types of members:
Methods
The IEnumWbemClassObject interface has these methods.
IEnumWbemClassObject::Clone The IEnumWbemClassObject::Clone method makes a logical copy of the entire enumerator, retaining its current position in an enumeration. |
IEnumWbemClassObject::Next Use the IEnumWbemClassObject::Next method to get one or more objects starting at the current position in an enumeration. |
IEnumWbemClassObject::NextAsync Use the NextAsync method when a controlled asynchronous retrieval of objects to a sink is required. |
IEnumWbemClassObject::Reset The IEnumWbemClassObject::Reset method resets an enumeration sequence back to the beginning. Because CIM objects are dynamic, calling this method does not necessarily return the same list of objects that you obtained previously. |
IEnumWbemClassObject::Skip You can use the IEnumWbemClassObject::Skip method to move the current position in an enumeration ahead by a specified number of objects. Also, this affects subsequent calls to NextAsync, but it does not affect pending deliveries begun with NextAsync. |
Remarks
IEnumWbemClassObject is the object returned from a WMI query, and is used to enumerate through the returned values. For more information on how to use this class, see Querying WMI and Enumerating WMI.
Examples
The following C++ code sample describes how to retrieve an IEnumWbemClassObject.
void ExecQuerySync(IWbemServices *pSvc)
{
// Query for all users and groups.
BSTR Language = SysAllocString(L"WQL");
BSTR Query = SysAllocString(L"SELECT * FROM __Namespace");
// Initialize the IEnumWbemClassObject pointer.
IEnumWbemClassObject *pEnum = 0;
// Issue the query.
HRESULT hRes = pSvc->ExecQuery(
Language,
Query,
WBEM_FLAG_FORWARD_ONLY, // Flags
0, // Context
&pEnum
);
SysFreeString(Query);
SysFreeString(Language);
if (hRes != 0)
{
printf("Error\n");
return;
}
ULONG uTotal = 0;
// Retrieve the objects in the result set.
for (;;)
{
IWbemClassObject *pObj = 0;
ULONG uReturned = 0;
hRes = pEnum->Next(
0, // Time out
1, // One object
&pObj,
&uReturned
);
uTotal += uReturned;
if (uReturned == 0)
break;
// Use the object.
// ...
// Release it.
// ===========
pObj->Release(); // Release objects not owned.
}
// All done.
pEnum->Release();
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | wbemcli.h (include Wbemidl.h) |