-
Sep 1st, 2021, 10:28 AM
#1
Thread Starter
New Member
Please Please help with this API : CertFindCertificateInStore
@dimsumZ, @Merrion,
long time passed since this post was first posted (20 years actually...)
Due to technical contraints, I am forced to use Excel and VBA.
Trying to run the code you did, but when calling "i = CertFindCertificateInStoreByLong..." Excel simply crashes.
this is my call:
Dim i As LongPtr
Dim j As CERT_CONTEXT
' https://referencesource.microsoft.co...18d2a75444cd00
' internal const uint PKCS_7_ASN_ENCODING = 0x00010000;
Dim X509_ASN_ENCODING As LongPtr
Dim CERT_FIND_ANY As LongPtr
' internal const uint X509_ASN_ENCODING = 0x00000001;
X509_ASN_ENCODING = 1
'internal const uint CERT_COMPARE_SHIFT = 16;
'internal const uint CERT_COMPARE_ANY = 0;
'internal const uint CERT_FIND_ANY = ((int)CERT_COMPARE_ANY << (int)CERT_COMPARE_SHIFT);
CERT_FIND_ANY = 0
i = CertFindCertificateInStoreByLong( _
CLngPtr(system_Store_Handler), _
X509_ASN_ENCODING, _
0, _
CERT_FIND_ANY, _
vbNull, _
vbNull) '<--This must be null the first time...
If you guys have running code, I would love to see the full example.
Thanks and god bless you...
-
Sep 1st, 2021, 11:42 AM
#2
Re: Please Please help with this API : CertFindCertificateInStore
There is little to no chance that the people who started that other thread would ever see your request, so I made your post a new thread in case any current user has some familiarity with the problem.
My usual boring signature: Nothing
-
Sep 2nd, 2021, 01:24 AM
#3
Re: Please Please help with this API : CertFindCertificateInStore
The first two parameters look wrong.
You're passing LongPtr, but I'd guess they have to be Long's
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Sep 2nd, 2021, 10:42 AM
#4
Re: Please Please help with this API : CertFindCertificateInStore
I'm wondering if instead of a Long they should Integer or IntPtr. If the original code was VB6, then a Long would be 32-bits, which would be an Integer in .Net.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 2nd, 2021, 11:48 AM
#5
Re: Please Please help with this API : CertFindCertificateInStore
Passel,
the first two params are DWORD in the C-Header
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Sep 2nd, 2021, 12:35 PM
#6
Re: Please Please help with this API : CertFindCertificateInStore
Which confirms with what I said, i.e. WORD = 16-bits, DWORD = 32 bits, QWORD would be 64-bits.
A Long in .Net is a QWORD, an Integer would be a DWORD.
That is a true for Windows and DOS, but doesn't necessarily hold true for other Operating systems.
Last edited by passel; Sep 2nd, 2021 at 12:41 PM.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 2nd, 2021, 01:02 PM
#7
Re: Please Please help with this API : CertFindCertificateInStore
He‘s forced to use Excel/VBA
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
Sep 2nd, 2021, 02:44 PM
#8
Re: Please Please help with this API : CertFindCertificateInStore
True, but these days, with the latest Excel/VBA, isn't the VBA 64-bits rather than 32-bits. I don't know, it is just something I thought that the latest versions of Office supported, i.e. 64-bit Excel etc...
I guess I probably don't know what I'm talking about, so should bow out, especially since we haven't heard back from the OP whether LongPtr to Long fixed the problem.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Sep 3rd, 2021, 01:17 AM
#9
Re: Please Please help with this API : CertFindCertificateInStore
Passel,
Yes, VBA is dependent on the bitness of the Office-Package (Not Windows!), but even in 64-Bit Office a Long is still a signed 32-Bit Integer
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|