Share via


Interface IAttachmentExecute (shobjidl_core.h)

Expõe métodos que funcionam com aplicativos cliente para apresentar um ambiente de usuário que fornece download seguro e troca de arquivos por meio de anexos de email e mensagens.

Herança

A interface IAttachmentExecute herda da interface IUnknown . IAttachmentExecute também tem estes tipos de membros:

Métodos

A interface IAttachmentExecute tem esses métodos.

 
IAttachmentExecute::CheckPolicy

Fornece um teste booliano que pode ser usado para tomar decisões com base na política de execução do anexo.
IAttachmentExecute::ClearClientState

Remove qualquer estado armazenado baseado no GUID do cliente. Um exemplo pode ser uma configuração baseada em uma caixa marcada que indica que um prompt não deve ser exibido novamente para um tipo de arquivo específico.
IAttachmentExecute::Execute

Executa uma ação em um anexo.
IAttachmentExecute::P rompt

Apresenta uma interface do usuário de prompt para o usuário.
IAttachmentExecute::Save

Salva o anexo.
IAttachmentExecute::SaveWithUI

Apresenta ao usuário uma interface do usuário de erro explicativo se a ação salvar falhar.
IAttachmentExecute::SetClientGuid

Especifica e armazena o GUID para o cliente.
IAttachmentExecute::SetClientTitle

Especifica e armazena o título da janela do prompt.
IAttachmentExecute::SetFileName

Especifica e armazena o nome proposto do arquivo.
IAttachmentExecute::SetLocalPath

Define e armazena o caminho para o arquivo.
IAttachmentExecute::SetReferrer

Define a zona de segurança associada ao arquivo de anexo com base no arquivo de referência.
IAttachmentExecute::SetSource

Define um caminho ou URL alternativo para a origem de uma transferência de arquivo.

Comentários

Essa interface pressupõe o seguinte:

  • O cliente tem políticas ou configurações para suporte e comportamento de anexo.
  • O cliente interage com o usuário.
A IID dessa interface é IID_IAttachmentExecute.

Aqui está um exemplo de como um cliente de email pode usar IAttachmentExecute.


// CClientAttachmentInfo, defined by the client, implements all the
// necessary client functionality concerning attachments. 
class CClientAttachmentInfo;  

// Creates an instance of IAttachmentExecute
HRESULT CreateAttachmentServices(IAttachmentExecute **ppae)
{
    // Assume that CoInitialize has already been called for this thread.
    HRESULT hr = CoCreateInstance(CLSID_AttachmentServices, 
                                  NULL, 
                                  CLSCTX_INPROC_SERVER, 
                                  IID_IAttachmentExecute, 
                                  (void**)&pAttachExec);

    if (SUCCEEDED(hr))
    {
        // Set the client's GUID.

        // UUID_ClientID should be created using uuidgen.exe and 
        // defined internally.
        (*ppae)->SetClientGuid(UUID_ClientID);
        
        // You also could call SetClientTitle at this point, but it is
        // not required.
    }
    return hr;
}

BOOL IsAttachmentBlocked(CClientAttachmentInfo *pinfo)
{
    // Assume that a client function has copied the file from the mail store 
    // into a temporary file.
    PWSTR pszFileName;

    // GetFileName is a method in this class for which we do not provide
    // an implementation here.
    HRESULT hr = pinfo->GetFileName(&pszFileName);
    if (SUCCEEDED(hr))
    {
        IAttachmentExecute *pExecute;

        hr = CreateAttachmentServices(&pExecute);
        if (SUCCEEDED(hr))
        {
            hr = pExecute->SetFileName(pszFileName);

            // Do not call SetLocalPath since we do not have the local path yet.
            // Do not call SetSource since email sources are not verifiable.
            // Do not call SetReferrer since we do not have a better zone 
            // than the default (Restricted sites).

            // Check for a policy regarding the file.
            if (SUCCEEDED(hr))
            {
                hr = pExecute->CheckPolicy();
            }
            pExecute->Release();
        }
        LocalFree(pszFileName);
    }
    return FAILED(hr);
}
    
HRESULT OnDoubleClickAttachment(HWND hwnd, CClientAttachmentInfo *pinfo)
{
    // Assume that a client function has copied the file from the mail store 
    // into a temporary file.
    PWSTR pszTempFile;

    // CopyToTempFile is a method in this class for which we do not provide
    // an implementation here.
    HRESULT hr = pinfo->CopyToTempFile(&pszTempFile);
    if (SUCCEEDED(hr))
    {
        IAttachmentExecute *pExecute;

        hr = CreateAttachmentServices(&pExecute);
        if (SUCCEEDED(hr))
        {
            hr = pExecute->SetLocalPath(pszTempFile);

            // Do not call SetFileName since we already have the local path.
            // Do not call SetSource since email sources are not verifiable.
            // Do not call SetReferrer since we do not have a better zone 
            // than the default (Restricted sites).

            if (SUCCEEDED(hr))
            {
                hr = pExecute->Execute(hwnd, NULL, NULL);
            }
            pExecute->Release();
        }
        LocalFree(pszTempFile);
    }
    return hr;
}

HRESULT OnSaveAttachment(HWND hwnd, CClientAttachmentInfo *pinfo)
{
    // Assume that a client function has copied the file from the mail store 
    // into a location selected by the user.
    PWSTR pszUserFile;

    // CopyToUserFile is a method in this class for which we do not provide
    // an implementation here.
    HRESULT hr = pinfo->CopyToUserFile(hwnd, &pszUserFile);
    if (SUCCEEDED(hr))
    {
        IAttachmentExecute *pExecute;

        hr = CreateAttachmentServices(&pExecute);
        if (SUCCEEDED(hr))
        {
            hr = pExecute->SetLocalPath(pszTempFile);

            // Do not call SetFileName since we have the local path.
            // Do not call SetSource since email sources are not verifiable.
            // Do not call SetReferrer since we do not have a better zone 
            // than the default (Restricted sites).

            if (SUCCEEDED(hr))
            {
                hr = pExecute->Save();
            }
            pExecute->Release();
        }
        LocalFree(pszUserFile);
    }
    return hr;
}

Requisitos

   
Cliente mínimo com suporte Windows XP com SP2 [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows Server 2003 [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho shobjidl_core.h