Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Kullanılacak bayt sayısı üst sınırına göre belge sağlama toplamını ve algoritma tanımlayıcısını alır.
Sözdizimi
public int GetChecksumAndAlgorithmId(
out Guid pRetVal,
uint cMaxBytes,
out byte pChecksum,
out uint pcNumBytes
);
Parametreler
pRetVal
[out] Sağlama toplamı algoritması için benzersiz tanımlayıcı.
cMaxBytes
[in] Sağlama toplamı için kullanılacak en fazla bayt sayısı.
pChecksum
[out] Sağlama toplamının değeri.
pcNumBytes
[out] Sağlama toplamı için kullanılan gerçek bayt sayısı.
İade Değeri
Başarılı olursa döndürür S_OK; aksi takdirde bir hata kodu döndürür.
Örnek
Aşağıdaki örnek, bir belgenin sağlama toplamını ve algoritmasını almak için bu yöntemi kullanır.
HRESULT CDebugCodeContext::GetDocumentChecksumAndAlgorithmId(GUID *pguidAlgorithm, BYTE **ppChecksum, ULONG *pcNumBytes)
{
HRESULT hRes = E_FAIL;
*ppChecksum = NULL;
*pcNumBytes = 0;
CComPtr<IDebugDocumentContext2> pDocContext;
hRes = this->GetDocumentContext(&pDocContext);
if ( HREVAL(S_OK, hRes) )
{
CComQIPtr<IDebugDocumentChecksum2> pDocChecksum(pDocContext);
if ( pDocChecksum != NULL )
{
// Figure out the size of the checksum buffer required
ULONG cNumBytes = 0;
hRes = pDocChecksum->GetChecksumAndAlgorithmId(pguidAlgorithm, 0, NULL, &cNumBytes);
if ( S_OK == hRes )
{
// check to see if we got back valid values
if ( cNumBytes && GUID_NULL != (*pguidAlgorithm) )
{
// Alloc space for the checksum data
BYTE *pChecksum = (BYTE*) CoTaskMemAlloc(cNumBytes);
if ( pChecksum )
{
// Get the buffer containing the checksum info
hRes = pDocChecksum->GetChecksumAndAlgorithmId(pguidAlgorithm, cNumBytes, pChecksum, &cNumBytes);
if ( HREVAL(S_OK, hRes) )
{
*ppChecksum = pChecksum;
*pcNumBytes = cNumBytes;
}
else
{
CoTaskMemFree(pChecksum);
}
}
else
hRes = E_OUTOFMEMORY;
}
else
hRes = S_FALSE; // lang doesn't support checksums
}
else
hRes = S_FALSE; // failed to work out checksum info
}
else
hRes = S_FALSE; // SH doesn't support checksums
}
return ( hRes );
}