BSTR to const char[]
-
I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:
-
I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:
-
The following line has undefined variable m_bstrFileString (could be typo) m_bstrFileString = newVal; //assign btr to CComBSTR Note : W2A macros has limitation, can not be used in loop. It can convert max 500KB of chars One more soln would be using _bstr_t class.. For Ex: char str[MAX_PATH]; _bstr_t str1(newVal); strcpy(str,(char *)str1); Sandeep Naik
-
I've created a get / put property inside an activeX control. I know the functionality is working ok because i've tested it with script What i now need to do is copy the BSTR into a char* or c style array. I've tried: char str[MAX_PATH]; CComBSTR m_bstrString; put: ATLTRACE(_T("String assigned to: %ls\n"),newVal); m_bstrFileString = newVal; //assign btr to CComBSTR //do conversion BSTR var = m_bstrString.Copy(); strcat(str,(LPCTSTR)var); It only seems to be copying the first char? Please help :doh:
See The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball. "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer." -- Michael P. Butler in the Lounge
-
The following line has undefined variable m_bstrFileString (could be typo) m_bstrFileString = newVal; //assign btr to CComBSTR Note : W2A macros has limitation, can not be used in loop. It can convert max 500KB of chars One more soln would be using _bstr_t class.. For Ex: char str[MAX_PATH]; _bstr_t str1(newVal); strcpy(str,(char *)str1); Sandeep Naik
thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.
-
thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.
-
See The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Laugh it up, fuzzball. "Kosh reminded me of some of the prima-donna programmers I've worked with. Knew everything but when you asked them a question; never gave you a straight answer." -- Michael P. Butler in the Lounge
thanks i will try that. Could you please have a look at my thread 'ATL activeX control Initialize', directly below this one.