Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

IWbemServices::GetObject method

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

Syntax


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

Parameters

strObjectPath [in]

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.

lFlags [in]

The following flags affect the behavior of this method.

FlagMeaning
WBEM_FLAG_USE_AMENDED_QUALIFIERS

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.

WBEM_FLAG_RETURN_WBEM_COMPLETE

This flag makes this a synchronous call.

WBEM_FLAG_RETURN_IMMEDIATELY

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

WBEM_FLAG_DIRECT_READ

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

 

pCtx [in]

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.

ppObject [out]

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.

ppCallResult [out]

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 table 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.

Return codeDescription
WBEM_E_ACCESS_DENIED

The current user does not have permission to access the object.

WBEM_E_FAILED

This indicates other unspecified errors.

WBEM_E_INVALID_CLASS

The specified class does not exist.

WBEM_E_INVALID_PARAMETER

A specified parameter is not valid.

WBEM_E_INVALID_OBJECT_PATH

The specified path was not valid.

WBEM_E_NOT_FOUND

The requested object could not be found.

WBEM_E_OUT_OF_MEMORY

There was not enough memory to complete the operation.

WBEM_E_SHUTTING_DOWN

Windows Management service was probably stopped and restarted. A new call to ConnectServer is needed.

WBEM_E_TRANSPORT_FAILURE

This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management.

WBEM_S_NO_ERROR

The call succeeded.

 

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

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

IWbemServices
Creating a Class
Describing the Location of a WMI Object
Retrieving an Error Code
IWbemCallResult
IWbemServices::GetObjectAsync

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.