1 std::stringstd::wstring相互转换

#include <Windows.h>
static std::wstring StringToWString(const std::string& str)
{
    std::wstring wstr = L"";

    int nLen = (int)str.length();
    wstr.resize(nLen, L' ');

    int nResult = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)str.c_str(), nLen, (LPWSTR)wstr.c_str(), nLen);

    return wstr;
}

static std::string WStringToString(const std::wstring& wstr)
{
    std::string str = "";

    int nLen = (int)wstr.length();
    str.resize(nLen, ' ');

    int nResult = WideCharToMultiByte(CP_ACP, 0, (LPCWSTR)wstr.c_str(), nLen, (LPSTR)str.c_str(), nLen, NULL, NULL);

    return str;
}