IWbemServices::DeleteInstanceAsync method

The IWbemServices::DeleteInstanceAsync method asynchronously deletes an instance of an existing class in the current namespace. The confirmation or failure of the operation is reported through the IWbemObjectSink interface implemented by the caller.

Syntax

HRESULT DeleteInstanceAsync(
  const BSTR      strObjectPath,
  long            lFlags,
  IWbemContext    *pCtx,
  IWbemObjectSink *pResponseHandler
);

Parameters

strObjectPath

Valid BSTR that contains the object path of the object to be deleted.

lFlags

WBEM_FLAG_SEND_STATUS registers with Windows Management a request to receive intermediate status reports through the client's implementation of IWbemObjectSink::SetStatus. Provider implementation must support intermediate status reporting, for this flag to change behavior. Note that the WBEM_FLAG_USE_AMENDED_QUALIFIERS flag cannot be used here.

pCtx

Typically NULL. Otherwise, this is a pointer to an IWbemContext object that may be used by the provider that is deleting the instance. The values in the context object must be specified in the documentation for the provider in question.

pResponseHandler

Pointer to the caller's implementation of IWbemObjectSink. This handler receives the status of the delete operation as it becomes available through the SetStatus method. If any error code is returned, then the supplied IWbemObjectSink pointer is not used. If WBEM_S_NO_ERROR is returned, then the user's IWbemObjectSink implementation is called to indicate the result of the operation. Windows Management only calls AddRef on the pointer in cases where WBEM_S_NO_ERROR returns. In cases where an error code returns, the reference count is the same as on entry. For more information, see Calling a Method.

Return Value

This method returns an HRESULT that indicates the status of the method call. The following list lists the value contained withinan HRESULT.

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

If DeleteInstanceAsync returns WBEM_S_NO_ERROR, WMI waits for a result from the SetStatus method of the response handler. WMI waits indefinitely on a local connection, or until a remote connection time-out occurs.

Other error conditions are reported asynchronously to the object sink supplied by the pResponseHandler parameter.

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

Note  Clients that call DeleteInstanceAsync must always expect the results of the call to be reported using their IWbemObjectSink::Indicate method.
 
Note  When the instance pointed to by strObjectPath belongs to a class that is a member of a class hierarchy, the success of DeleteInstanceAsync depends on the topmost non-abstract provider. For a detailed explanation of the dependencies involved that determine the success of this operation, see Remarks in IWbemServices::DeleteInstance.
 

Remarks

An instance provider can report success or failure with either the return code from DeleteInstanceAsync or through a call to SetStatus made through pResponseHandler. If sent to SetStatus, the return code sent to the sink through pResponseHandler takes precedence. Because the callback might not be returned at the same authentication level as the client requires, it is recommended that you use semisynchronous instead of asynchronous communication. If you require asynchronous communication, see Calling a Method.

For more information about using methods semisynchronously, see IWbemServices::DeleteInstance and Calling a Method.

Requirements

   
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

Calling a Method

Describing an Instance Object Path

IWbemServices

IWbemServices::DeleteInstance