[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: CertEnumCertificatesInStore and VB
From:       Eric Eicke <eicke () DART ! COM>
Date:       1999-09-21 19:48:13
[Download RAW message or body]


Scratch that I finally figured it out. I change pvPara As String to ByVal
pvPara As Any and it works....

Thanks for the help...
----- Original Message -----
From: Eric Eicke <eicke@DART.COM>
To: <CryptoAPI@DISCUSS.MICROSOFT.COM>
Sent: Tuesday, September 21, 1999 3:13 PM
Subject: Re: CertEnumCertificatesInStore and VB


> Excuse my ignorance I hardly use VB, but the define
>
>  Private Declare Function CertOpenStore Lib "crypt32" ( _
>      ByVal lpszStoreProvider As Long, _
>      ByVal dwEncodingType As Long, _
>      ByVal hCryptProv As Long, _
>      ByVal dwFlags As Long, _
>      pvPara As String) As Long
>
> Still doesn't return a valid handle for me and gives the same DLLError(2)
..
>
> Here is how I did it in C++:
> hCertStore = CertOpenStore(CERT_STORE_PROV_SYSTEM,
>                                                     X509_ASN_ENCODING,
>                                                     0,
>
> CERT_SYSTEM_STORE_LOCAL_MACHINE,
>                                                     L"MY");
>
> I tried several combinations of BYVAL and BYREF. I still can't get it to
> work.
>
> Thanks in advance,
> Eric Eicke
> ----- Original Message -----
> From: Jeffrey Phillips (E-mail) <jeffphil@IX.NETCOM.COM>
> To: <CryptoAPI@DISCUSS.MICROSOFT.COM>
> Sent: Friday, September 17, 1999 1:15 PM
> Subject: Re: CertEnumCertificatesInStore and VB
>
>
> > Here you go:
> >
> > Private Declare Function CertOpenStore Lib "crypt32" ( _
> >     ByVal lpszStoreProvider As Long, _
> >     ByVal dwEncodingType As Long, _
> >     ByVal hCryptProv As Long, _
> >     ByVal dwFlags As Long, _
> >     pvPara As String) As Long
> >
> > Private Declare Function CertCloseStore Lib "crypt32" ( _
> >     ByVal hCertStore As Long, _
> >     ByVal dwFlags As Long) As Boolean
> >
> > Private Declare Function CertEnumCertificatesInStore Lib "crypt32" ( _
> >     ByVal hCertStore As Long, _
> >     ByVal pPrevCertContext As Long) As Long
> >
> > Private Declare Function CertOpenSystemStoreA Lib "crypt32" ( _
> >     ByVal hProv As Long, _
> >     ByVal szSubSystemProtocol As String) As Long
> >
> > Sometimes you just have to play around with ByVal vs. ByRef.
> >
> > -----Original Message-----
> > From: Microsoft Cryptographic API
> > [mailto:CryptoAPI@DISCUSS.MICROSOFT.COM]On Behalf Of Eric Eicke
> > Sent: Friday, September 17, 1999 10:53 AM
> > To: CryptoAPI@DISCUSS.MICROSOFT.COM
> > Subject: Re: CertEnumCertificatesInStore and VB
> >
> >
> > Changing it to a ByVal causes a GPF so must be the value returned by
> > CertOpenSystemStore is not a acutally a handle. I looked at
> Err.LastDllError
> > after the call to CertOpenSystemStore and it is 0x02(The system cannot
> find
> > the file specified.)
> >
> > Any clues what to do now?
> >
> > Thanks in advance,
> > Eric Eicke
> > ----- Original Message -----
> > From: Jeffrey Phillips (E-mail) <jeffphil@IX.NETCOM.COM>
> > To: <CryptoAPI@DISCUSS.MICROSOFT.COM>
> > Sent: Friday, September 17, 1999 11:26 AM
> > Subject: Re: CertEnumCertificatesInStore and VB
> >
> >
> > > Eric:
> > >
> > > Anywhere you are passing IN a handle to the API's you would
> > > want to pass it ByVal and not ByRef.  So you would want:
> > >
> > > Private Declare Function CertEnumCertificatesInStore Lib "crypt32" _
> > > (ByVal hCertStore As Long, pPrevCertContext As Long) As Long
> > >
> > > You can also test why any calls are failing by looking at the
> > > Err.LastDllError immediately after the call.  If the number returned
> > > is in the 2 billion range, then you will need to convert the number
> > > to hex to look up what the code means.  Otherwise, the error should
> > > be a standard OS error code.
> > >
> > > Lastly, I know you have the CertOpenStore commented but you would want
> > > to use CERT_STORE_PROV_SYSTEM_A = 9 instead of CERT_STORE_PROV_SYSTEM
> =10.
> > >
> > > -Jeffrey.
> > >
> > > -----Original Message-----
> > > From: Microsoft Cryptographic API
> > > [mailto:CryptoAPI@DISCUSS.MICROSOFT.COM]On Behalf Of Eric Eicke
> > > Sent: Friday, September 17, 1999 9:00 AM
> > > To: CryptoAPI@DISCUSS.MICROSOFT.COM
> > > Subject: CertEnumCertificatesInStore and VB
> > >
> > >
> > > Here is what I have so far:
> > >
> > > Const CERT_STORE_PROV_SYSTEM = 10
> > > Const X509_ASN_ENCODING = 1
> > > Const CERT_SYSTEM_STORE_LOCAL_MACHINE = 131072
> > > Const CERT_SYSTEM_STORE_CURRENT_USER = 65536
> > >
> > > Private Declare Function CertOpenStore Lib "crypt32" (ByVal
> > > lpszStoreProvider As Long, ByVal dwEncodingType As Long, hCryptProv As
> > Long,
> > > ByVal dwFlags As Long, pvPara As String) As Long
> > > Private Declare Function CertCloseStore Lib "crypt32" (hCertStore As
> Long,
> >
> > > ByVal dwFlags As Long) As Boolean
> > > Private Declare Function CertEnumCertificatesInStore Lib "crypt32"
> > > (hCertStore As Long, pPrevCertContext As Long) As Long
> > > Private Declare Function CertOpenSystemStoreA Lib "crypt32" (hProv As
> > Long,
> > > szSubSystemProtocol As String) As Long
> > >
> > >
> > > Private Sub Command1_Click()
> > > Dim hStore As Long
> > > Dim Cert As Long
> > > 'hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, X509_ASN_ENCODING, 0,
> > > CERT_SYSTEM_STORE_CURRENT_USER, "MY")
> > > hStore = CertOpenSystemStoreA(0, "MY")
> > >
> > > Cert = CertEnumCertificatesInStore(hStore, 0)
> > > If (CertCloseStore(hStore, 0)) Then
> > >     MsgBox "OK"
> > > Else
> > >     MsgBox "Nope"
> > > End If
> > > End Sub
> > >
> > > I get a value back from CertOpenStore and CertOpenSystemStore, but I
> never
> > > get a Cert back from CertEnumCertificatesInStore. The same code works
> fine
> > > in C++. What is wrong?
> > >
> > > Thanks in advance,
> > > Eric Eicke
> > >
> > > ----------------------------------------------------------------
> > > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> > > contains important info including how to unsubscribe.  Save time,
search
> > > the archives at http://discuss.microsoft.com/archives/index.html
> > >
> > > ----------------------------------------------------------------
> > > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> > > contains important info including how to unsubscribe.  Save time,
search
> > > the archives at http://discuss.microsoft.com/archives/index.html
> >
> > ----------------------------------------------------------------
> > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> > contains important info including how to unsubscribe.  Save time, search
> > the archives at http://discuss.microsoft.com/archives/index.html
> >
> > ----------------------------------------------------------------
> > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> > contains important info including how to unsubscribe.  Save time, search
> > the archives at http://discuss.microsoft.com/archives/index.html
>
> ----------------------------------------------------------------
> Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
> contains important info including how to unsubscribe.  Save time, search
> the archives at http://discuss.microsoft.com/archives/index.html

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic