Data Type VC++ <--> VB6

R

robert

Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code. I have managed to get as far as creating the instance of the COM
object and calling a method from within the C++ program - not being a
C++ programmer at all, this was a huge undertaking, and I'm very proud
of myself for even getting this far ;-).

My Question is in relation to passing parameters from the C++ program
to my VB COM Object. If I define a String variable in VB, what must my
parameter in C++ be in order for it to talk properly. There seems to be
a whole host of string types available - CHAR, CString, LPCOLESTR,
OLESTR, TCHAR, blah, blah, blah, and each of these types are only
applicable for specific things. Maybe I have it wrong, if so, please
correct me. Number data is also a headache. If someone could explain to
me the correlation from C++ to VB, maybe even provide a list of C++ to
VB data type equivalents, I would be most appreciative.

Many Thanks Rob
 
K

Kurt Krueckeberg

Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code. I have managed to get as far as creating the instance of the COM
object and calling a method from within the C++ program - not being a
C++ programmer at all, this was a huge undertaking, and I'm very proud
of myself for even getting this far ;-).

My Question is in relation to passing parameters from the C++ program
to my VB COM Object. If I define a String variable in VB, what must my
parameter in C++ be in order for it to talk properly. There seems to be
a whole host of string types available - CHAR, CString, LPCOLESTR,
OLESTR, TCHAR, blah, blah, blah, and each of these types are only
applicable for specific things. Maybe I have it wrong, if so, please
correct me. Number data is also a headache. If someone could explain to
me the correlation from C++ to VB, maybe even provide a list of C++ to
VB data type equivalents, I would be most appreciative.

Many Thanks Rob

A BSTR in C++ corresponds to the VB String.

BSTR Manipulation Functions Descriptions
SysAllocString Creates and initializes a string.
SysAllocStringByteLen Creates a zero-terminated string of a specified length
(32-bit only).
SysAllocStringLen Creates a string of a specified length.
SysFreeString Frees a previously created string.
SysReAllocString Changes the size and value of a string.
SysReAllocStringLen Changes the size of an existing string.
SysStringByteLen Returns the length of a string in bytes (32-bit
only).
SysStringLen Returns the length of a string.

_bstr_t is a VC++ wrapper for BSTR. The Active Template Library wrapper is
CComBSTR.
 
R

Raymond Martineau

Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code.

Not many people here know how to interact with the windows API.

http://www.slack.net/~shiva/welcome.txt

<ot>
As the other poster mentioned, the desired datatype is BSTR. You can find
the other appropriate datatypes under the "IDispatch Data Types and
Structures" section in the MSDN help file.
</ot>
 
R

robert

Thanks guys, that helped. Not sure what it means, but I had a problem
when My BSTR parameters (3 of them), were positioned after my numeric
parameters (2 doubles, 1 __int64). They were coming through as blank on
the vb side. Switching them around so that I have the BSTR params
first, then all the numerics. Wierd ?, dunno, but at least it's working
now. Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top