wchar_t* 转 char*

int wstr2str(const wchar_t* _wstr,std::string& _cstr)
{
	int len = WideCharToMultiByte(CP_ACP, 0, _wstr, -1, NULL, 0, NULL, NULL);
	char* str = new char[len + 1];
	int rlen = WideCharToMultiByte(CP_ACP, 0, _wstr, -1, str, len, NULL, NULL);
	str[len] = '\0';
	_cstr = str;
	return rlen;
}

char* 转 wchar_t*

int str2wstr(const char* _str, std::wstring& _wstr)
{
	int len = MultiByteToWideChar(CP_ACP, 0, _str, -1, NULL, 0);
	wchar_t* wstr = new wchar_t[len + 1];
	int rlen = MultiByteToWideChar(CP_ACP, 0, _str, -1, wstr, len);
	wstr[len] = L'\0';
	_wstr = wstr;
	return rlen;
}