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.
hi sidharth, when u r passing string in vc++ they are accepted in BSTR format. so u have to first change into CString and then to char* to use it as a string. function used to perform this is #include CString CString_str = _T(""); if (BSTR_str != NULL) // To be sure that input string is valid... { CString s; LPSTR p = s.GetBuffer(::SysStringLen(BSTR_str) + 1); BOOL UsedDefaultChar; ::WideCharToMultiByte(CP_ACP, 0, BSTR_str, -1, p, ::SysStringLen(BSTR_str)+1, NULL, &UsedDefaultChar); if (UsedDefaultChar) // BSTR_str contains an ANSI string CString_str = (LPCTSTR)BSTR_str; else // BSTR_str contains an UNICODE string CString_str = (LPCWSTR)BSTR_str; } char *temp = LPSTR(CString_str); further if u have to include MFC support at the time of creating new ATL project I hope it will help u. Ritu
-
hi sidharth, when u r passing string in vc++ they are accepted in BSTR format. so u have to first change into CString and then to char* to use it as a string. function used to perform this is #include CString CString_str = _T(""); if (BSTR_str != NULL) // To be sure that input string is valid... { CString s; LPSTR p = s.GetBuffer(::SysStringLen(BSTR_str) + 1); BOOL UsedDefaultChar; ::WideCharToMultiByte(CP_ACP, 0, BSTR_str, -1, p, ::SysStringLen(BSTR_str)+1, NULL, &UsedDefaultChar); if (UsedDefaultChar) // BSTR_str contains an ANSI string CString_str = (LPCTSTR)BSTR_str; else // BSTR_str contains an UNICODE string CString_str = (LPCWSTR)BSTR_str; } char *temp = LPSTR(CString_str); further if u have to include MFC support at the time of creating new ATL project I hope it will help u. Ritu
Thanx a lot buddy. That was a breather. I will try and get back.But I am not using MFC. and if I include it will create conflict. Any way let me try first.