
MFC app calling VB ActiveX DLL
Hello,
If you are using MFC, you may call this method as following:
CString m_strIn, m_strOut;
m_strIn = "xxx";
BSTR strIn = m_strIn.AllocSysString();
BSTR strOut = m_strOut.AllocSysString();
lRet = obj->TestString(&strIn,&strOut);
By the way, I suggest you declare the function as TestString(byval strIn as
String, strOut as String) in VB. Then you can call it as
obj->TestString(strIn, &strOut);
Hope this helps.
Regards,
Max
==========================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
|Content-Class: urn:content-classes:message
|Subject: MFC app calling VB ActiveX DLL
|
|I hope someone can help me with this age old problem! :)
|
|I have a VB ActiveX DLL with a public function TestString
|TestString( strIn as String, strOut as String) as long
|
|As the strings in VB are BSTR, how do a pass and receive a
|string from VC++?
|
|eg.
|
|BSTR strIn = "My passed string"
|BSTR strOut = ""
|lRet = obj->TestString(strIn,strOut)
|...
|...
|Do something with the 2 strings
|
|
|I have imported the dll and now it works on calls with no
|arguments but the string conversion is a causing me pain.
|
|Thanks in advance
|
|Brian
|
|