'HCRYPTHASH' : undeclared identifier 类似错误的解决办法

在编译一个cpp程序时,明明已经 include <wincrypt.h>,可还是报错

D:\crypt\crypt.cpp(20) : error C2065: 'HCRYPTHASH' : undeclared identifier
D:\crypt\crypt.cpp(20) : error C2146: syntax error : missing ';' before identifier 'hHash'
D:\crypt\crypt.cpp(20) : error C2065: 'hHash' : undeclared identifier
D:\crypt\crypt.cpp(22) : error C2065: 'HCRYPTKEY' : undeclared identifier
D:\crypt\crypt.cpp(22) : error C2146: syntax error : missing ';' before identifier 'hKey'
D:\crypt\crypt.cpp(22) : error C2065: 'hKey' : undeclared identifier
D:\crypt\crypt.cpp(24) : error C2065: 'HCRYPTPROV' : undeclared identifier
D:\crypt\crypt.cpp(24) : error C2146: syntax error : missing ';' before identifier 'hProv'
D:\crypt\crypt.cpp(24) : error C2065: 'hProv' : undeclared identifier
D:\crypt\crypt.cpp(32) : error C2065: 'CryptAcquireContext' : undeclared identifier
D:\crypt\crypt.cpp(38) : error C2065: 'CryptCreateHash' : undeclared identifier
D:\crypt\crypt.cpp(54) : error C2065: 'CryptHashData' : undeclared identifier
D:\crypt\crypt.cpp(70) : error C2065: 'CryptDeriveKey' : undeclared identifier
D:\crypt\crypt.cpp(105) : error C2065: 'CryptEncrypt' : undeclared identifier
D:\crypt\crypt.cpp(151) : error C2065: 'CryptDestroyHash' : undeclared identifier
D:\crypt\crypt.cpp(157) : error C2065: 'CryptDestroyKey' : undeclared identifier

原因是:

vc6缺省是不定义_WIN32_WINNT宏的。 
而在wincrypt.h中有 
#if (_WIN32_WINNT >= 0x0400) 
... 
#endif

解决办法是:
在stdafx.h中添加

#ifndef   _WIN32_WINNT 
#define   _WIN32_WINNT   0x0400 
#endif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值