Help with a Declare (pointer to a pointer)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Help with a Declare (pointer to a pointer)

  1. #1
    Sean Woods Guest

    Help with a Declare (pointer to a pointer)

    I have a function that I am trying to write a Declare for in VB. Any help
    on it would be appreciated.

    The C function looks like this:
    WINCRYPT32API HCERTSTORE WINAPI CertOpenStore(
    IN LPCSTR lpszStoreProvider, IN DWORD dwEncodingType,
    IN HCRYPTPROV hCryptProv, IN DWORD dwFlags, IN const void *pvPara);

    What I have got for the VB delcare is:
    Public Declare Function CertOpenStore Lib "crypt32.dll"

    ByVal lpszStoreProvider As String, ByVal dwMsgAndCertEncodingType As
    Long,
    ByVal hCyrptProv As Long, ByVal dwFlags As Long, ByVal pvPara As Long)
    As Long

    I think this is close but that last parameter maybe wrong because it appears
    to be a pointer to a pointer.

    The next question... How do I actually use that declare. Again it is the
    last parameter that gives me problems? In particular what I need to pass in
    is a unicode string, or a reference to one rather, but later it could be
    something else later.

    Any help would be very much appreciated.

    Thanks
    Sean Woods



  2. #2
    Mattias Sjögren Guest

    Re: Help with a Declare (pointer to a pointer)

    Sean,

    >What I have got for the VB delcare is:
    >Public Declare Function CertOpenStore Lib "crypt32.dll"
    >
    > ByVal lpszStoreProvider As String, ByVal dwMsgAndCertEncodingType As
    >Long,
    > ByVal hCyrptProv As Long, ByVal dwFlags As Long, ByVal pvPara As Long)
    >As Long


    >I think this is close


    It looks like it should work. You could also declare the the last
    parameter As Any if you ever need to pass something else to it.


    >but that last parameter maybe wrong because it appears
    >to be a pointer to a pointer.


    No, it's a simple one-level pointer, that can point to anything.


    >The next question... How do I actually use that declare. Again it is the
    >last parameter that gives me problems? In particular what I need to pass in
    >is a unicode string, or a reference to one rather, but later it could be
    >something else later.


    For Unicode strings, pass it StrPtr(YourString)


    Mattias

    ===
    Mattias Sjögren (VB MVP)
    mattias @ mvps.org
    http://www.msjogren.net/dotnet/

  3. #3
    Mattias Sjögren Guest

    Re: Help with a Declare (pointer to a pointer)

    Sean,

    >What I have got for the VB delcare is:
    >Public Declare Function CertOpenStore Lib "crypt32.dll"
    >
    > ByVal lpszStoreProvider As String, ByVal dwMsgAndCertEncodingType As
    >Long,
    > ByVal hCyrptProv As Long, ByVal dwFlags As Long, ByVal pvPara As Long)
    >As Long


    >I think this is close


    It looks like it should work. You could also declare the the last
    parameter As Any if you ever need to pass something else to it.


    >but that last parameter maybe wrong because it appears
    >to be a pointer to a pointer.


    No, it's a simple one-level pointer, that can point to anything.


    >The next question... How do I actually use that declare. Again it is the
    >last parameter that gives me problems? In particular what I need to pass in
    >is a unicode string, or a reference to one rather, but later it could be
    >something else later.


    For Unicode strings, pass it StrPtr(YourString)


    Mattias

    ===
    Mattias Sjögren (VB MVP)
    mattias @ mvps.org
    http://www.msjogren.net/dotnet/

  4. #4
    Sean Woods Guest

    Re: Help with a Declare (pointer to a pointer)

    Mattias,

    Thanks... that did the trick. I always forget about StrPtr, VarPtr, and
    ObjPtr.

    Sean


    "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
    news:3c0fd0da$1@147.208.176.211...
    > Sean,
    >
    > >What I have got for the VB delcare is:
    > >Public Declare Function CertOpenStore Lib "crypt32.dll"
    > >
    > > ByVal lpszStoreProvider As String, ByVal dwMsgAndCertEncodingType As
    > >Long,
    > > ByVal hCyrptProv As Long, ByVal dwFlags As Long, ByVal pvPara As

    Long)
    > >As Long

    >
    > >I think this is close

    >
    > It looks like it should work. You could also declare the the last
    > parameter As Any if you ever need to pass something else to it.
    >
    >
    > >but that last parameter maybe wrong because it appears
    > >to be a pointer to a pointer.

    >
    > No, it's a simple one-level pointer, that can point to anything.
    >
    >
    > >The next question... How do I actually use that declare. Again it is the
    > >last parameter that gives me problems? In particular what I need to pass

    in
    > >is a unicode string, or a reference to one rather, but later it could be
    > >something else later.

    >
    > For Unicode strings, pass it StrPtr(YourString)
    >
    >
    > Mattias
    >
    > ===
    > Mattias Sjögren (VB MVP)
    > mattias @ mvps.org
    > http://www.msjogren.net/dotnet/




  5. #5
    Sean Woods Guest

    Re: Help with a Declare (pointer to a pointer)

    Mattias,

    Thanks... that did the trick. I always forget about StrPtr, VarPtr, and
    ObjPtr.

    Sean


    "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
    news:3c0fd0da$1@147.208.176.211...
    > Sean,
    >
    > >What I have got for the VB delcare is:
    > >Public Declare Function CertOpenStore Lib "crypt32.dll"
    > >
    > > ByVal lpszStoreProvider As String, ByVal dwMsgAndCertEncodingType As
    > >Long,
    > > ByVal hCyrptProv As Long, ByVal dwFlags As Long, ByVal pvPara As

    Long)
    > >As Long

    >
    > >I think this is close

    >
    > It looks like it should work. You could also declare the the last
    > parameter As Any if you ever need to pass something else to it.
    >
    >
    > >but that last parameter maybe wrong because it appears
    > >to be a pointer to a pointer.

    >
    > No, it's a simple one-level pointer, that can point to anything.
    >
    >
    > >The next question... How do I actually use that declare. Again it is the
    > >last parameter that gives me problems? In particular what I need to pass

    in
    > >is a unicode string, or a reference to one rather, but later it could be
    > >something else later.

    >
    > For Unicode strings, pass it StrPtr(YourString)
    >
    >
    > Mattias
    >
    > ===
    > Mattias Sjögren (VB MVP)
    > mattias @ mvps.org
    > http://www.msjogren.net/dotnet/




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center