Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Passing strings between VC++ and VB


Message #1 by "Keith Scott" <keith@b...> on Thu, 14 Sep 2000 23:43:16 +0100
That's often the way people do it. They pad a string variable with the
maximum possible return size. You could also write your C++ component to
support BSTR directly. Some API's take two calls, one two determine the
length needed to hold a particular data and another to actually retrieve and
store the data.

Javier Plumey, MCP3
jplumey@b...

-----Original Message-----
From: Keith Scott [mailto:keith@b...]
Sent: Thursday, September 14, 2000 6:43 PM
To: professional vb
Subject: [pro_vb] Passing strings between VC++ and VB


What is the proper way to pass a string between VB and VC++?

Suppose that you have a string in a VB standard exe that must be passed
into a C++ dll for some sort of processing that will change the length of
the string. My understanding is that in VB a string is a BSTR with an
extra byte on the front of it.  How do you reallocate the memory on the
C++ side so that when the string is passed back into VB, you get the right
string?  Should you make an extra large string on the VB side and pass
that in as a buffer in which to copy the result string?

Thanks,
Keith

  Return to Index