用_T()宏包含你的字符串,如:_T("Hello,World!")
解决方案 »
- 龚建伟的用MSCOMM 串口
- m_pConnection->Open runtime error
- ActiveX控件里面的控件句柄全然没法拿到吗?
- 散分展示下最新进展。。。
- 求助!! 对话框之间变量访问的问题
- 怎样制作类似media player的漂亮界面(VC.NET)
- 注册表问题,在DELPHI没解决,特来邀请VC高手帮忙~!先奉上100分,不够可以再加;解决者也请到DELPHI版回帖,我将一起结算
- “哪个窗口拥有焦点”和"哪个窗口是活动的”是否等价?
- 一个简单问题,但是忘记怎么解决了
- operation valid only when the port is open
- windows 9x里面有msconfig来控制启动选项,请问:2000下有什么类似的命令呢?
- 那位能告诉我VS.net 的CDkey?多谢并送百分。
1. 常量字串,应采用zhanghy(zhanghy)的方法:将字串以L作为前导,如 L"abc"
2. char*型字串,则需要转换,方法有三
1) 使用USECONVERTION宏和A2W宏
2) 当使用C++.net时,直接用CA2W模板,如:CA2W(__str)
3) 使用转换函数MultiByteToWideChar,如:(这里考虑对Ascii以外的字符集)
// we want to convert an MBCS string in lpszA
int nLen = MultiByteToWideChar(CP_ACP, 0,lpszA, -1, NULL, NULL);
LPWSTR lpszW = new WCHAR[nLen];
MultiByteToWideChar(CP_ACP, 0,
lpszA, -1, lpszW, nLen);
// use it to call OLE here
pI->SomeFunctionThatNeedsUnicode(lpszW);
// free the string
delete[] lpszW;
DWORD GetAdapterIndex(
LPWSTR AdapterName, // name of the adapter :这里
PULONG IfIndex // index of the adapter
);已经得到
AdapterName=“{02..}”;
看来要两步转换??
CString str1="?????";
BSTR bstr1=str1.AllocSysString();
.......
FreeSysString(bstr1);
用:
swprintf(ws,L"%S",s); //和sprintf的用法差不多
wchar_t *pwchData = new wchar_t[2];
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,pchData,-1,pwchData,strlen(pchData)+1);
{
USES_CONVERSION;
...
LPWSTR x = A2W(lpsz)
// Do something with x
...
}头文件可能是atl.h或者atlbase.h没有查,自己找找看