Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2006-05-18
9
Medium Priority
?
1,009 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:Eladla
  • 4
  • 2
7 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16708876
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
0
 
LVL 6

Author Comment

by:Eladla
ID: 16708904
I have seen the flipcode site....not much help to me.
Thanks anyway.
Any other ideas?
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 16708906
Alternatively have a look at this post which suggesting to use StringBuilder :

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

-MAHESH

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Eladla
ID: 16708997
I need something similar to the find function of std:string
or it`s useless to me.
I`ll check out your other link.
0
 
LVL 6

Author Comment

by:Eladla
ID: 16710481
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.
0
 
LVL 6

Author Comment

by:Eladla
ID: 16711144
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.
0
 

Accepted Solution

by:
CetusMOD earned 0 total points
ID: 16958129
PAQed with points refunded (150)

CetusMOD
Community Support Moderator
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question