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( [in] const BSTR strObjectPath, [in] LONG lFlags, [in] IWbemContext *pCtx, [in] IWbemObjectSink *pResponseHandler );
Parameters
- strObjectPath [in]
-
Valid BSTR that contains the object path of the object to be deleted.
- lFlags [in]
-
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 [in]
-
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 [in]
-
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 table lists the value contained within an 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.
| Return code | Description |
|---|---|
|
This indicates other unspecified errors. |
|
The specified class was not valid. |
|
A specified parameter is not valid, or amended qualifiers were specified. |
|
There was not enough memory to complete the operation. |
|
Windows Management service was probably stopped and restarted. A new call to ConnectServer is needed. |
|
This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management. |
|
The object path specified is not valid or is a class object path. |
|
If the instance specified cannot be deleted. |
|
The provider could not recognize the instance. |
|
The provider cannot delete instances regardless of whether it recognizes the name. Return this error code in all cases if a more specific code is not required. |
|
The call succeeded. |
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.
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 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012