Results 1 to 3 of 3

Thread: Exposing C++ DLL funcitons to VB

  1. #1
    Join Date
    Oct 2004
    Posts
    52
    Rep Power
    0

    Default Exposing C++ DLL funcitons to VB

    have a prob and I just haven't been able to figure it out. If any of
    you have a solution or suggestion please send it to me as soon as you
    can.

    What I need to know is how to pass a string type, by reference and as
    a parameter, form VB to a DLL written in Visual C++. Right now I am
    trying it and I am not getting values back from the dll even though I
    get the values when I either debug the dll or run it from a driver app
    compiled in C.

    The problem is that I have a VB client app accessing a Visual C++
    standard DLL. The client app needs to send a string values to the dll
    and have the dll update these values for later use by the client app.

    I can contact the dll and get the values it's just that when it gets
    back to the client app it is gibberish. I have tried just sending the
    string on way and I realise that C++ arrays and VB strings have
    compatability issues.

    Looking forward to some speedy response.

  2. #2
    Join Date
    Jul 2004
    Posts
    264
    Rep Power
    0

    Default Re: Exposing C++ DLL funcitons to VB

    ok ... if u defined the c++ dll to accept a normal character array then u have to declare the function in VB to pass the string value, by value with the ByVal specifier. This is because Vb uses a string object that has a header which contains info on the data it contains. If u don't want to use the ByVal specifier and allow the c++ dll to manipulate the same variable that was passed to the function in the dll then u can use the BSTR data type. this is a pointer to the Vb string data object. this u can pass like a normal variable in Vb.

    if u need more info check out this link info

  3. #3
    Join Date
    Oct 2004
    Posts
    52
    Rep Power
    0

    Default Re: Exposing C++ DLL funcitons to VB

    Thanx for the advise 'killa. I actually happened across this article myself and tried what I consider to be every permitation of the BSTR, byval, byref declarations that I could think of. The most success I hap was being able to see the first letter of the string I passed. I find that even integer values I pass to the dll get "curropted". I passed "7" once and viewed a value of "-3939939.22"(not exact) in the dll. Not quite sure what is up.

    I had put that project off (missed the deadline) to persue some more indepth research (which I haven't gotten around to yet). Suggestions are welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •