Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   vb-c++-connection (http://www.go4expert.com/forums/vb-cpp-connection-t1367/)

AMK 9Sep2006 12:34

vb-c++-connection
 
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.

AMK 9Sep2006 12:36

Re: vb-c++-connection
 
It is actually like this:
void AccessUnknownBuf(char** cbuffer, int* sizeofcbuffer);

shabbir 9Sep2006 14:18

Re: vb-c++-connection
 
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.

AMK 9Sep2006 20:36

Re: vb-c++-connection
 
how do you allocate this many mem space to string?.
Dim s as string*50000 (got overflow error).

shabbir 10Sep2006 06:02

Re: vb-c++-connection
 
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.

AMK 10Sep2006 10:38

Re: vb-c++-connection
 
there is no way that i can access c++ dll's cBuffer content without allocating memory in VB?.

shabbir 10Sep2006 11:25

Re: vb-c++-connection
 
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.


All times are GMT +5.5. The time now is 02:13.