MFC app calling VB ActiveX DLL 
Author Message
 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



Tue, 30 Nov 2004 07:44:30 GMT  
 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
|
|



Fri, 03 Dec 2004 14:23:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calling a VB ActiveX dll from MFC

2. Calling VB ActiveX DLL from MFC applications(Newbie question)

3. Creating an MFC dll to be called from a VB app

4. Creating c dll calling vb ActiveX dll

5. Show modeless form in VB ActiveX DLL from C++ MFC DLL

6. MFC DLL needs to be called from Non-MFC VB.

7. Bad DLL calling convention in my MFC (for VB) DLL

8. Calling MFC DLLs from a non-MFC app

9. VB app won't close when using MFC ActiveX

10. Calling VB ActiveX Control from MFC

11. Atl NT service calling VB ActiveX dll had problem when clean-up

12. How do you call VB ActiveX DLL functions from VC

 

 
Powered by phpBB® Forum Software