Hi,
I?m trying to call the CryptoAPI-function CryptRetrieveObjectByUrl from my
C# project. At the moment I?m using a C++ - dll in order to call the
function with the following parameters:
CryptRetrieveObjectByUrl( My_LDAP , CONTEXT_OID_CRL , dwFlags, 30000 ,
(LPVOID *)&pMyCRL, NULL , NULL , NULL , NULL )
but I would like to remove the dll and make the call from C#. But I?m unsure
how to marshal some of the parameters, more precisely the second and fifth
parameters.
The fifth parameter (pMyCRL) is defined as a pointer to a pointer, which in
the end is supposed to point to a PCRL_CONTEXT-struct.
The second parameter is defined in WinCrypt.h like this: #define
CONTEXT_OID_CRL ((LPCSTR)2) I know how to marshal to a LPCSTR , but what?s
the value of it??
Any help appreciated... Thanks in advance
Jon G
Mattias Sj?gren - 11 Jun 2004 02:17 GMT
Jon,
>The fifth parameter (pMyCRL) is defined as a pointer to a pointer, which in
>the end is supposed to point to a PCRL_CONTEXT-struct.
Right, I'd declare it as out IntPtr and then use
Marshal.PtrToStructure to dereference the returned CRL_CONTEXT struct.
>The second parameter is defined in WinCrypt.h like this: #define
>CONTEXT_OID_CRL ((LPCSTR)2) I know how to marshal to a LPCSTR , but what´s
>the value of it??
Declare it as an IntPtr rather than a string, then pass in (IntPtr) 2.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jon G - 11 Jun 2004 07:28 GMT
Thanks,
I'm gonna try it as soon as possible.
-Jon
> Jon,
>
[quoted text clipped - 6 lines]
> >The second parameter is defined in WinCrypt.h like this: #define
> >CONTEXT_OID_CRL ((LPCSTR)2) I know how to marshal to a LPCSTR , but
what?s
> >the value of it??
>
> Declare it as an IntPtr rather than a string, then pass in (IntPtr) 2.
>
> Mattias