The CryptCATAdminCalcHashFromFileHandle2 function calculates the hash for a file by using the specified algorithm.
BOOL CryptCATAdminCalcHashFromFileHandle2( HCATADMIN hCatAdmin, HANDLE hFile, DWORD *pcbHash, BYTE *pbHash, DWORD dwFlags );
Handle of an open catalog administrator context. For more information, see CryptCATAdminAcquireContext2.
A handle to the file whose hash is being calculated. This parameter cannot be NULL and must be a valid file handle.
Pointer to a DWORD variable that contains the number of bytes in the pbHash parameter. Upon input, set pcbHash to the number of bytes allocated for pbHash. Upon return, pcbHash contains the number of returned bytes in pbHash. If pbHash is set to NULL, then pcbHash contains the number of bytes to allocate for pbHash.
Pointer to a BYTE buffer that receives the hash. If you set this parameter to NULL, then pcbHash will contain the number of bytes to allocate for pbHash, and a subsequent call can be made to retrieve the hash.
Reserved. This value must be zero.
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.
The following table lists the error codes most commonly returned by the GetLastError function.
The hFile parameter must not be NULL.
The hFile parameter must be a valid file handle.
The pcbHash parameter must not be NULL.
The dwFlags parameter must be zero (0).
||The buffer pointed to by the pbHash parameter was not NULL but was not large enough to be written. The correct size of the required buffer is contained in the value pointed to by the pcbHash parameter.|
||The hash algorithm specified by the pwszHashAlgorithm parameter cannot be found.|
The amount of time this function takes to execute depends on the length of the file being hashed, the algorithm being used, and the file location. For example, it takes several seconds to calculate the hash of a local file that is very large (a few hundred megabytes).
|Minimum supported client||Windows 8 [desktop apps only]|
|Minimum supported server||Windows Server 2012 [desktop apps only]|