vb-c++-connection

Discussion in 'Visual Basic ( VB )' started by AMK, Sep 9, 2006.

  1. AMK

    AMK New Member

    Joined:
    Sep 9, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    c++ dll has exported funtion call such as:
    void AccessUnknownBuf(char** cbuffer, int sizeofbuf);
    VB does not know about the size of cbuffer beforehand. It has to get the cbuffer and its size from dll. How VB can do this?. somehow it should be accessing dll's memory area...?. seconldy, how to allocate more than 40000 bytes for character string type?.
    dim s as string*50000 does not work.
     
  2. AMK

    AMK New Member

    Joined:
    Sep 9, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    It is actually like this:
    void AccessUnknownBuf(char** cbuffer, int* sizeofcbuffer);
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    AccessUnknownBuf should supply the size of the buffer for some default parameter and in VB use the string with SPACE to fill the buffer and pass that as an argument to the function.
     
  4. AMK

    AMK New Member

    Joined:
    Sep 9, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    how do you allocate this many mem space to string?.
    Dim s as string*50000 (got overflow error).
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Code:
    Dim str As String
    str = Space(1000)
    This will allocate the string with 1000 buffer size by default and this can be used easily with the C++ buffer.
     
  6. AMK

    AMK New Member

    Joined:
    Sep 9, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    there is no way that i can access c++ dll's cBuffer content without allocating memory in VB?.
     
  7. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I dont think so. You are calling a function in a C++ dll and all you can get is the return type of the function or any pointer that you provide are having some data and the second option requires you to have the buffer in VB and pass that to C++ dll.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice