IWbemServices::GetObject method (wbemcli.h)

The IWbemServices::GetObject method retrieves a class or instance. This method only retrieves objects from the namespace associated with the current IWbemServices object.


HRESULT GetObject(
  [in]  const BSTR       strObjectPath,
  [in]  long             lFlags,
  [in]  IWbemContext     *pCtx,
  [out] IWbemClassObject **ppObject,
  [out] IWbemCallResult  **ppCallResult


[in] strObjectPath

Path of the object to retrieve. If this is NULL, an empty object is returned that can become a new class. For more information, see Creating a Class.

[in] lFlags

The following flags affect the behavior of this method.


If this flag is set, WMI retrieves the amended qualifiers stored in the localized namespace of the current connection's locale. If not set, only the qualifiers stored in the immediate namespace are retrieved.


This flag makes this a synchronous call.


This flag makes this a semisynchronous call. You must provide a valid pointer for the ppCallResult parameter. For more information, see Calling a Method.


This flag causes direct access to the provider for the class specified without any regard to its parent class or subclasses.

[in] pCtx

Typically NULL. Otherwise, this is a pointer to an IWbemContext object that may be used by the provider that is producing the requested class or instance. The values in the context object must be specified in the documentation for the provider in question. For more information about this parameter, see Making Calls to WMI.

[out] ppObject

If not NULL, this receives the object, if it is found. The returned object has a positive reference count. The caller must use Release when the object is no longer needed. In all cases of error, this parameter is set to point to NULL.

[out] ppCallResult

If NULL, this parameter is not used. If the lFlags parameter contains WBEM_FLAG_RETURN_IMMEDIATELY, this call returns immediately with WBEM_S_NO_ERROR. The ppCallResult parameter receives a pointer to a new IWbemCallResult object, which can then be polled to obtain the result using the GetCallStatus method. The caller can call IWbemCallResult::GetResultObject to retrieve the object when it becomes available.

Return value

This method returns an HRESULT indicating the status of the method call. The following list lists the value contained within an HRESULT.

On failure, you can obtain any available information from the COM function GetErrorInfo.

COM-specific error codes also may be returned if network problems cause you to lose the remote connection to Windows Management.


Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header wbemcli.h (include Wbemidl.h)
Library Wbemuuid.lib
DLL Fastprox.dll; Esscli.dll; FrameDyn.dll; FrameDynOS.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

Creating a Class

Describing the Location of a WMI Object




Retrieving an Error Code