VC calling a VB COM dll 
Author Message
 VC calling a VB COM dll

I created a VB cOM dll with parameter list like:

myMethod(a as String)

Then I made a pointer to the COM object (used #import from
the MSKB article), and called the function as from VC like
this:

char* xyz = "aaaa";
ptr->myMethod(abc)
where abc is a BSTR from SysAllocString(xyz);

Compile error: SysAllocString' : cannot convert parameter
1 from 'const char *' to 'const unsigned short *

Same sort of error if I put in a CString in the Alloc
argument.
Help!



Mon, 07 Mar 2005 18:35:14 GMT  
 VC calling a VB COM dll

Quote:
> I created a VB cOM dll with parameter list like:

> myMethod(a as String)

> Then I made a pointer to the COM object (used #import from
> the MSKB article), and called the function as from VC like
> this:

> char* xyz = "aaaa";
> ptr->myMethod(abc)
> where abc is a BSTR from SysAllocString(xyz);

> Compile error: SysAllocString' : cannot convert parameter
> 1 from 'const char *' to 'const unsigned short *

> Same sort of error if I put in a CString in the Alloc
> argument.

It's because SysAllocString doesn't want "char" it wants "WCHAR".

Try this:
WCHAR *  xyz = L"aaaa";

You might also want to try (not compiled):
CString str( "aaaa" );
ptr->myMethod( str.AllocSysString() );

--
russ.
http://www.gipsysoft.com/articles/winspector/ - FREE Spy++ replacement.
http://www.gipsysoft.com/qhtm/ - FREE HTML display in a small and light DLL
http://www.gipsysoft.com/ZoomPlus/ - Programmers Zoom Utility on Steroids



Tue, 08 Mar 2005 01:01:11 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. call a VB COM dll thru a C++ COM dll from a C program

2. call a VB COM dll thru a C++ COM dll from a C program

3. Problem calling VB COM dll from VC++ multithreaded COM EXE client

4. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

5. Calling a VB late bounded COM from VC

6. newbie -- any simple call to COM in VC as in VB

7. Calling a VB late bounded COM from VC

8. call a C# class from a VB 6 COM dll

9. Cant use VC ATL COM DLL method at VB project

10. VC ATL DLL crashin with VB COM client

11. what is the diffrence between Activex DLL in VB and ATL COM in VC

12. A Nasty Debug Problem involving VB, VC (COM) and DLL

 

 
Powered by phpBB® Forum Software