사용할 최대 바이트 수가 지정된 문서 체크섬 및 알고리즘 식별자를 검색합니다.
구문
public int GetChecksumAndAlgorithmId(
out Guid pRetVal,
uint cMaxBytes,
out byte pChecksum,
out uint pcNumBytes
);
매개 변수
pRetVal
[out] 체크섬 알고리즘의 고유 식별자입니다.
cMaxBytes
[in] 체크섬에 사용할 최대 바이트 수입니다.
pChecksum
[out] 체크섬의 값입니다.
pcNumBytes
[out] 체크섬에 사용되는 실제 바이트 수입니다.
Return Value
성공하면 S_OK를 반환하고, 실패하면 오류 코드를 반환합니다.
예시
다음 예제에서는 이 메서드를 사용하여 문서의 체크섬 및 알고리즘을 가져옵니다.
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 );
}