Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,136 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,840 people online right now. Registration is fast and FREE... Join Now!




passing a string from C++ DLL to VB

 
Reply to this topicStart new topic

passing a string from C++ DLL to VB

thiviravadhi
16 May, 2007 - 06:24 AM
Post #1

New D.I.C Head
*

Joined: 3 May, 2007
Posts: 5


My Contributions
CODE

/* Code in VB */

Private Sub sendmsg_Click()
    MsgBox sendDiameterMessage("test.xml")
   //Here I am not getting the value “exists” as passed from C++
End Sub

/* Declaration of the C++ function in VB */

Public Declare Function sendDiameterMessage Lib "VCDLL.dll" (ByVal filename As String) As String

/*Function in C++ */

extern "C" char* __stdcall sendDiameterMessage(char* filename) {
    cout << filename;
        //Here I am getting the value “test.xml” as passed from VB
    char* msg = "exists";
    return msg;
}



i am able to pass a string from VB to a C++ DLL... when i try to do the reverse process, i am going wrong somewhere!

i tried using BSTR, LPSTR instead of char*, not much use!
User is offlineProfile CardPM
+Quote Post

Trogdor
RE: Passing A String From C++ DLL To VB
16 May, 2007 - 09:23 AM
Post #2

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 523



Thanked: 3 times
Dream Kudos: 125
My Contributions
It should be a BSTR as far as i remember.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:34PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month