- Код: Выделить всё
PCCERT_CONTEXT WINAPI CertCreateCertificateContext(
__in DWORD dwCertEncodingType,
__in const BYTE *pbCertEncoded,
__in DWORD cbCertEncoded
);
под VB6.
определяю так:
- Код: Выделить всё
Option Explicit
Public Declare Function CertCreateCertificateContext Lib "crypt32.dll" _
(ByVal dwCertEncodingType As Long, pbCertEncoded As Any, _
ByVal cbCertEncoded As Long) As CERT_CONTEXT
Public Declare Function CertFreeCertificateContext Lib "crypt32.dll" (ByRef pCertContext As CERT_CONTEXT) As Boolean
'=============================
Type CRYPT_BIT_BLOB
cbData As Long
pbData As Long
cUnusedBits As Long
End Type
Type CRYPTOAPI_BLOB
cbData As Long
pbData As Long
End Type
Type CRYPT_ALGORITHM_IDENTIFIER
pszObjId As String
Parameters As CRYPTOAPI_BLOB
End Type
Type FILETIME
dwLowDataTime As Long
dwHighDataTime As Long
End Type
Type CERT_PUBLIC_KEY_INFO
Algorithm As CRYPT_ALGORITHM_IDENTIFIER
PublicKey As CRYPT_BIT_BLOB
End Type
Type CERT_INFO
dwVersion As Long
SerialNumber As CRYPTOAPI_BLOB
SignatureAlgorithm As CRYPT_ALGORITHM_IDENTIFIER
Issuer As CRYPTOAPI_BLOB
NotBefore As FILETIME
NotAfter As FILETIME
Subject As CRYPTOAPI_BLOB
SubjectPublicKeyInfo As CERT_PUBLIC_KEY_INFO
IssuerUniqueId As CRYPT_BIT_BLOB
SubjectUniqueId As CRYPT_BIT_BLOB
cExtension As Long
rgExtension As Long
End Type
Public Type CERT_CONTEXT
dwCertEncodingType As Long
pbCertEncoded As String
cbCertEncoded As Long
pCertInfo As CERT_INFO
hCertStore As Long
End Type
Public Const PKCS_7_ASN_ENCODING As Long = &H10000
Public Const X509_ASN_ENCODING As Long = &H1
но при вызове
- Код: Выделить всё
Dim bcert() As Byte
bcert = cert.Export(CAPICOM_ENCODE_BINARY)
Dim cc As CERT_CONTEXT
Dim EncType As Long: EncType = PKCS_7_ASN_ENCODING Or X509_ASN_ENCODING
Dim ret As Boolean
cc = CertCreateCertificateContext(EncType, bcert(0), UBound(bcert))
вываливается с ошибкой Bad DLL Calling convertion