Antarmuka IAttachmentExecute (shobjidl_core.h)
Mengekspos metode yang bekerja dengan aplikasi klien untuk menyajikan lingkungan pengguna yang menyediakan unduhan dan pertukaran file yang aman melalui lampiran email dan pesan.
Warisan
Antarmuka IAttachmentExecute mewarisi dari antarmuka IUnknown . IAttachmentExecute juga memiliki jenis anggota ini:
Metode
Antarmuka IAttachmentExecute memiliki metode ini.
IAttachmentExecute::CheckPolicy Menyediakan tes Boolean yang dapat digunakan untuk membuat keputusan berdasarkan kebijakan eksekusi lampiran. |
IAttachmentExecute::ClearClientState Menghapus status tersimpan yang didasarkan pada GUID klien. Contohnya mungkin pengaturan berdasarkan kotak centang yang menunjukkan perintah tidak boleh ditampilkan lagi untuk jenis file tertentu. |
IAttachmentExecute::Execute Menjalankan tindakan pada lampiran. |
IAttachmentExecute::P rompt Menyajikan UI perintah kepada pengguna. |
IAttachmentExecute::Save Menyimpan lampiran. |
IAttachmentExecute::SaveWithUI Menyajikan UI kesalahan penjelasan kepada pengguna jika tindakan penyimpanan gagal. |
IAttachmentExecute::SetClientGuid Menentukan dan menyimpan GUID untuk klien. |
IAttachmentExecute::SetClientTitle Menentukan dan menyimpan judul jendela perintah. |
IAttachmentExecute::SetFileName Menentukan dan menyimpan nama file yang diusulkan. |
IAttachmentExecute::SetLocalPath Mengatur dan menyimpan jalur ke file. |
IAttachmentExecute::SetReferrer Mengatur zona keamanan yang terkait dengan file lampiran berdasarkan file yang merujuk. |
IAttachmentExecute::SetSource Mengatur jalur atau URL alternatif untuk sumber transfer file. |
Keterangan
Antarmuka ini mengasumsikan hal berikut:
- Klien memiliki kebijakan atau pengaturan untuk dukungan dan perilaku lampiran.
- Klien berinteraksi dengan pengguna.
Berikut adalah contoh bagaimana klien email mungkin menggunakan 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;
}
Persyaratan
Klien minimum yang didukung | Windows XP dengan SP2 [hanya aplikasi desktop] |
Server minimum yang didukung | Windows Server 2003 [hanya aplikasi desktop] |
Target Platform | Windows |
Header | shobjidl_core.h |
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk