我想将 TCHAR 数组转换为 wstring。
TCHAR szFileName[MAX_PATH+1];
#ifdef _DEBUG
std::string str="m:\\compiled\\data.dat";
TCHAR *param=new TCHAR[str.size()+1];
szFileName[str.size()]=0;
std::copy(str.begin(),str.end(),szFileName);
#else
//Retrieve the path to the data.dat in the same dir as our data.dll is located
GetModuleFileName(_Module.m_hInst, szFileName, MAX_PATH+1);
StrCpy(PathFindFileName(szFileName), _T("data.dat"));
#endif
wstring sPath(T2W(szFileName));
我需要传递szFileName
给期望的函数
const WCHAR *
为了完整起见,我正在说明我需要传递szFileName
给的空白:
HRESULT CEngObj::MapFile( const WCHAR * pszTokenVal, // Value that contains file path
HANDLE * phMapping, // Pointer to file mapping handle
void ** ppvData ) // Pointer to the data
但是,T2W 对我不起作用。编译器说that "_lpa" is not defined
,我不知道从哪里开始。我已经尝试了我在网上找到的其他转换方法,但它们也不起作用。