Link to home
Start Free TrialLog in
Avatar of LearningCpp
LearningCpp

asked on

Need to add mulltiple BSTR strings using C++

Hi,
I need to add multiple bstr strings using C++, I am aware to add bstr we can:

int lenBuffer;
BSTR bstr1,bstr2, bstr3,;
//assign some values to bstr's
lenBuffer = SysStringLen(bstr1) + SysStringLen(bstr2) + SysStringLen(bstr3);
BSTR bstrQuery;
bstrQuery = SysAllocStringLen(L"",lenBuffer+1);
wcscat_s(bstrQuery,lenBuffer+1,bstr1);
wcscat_s(bstrQuery,lenBuffer+1,bstr2);
wcscat_s(bstrQuery,lenBuffer+1,bstr3);

is there any better way of doing it, I have around 6 bstr strings(or more) to concatenate, whats the best possible way of doing it?

TIA

ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LearningCpp
LearningCpp

ASKER

What is the significance of adding:
#include
Will this work in pure win32 environment, currently I am developing in VS IDE 2005. but will have to port only to pure win32 api environment
Yes, it will.