“unsigned long *”类型的参数与“HCRYPTHASH *”类型的参数不兼容

时间:2015-06-16 10:46:10

标签: c++ md5 unsigned wincrypt

我在64位计算机上使用Windows 8.1上的Visual Studios 2012。我在编译以下c ++代码时遇到了问题,得到了上述错误:

#include <windows.h>
#include <wincrypt.h>
void MD5Init(MD5Context *ctx)
{
    CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
}

然而,这似乎就是这种方式(here is one which has the same call and gives me the same error)。 VS建议了几个可能的修复,我会尝试,但有谁知道为什么会发生这种行为以及如何避免它?

建议的修复方法是:

  

错误C2664:'CryptCreateHash':无法转换参数5   'unsigned long *'到'HCRYPTHASH *'指向的类型是不相关的;

     

转换需要reinterpret_cast,C风格的转换或函数风格   投

谢谢,

Aodhán

编辑:32位编译不会发生这种情况,所以我想这就是我读过的示例。我将更新建议的修复是否适用于64位编译。

0 个答案:

没有答案