OLESTR("s")
is the same as L"s"
(and OLESTR(s)
is Ls
), which is obviously not what you want.
Use this:
#define url L"http://domain.com"
wstring s1 = url;
wstring s2 = L"/page.html";
wstring s = s1 + s2;
LPCOLESTR o = s.c_str();
This gives you a LPCOLESTR
(ie. a const LPOLESTR
). If you really need it to be non-const, you can copy it to a new string:
...
wstring s = s1 + s2;
LPOLESTR o = new wchar_t[s.length() + 1];
wcscpy(o, s.c_str()); //wide-string equivalent of strcpy is wcscpy
//Don't forget to delete o!
Or, to avoid wstring's altogether (not recommended; it would be better to convert your application to using wstring
's everywhere than to use LPOLESTR
's):
#define url L"http://domain.com"
LPCOLESTR s1 = url;
LPCOLESTR s2 = L"/page.html";
LPOLESTR s = new wchar_t[wcslen(s1) + wcslen(s2) + 1];
wcscpy(s, s1); //wide-string equivalent of strcpy is wcscpy
wcscat(s, s2); //wide-string equivalent of strcat is wcscat
//Don't forget to delete s!