You are creating a temporary std::wstring and, using c_str(), assign a pointer to a member of that temporary to the variable wstr. After the assignment, the temporary variable get deleted and you are left with a dangling pointer.
An easy way to avoid this is:
std::wstring tmp = Conversions::to_wstring("hello");
LPCWSTR wstr = tmp.c_str(); // wstr is valid as long as tmp is in scope
But that still leave the door open for similar bugs. Better to use a std::wstring or CString instead of the LPCWSTR.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky