Ok, I think I follow you on the return value code, I am trying something like this:

Code:
SysFreeString(szBuffer);
BSTR temp;

temp = SysAllocString(returnValue.c_str());

szBuffer = temp;
As for passing the function the BSTR that it wants when all I have is the wstring, I am still at a loss.