VB
Microsoft 开发的一种面向对象的编程语言,其在 .NET Framework 上实现。 以前称为 Visual Basic .NET。
76 个问题
你好 最近我看到了有关CAPICOM的 https://learn.microsoft.com/it-it/windows/win32/seccrypto/signedcode?redirectedfrom=MSDN#methods 和其他文件.dll
如何调用此 DLL/activeX?
我有方法和属性,但我如何调用 SignedCode -> SignCode.verify.......
Note:此问题总结整理于:How to use SignedCode - Microsoft Q&A
您好,您必须首先添加对 CAPICOM 的引用,然后像(此处的代码)一样使用它。
Dim signeddata As CAPICOM.SignedData = New CAPICOM.SignedData()
Dim file As FileStream = File.Open(tbSourceFile.Text, FileMode.Open)
Dim Content As Byte() = New Byte(CInt(file.Length) - 1) {}
file.Read(Content, 0, CInt(file.Length))
file.Close()
Dim sw As StringWriter = New StringWriter()
sw.Write(Content)
signeddata.Content = sw.ToString()
Dim store As IStore = New CAPICOM.Store()
store.Open(CAPICOM.CAPICOM_STORE_LOCATION.CAPICOM_CURRENT_USER_STORE, "MY", CAPICOM.CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_READ_ONLY Or CAPICOM.CAPICOM_STORE_OPEN_MODE.CAPICOM_STORE_OPEN_EXISTING_ONLY)
Dim certificates As ICertificates2 = CType(store.Certificates, ICertificates2)
certificates = certificates.Find(CAPICOM_CERTIFICATE_FIND_TYPE.CAPICOM_CERTIFICATE_FIND_KEY_USAGE, CAPICOM_KEY_USAGE.CAPICOM_DIGITAL_SIGNATURE_KEY_USAGE, True)
If certificates.Count > 0 Then
certificates = certificates.[Select]()
End If
If certificates.Count > 0 Then
Dim signers As ISigner2 = New CAPICOM.Signer()
signers.Certificate = certificates(1)
tbSignatureBlock.Text = signeddata.Sign(signers, True)
End If
请注意,CAPICOM 不再开发。 如果答案是正确的,请点击“接受答案”并点赞。 如果您对此答案还有其他疑问,请点击“评论”。 注意:如果您想接收相关电子邮件,请按照我们的文档中的步骤启用电子邮件通知 此线程的通知。