String from vb to VC
-
Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.
-
Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.
Where are we? VB6? VB.NET? Are you using Declare to initialize the DLL function call in VB6? Or is this VB.NET? More specific code examples? Also, for the c++ code, you might try the c++ forum. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.
First think that comes to mind is you may have to null terminate the string before you send it over.
myString &= chr(0)
Matthew Hazlett Windows 2000/2003 MCSE Never got an MCSD, go figure... -
Please help me I lost my night sleep. Tell in simple code. From my VB client I am passing simple string "Siddharth", to a win32 dll function GetUserName(DATATYPE)(if DAtatype is BSTR or wstring tell me how to convert it into string in dll function declaration). My program should run in 98 as well as NT. I am trying lot of examples but they all are for long. When I convert it to string nothing works out. VB client Dim x as string x = "String" GetStringFromVb(wstring *) end Win32 GetStringFromVb(wstring*) { vector MyString; MyString.push_back(wstring); { //..Lot of string manipulation } } One more issue. in the win32 DLL.h if I declare stl parameter, it is not accepted by the compiler.
VB6 uses BSTR type strings. Which are always Unicode and have their length as the first 4 bytes. When you pass a string to the API ByVal, a copy of the string is automatically made in ASCII (I think!) and a pointer to the copy is actually passed to the function you called. There is no way to "convert" a BSTR into a wString at the function declaration. Either your VB code has to pass the data, NOT necessarily as a String type, to the function in a format the function can deal with, like an array of Bytes that LOOKS like a string, or your function must be able to deal with BSTR's. RageInTheMachine9532
-
Where are we? VB6? VB.NET? Are you using Declare to initialize the DLL function call in VB6? Or is this VB.NET? More specific code examples? Also, for the c++ code, you might try the c++ forum. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
Please don't preach. U know it tell and make me thankful or keep your arse away.
-
Please don't preach. U know it tell and make me thankful or keep your arse away.
Excuse me! He didn't preach anything. He asked you a couple of valid questions about information that you didn't provide in your initial post. Information that is VITAL to answering your question correctly. Keep his 'arse' away??!!??!! It's responses like this that make me question why ... nevermind... You can bet that I won't be helping you anymore. Be nice to the people your asking for help from! RageInTheMachine9532
-
Please don't preach. U know it tell and make me thankful or keep your arse away.
:confused: Yes, perhaps you misinterpreted my inquiry --- and the reference to the c++ forum was a simple suggestion. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.