CRYTOAPI 库调用出错

调试中,出现以下错误:

Compiling...
Keycos.cpp
d:/soft work/other/devinterface/keycos.cpp(34) : warning C4101: 'ifData' : unreferenced local variable
d:/soft work/other/devinterface/keycos.cpp(383) : error C2065: 'HCRYPTPROV' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(383) : error C2146: syntax error : missing ';' before identifier 'hProv'
d:/soft work/other/devinterface/keycos.cpp(383) : error C2065: 'hProv' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(384) : error C2065: 'HCRYPTKEY' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(384) : error C2146: syntax error : missing ';' before identifier 'hKey'
d:/soft work/other/devinterface/keycos.cpp(384) : error C2065: 'hKey' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(392) : error C2065: 'HCERTSTORE' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(392) : error C2146: syntax error : missing ';' before identifier 'hSysStore'
d:/soft work/other/devinterface/keycos.cpp(392) : error C2065: 'hSysStore' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(393) : error C2065: 'PCCERT_CONTEXT' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(393) : error C2146: syntax error : missing ';' before identifier 'pCertContext'
d:/soft work/other/devinterface/keycos.cpp(393) : error C2065: 'pCertContext' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(394) : error C2065: 'CERT_CONTEXT' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(394) : error C2146: syntax error : missing ';' before identifier 'MyContext'
d:/soft work/other/devinterface/keycos.cpp(394) : error C2065: 'MyContext' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(404) : error C2065: 'CryptAcquireContext' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(404) : error C2065: 'sContainer' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(404) : error C2065: 'sCspName' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(404) : error C2065: 'PROV_RSA_FULL' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(407) : error C2065: 'CryptGenKey' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(409) : error C2065: 'AT_KEYEXCHANGE' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(410) : error C2065: 'CRYPT_EXPORTABLE' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(416) : error C2065: 'CryptGetKeyParam' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(418) : error C2065: 'KP_CERTIFICATE' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(435) : error C2065: 'CertOpenSystemStore' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(435) : error C2065: 'sNewItStoreName' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(438) : error C2228: left of '.cbCertEncoded' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(439) : error C2228: left of '.dwCertEncodingType' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(439) : error C2065: 'X509_ASN_ENCODING' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(440) : error C2228: left of '.hCertStore' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(441) : error C2228: left of '.pbCertEncoded' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(443) : error C2440: '=' : cannot convert from 'int *' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:/soft work/other/devinterface/keycos.cpp(445) : error C2065: 'PCERT_CONTEXT' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(445) : error C2146: syntax error : missing ';' before identifier 'CertCreateCertificateContext'
d:/soft work/other/devinterface/keycos.cpp(445) : error C2065: 'CertCreateCertificateContext' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(446) : error C2065: 'PKCS_7_ASN_ENCODING' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(456) : error C2065: 'CertAddCertificateContextToStore' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(458) : error C2065: 'CERT_STORE_ADD_ALWAYS' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(466) : error C2227: left of '->pCertInfo' must point to class/struct/union
d:/soft work/other/devinterface/keycos.cpp(466) : error C2227: left of '->SerialNumber' must point to class/struct/union
d:/soft work/other/devinterface/keycos.cpp(466) : error C2228: left of '.pbData' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(466) : error C2227: left of '->pCertInfo' must point to class/struct/union
d:/soft work/other/devinterface/keycos.cpp(466) : error C2227: left of '->SerialNumber' must point to class/struct/union
d:/soft work/other/devinterface/keycos.cpp(466) : error C2228: left of '.cbData' must have class/struct/union type
d:/soft work/other/devinterface/keycos.cpp(468) : error C2065: 'CertFreeCertificateContext' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(469) : error C2065: 'CertCloseStore' : undeclared identifier
d:/soft work/other/devinterface/keycos.cpp(472) : error C2065: 'CERT_CLOSE_STORE_FORCE_FLAG' : undeclared identifier
KeyMethd.cpp
Error executing cl.exe.

DevInterface.dll - 47 error(s), 1 warning(s)

 

已经添加如下条件:

#include <hlguids.h>
#include <stdio.h>

#include <setupapi.h>
#pragma  comment(lib,"setupapi.lib")

#include  <WINCRYPT.h>
#pragma comment(lib,"CRYPT32.lib")

 

但是错误依然.........................

 

解决方案:

1. VC 6.0 所带的CRYTOAPI 比较陈旧,需要重新下载并替换之,可以去微软下载,我没有式过

2. 用比VC 6.0 更高的编译环境编译,我用的是 VS 2008,通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值