Visual Studio 2005 问题 - 类型转换char to LPWSTR
大家请看下面一段代码:
CString str;
BROWSEINFO bi;
char path[MAX_PATH];
ZeroMemory(&bi,sizeof(BROWSEINFO));
bi.hwndOwner = GetSafeHwnd();
bi.pszDisplayName = path;
bi.lpszTitle = _T("请选择GDC2000系统路径...");
bi.ulFlags = BIF_EDITBOX;
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
if(idl == NULL)
return;
SHGetPathFromIDList(idl,str.GetBuffer(MAX_PATH));
str.ReleaseBuffer();
m_dir = str;
CString a = str.GetAt(str.GetLength()-1);
if(a != "\\")
m_dir += "\\";
UpdateData(FALSE);
在VC6.0中编译没有一点问题,但在VS2005中不能通过,具体错误为:
错误 1 error C2440: '=' : cannot convert from 'char [260]' to 'LPWSTR'(是指“bi.pszDisplayName = path”这一句)
错误 2 error C2440: 'initializing' : cannot convert from 'wchar_t' to 'ATL::CStringT<BaseType,StringTraits>'(是指“CString a = str.GetAt(str.GetLength()-1)”这一句)
请问如何转换char类型为LPWSTR类型,以及char *类型为LPCWSTR类型?
这二条错误怎么解决?