Link to home
Start Free TrialLog in
Avatar of Eladla
EladlaFlag for Israel

asked on

Passing a string from VB.NET to C++ DLL

I need to pass a string from VB.NET to a C++ DLL.
My limitation is that I need to be able to manipulate the string in c++, I need all the functionalty I get from std::string.
I tryed casting to std::string without much luck.
I need the VB.NET type, C++ type and any other casts or code needed to use them.
Thanks!
Avatar of mahesh1402
mahesh1402
Flag of India image

I think you may do this using safearrays.

Following may be helpful :

Handling VB strings (as part of an array of UDT)
http://www.codeguru.com/Cpp/W-P/dll/interfacingtovisualbasicapplications/article.php/c103/

Interfacing VB and C++
http://www.flipcode.com/articles/article_vbdlls.shtml

-MAHESH
Avatar of Eladla

ASKER

I have seen the flipcode site....not much help to me.
Thanks anyway.
Any other ideas?
Alternatively have a look at this post which suggesting to use StringBuilder :

http://www.dotnet247.com/247reference/msgs/40/200377.aspx <====

-MAHESH

Avatar of Eladla

ASKER

I need something similar to the find function of std:string
or it`s useless to me.
I`ll check out your other link.
Avatar of Eladla

ASKER

I checked out the StringBuilder...it would work, but since I`m using unmanaged code and would rather
stick to stdlib C++, I don`t want to import .net namespaces and such.
Avatar of Eladla

ASKER

I have already found this:
http://groups.google.com/group/microsoft.public.vc.language/browse_thread/thread/c743b54624a1009c/cee84773330632aa?lnk=st&q=cast+BSTR+to+std%3A%3Astring&rnum=2&hl=en#cee84773330632aa

And it looks like it`s working. If anyone has better ideas, mainly ones that do not require
com or atl type references...please let me know.
ASKER CERTIFIED SOLUTION
Avatar of CetusMOD
CetusMOD
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial