IAttachmentExecute::Execute method (shobjidl_core.h)

Executes an action on an attachment.


HRESULT Execute(
  [in]            HWND    hwnd,
  [in, optional]  LPCWSTR pszVerb,
  [out, optional] HANDLE  *phProcess


[in] hwnd

Type: HWND

The handle of the parent window.

[in, optional] pszVerb


A pointer to a null-terminated string that contains a verb specifying the action to be performed on the file. See the lpOperation parameter in ShellExecute for valid strings. This value can be NULL.

[out, optional] phProcess


A pointer to a handle to the source process, used for synchronous operation. This value can be NULL.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


Before calling IAttachmentExecute::Execute, IAttachmentExecute::SetLocalPath must be called with a valid local path and the file must be copied to that location.

If a prompt is indicated, IAttachmentExecute::Execute calls IAttachmentExecute::Prompt using the ATTACHMENT_ACTION_EXEC value.

IAttachmentExecute::Execute may run virus scanners or other trust services to validate the file before executing it. Note that these services can delete or alter the file.

IAttachmentExecute::Execute may attach evidence to the local path in its NTFS alternate data stream (ADS).

If phProcess is not NULL, IAttachmentExecute::Execute operates as a synchronous process and returns an HPROCESS, if available. If phProcess is NULL, IAttachmentExecute::Execute operates as an asynchronous process. This implies that the calling application has a message pump and a long-lived window.

If the handle pointed to by phProcess is non-NULL when the method returns, the calling application is responsible for calling CloseHandle to free the handle when it is no longer needed.


Requirement Value
Minimum supported client Windows XP with SP2 [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shobjidl_core.h (include Shobjidl.h)
DLL Shdocvw.dll (version 6.0 or later)