http://oshiete1.goo.ne.jp/qa4971997.html
Option Explicit
Declare Function CertOpenSystemStoreW Lib "crypt32.dll" (ByRef hprov As Long, ByVal szSubsystemProtocol As String) As Long
Declare Function CertCloseStore Lib "crypt32.dll" (ByRef hprov As Long, ByVal szSubsystemProtocol As String) As Boolean
Declare Function CertEnumCertificatesInStore Lib "crypt32.dll" (ByRef hCertStore As Long, ByRef pPrevCertContext As Long) As Long
Declare Function CertGetNameStringW Lib "crypt32" (ByRef pCertContext As Long, ByVal dwType As Long, ByVal dwFlags As Long, pvTypePara As Any, ByVal pszNameString As String, ByVal cchNameString As Long) As Long
Const CERT_NAME_SIMPLE_DISPLAY_TYPE As Integer = 4
Sub Main()
Dim store As Long
Dim cert As Long
Dim Names() As String
Dim name As String * 100
ReDim Names(0)
store = CertOpenSystemStoreW(vbNull, "Root")
cert = CertEnumCertificatesInStore(store, vbNull)
Do While (Not IsNull(cert))
CertGetNameStringW cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, vbNull, name, 101
Names(UBound(Names)) = name
ReDim Preserve Names(UBound(Names) + 1)
cert = CertEnumCertificatesInStore(store, cert)
Loop
CertCloseStore store, 0
End Sub
何か間違っているようだが,解ってない。
CertGetNameStringWでクラッシュする。
Win32 APIは触れないようにしてきたからなあ
→何故か CertGetNameStringW Lib "crypt32" Alias "CertGetNameStringA"って書いてたので修正
→まだクラッシュする
Option Explicit
Declare Function CertOpenSystemStoreW Lib "crypt32.dll" (ByRef hprov As Long, ByVal szSubsystemProtocol As String) As Long
Declare Function CertCloseStore Lib "crypt32.dll" (ByRef hprov As Long, ByVal szSubsystemProtocol As String) As Boolean
Declare Function CertEnumCertificatesInStore Lib "crypt32.dll" (ByRef hCertStore As Long, ByRef pPrevCertContext As Long) As Long
Declare Function CertGetNameStringW Lib "crypt32" (ByRef pCertContext As Long, ByVal dwType As Long, ByVal dwFlags As Long, pvTypePara As Any, ByVal pszNameString As String, ByVal cchNameString As Long) As Long
Const CERT_NAME_SIMPLE_DISPLAY_TYPE As Integer = 4
Sub Main()
Dim store As Long
Dim cert As Long
Dim Names() As String
Dim name As String * 100
ReDim Names(0)
store = CertOpenSystemStoreW(vbNull, "Root")
cert = CertEnumCertificatesInStore(store, vbNull)
Do While (Not IsNull(cert))
CertGetNameStringW cert, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, vbNull, name, 101
Names(UBound(Names)) = name
ReDim Preserve Names(UBound(Names) + 1)
cert = CertEnumCertificatesInStore(store, cert)
Loop
CertCloseStore store, 0
End Sub
何か間違っているようだが,解ってない。
CertGetNameStringWでクラッシュする。
Win32 APIは触れないようにしてきたからなあ
→何故か CertGetNameStringW Lib "crypt32" Alias "CertGetNameStringA"って書いてたので修正
→まだクラッシュする