I am getting the below error when compiling the C++ project.
Error C2664 'BOOL CryptBinaryToStringW(const BYTE *,DWORD,DWORD,LPWSTR,DWORD *)': cannot convert argument 4 from 'std::unique_ptr>' to 'LPWSTR'
at the below line of code:
CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, pwszBuffer, &dwLength);
And also I am getting the below error:
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'std::unique_ptr>' (or there is no acceptable conversion)
at the below line:
sBase64 = pwszBuffer;
Below is the complete code:
bool EMRReader::EncodeBase64(DWORD dwSize, const std::string& strData, wstring& sBase64)
{
DWORD dwOptions = CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF;
DWORD dwLength = 0;
BOOL bRet = CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, 0, &dwLength);
if (!bRet)
return bRet;
std::unique_ptr<std::wstring> pwszBuffer = std::make_unique<std::wstring>(dwLength + 1);
if (!pwszBuffer)
return FALSE;
SecureZeroMemory(pwszBuffer.get(), (dwLength + 1) * sizeof(wchar_t));
CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, pwszBuffer, &dwLength);
sBase64 = pwszBuffer;
return TRUE;
}
Could anyone please help me to resolve these errors?
Aucun commentaire:
Enregistrer un commentaire