我正试图将以前的代码转换为VS 2010。下面提到了我试图转换的代码。函数addCommand的定义如下
addCommand(const ACHAR * cmdGroupName, const ACHAR * cmdGlobalName, const ACHAR * cmdLocalName, Adesk::Int32 commandFlags, AcRxFunctionPtr FunctionAddr,AcEdUIContext *UIContext=NULL, int fcode=-1, HINSTANCE hResourceHandle=NULL, AcEdCommand** cmdPtrRet=NULL)第三个必需的参数是ACHAR类型。函数的调用方式如下。
char cmdLocRes[65];
// If idLocal is not -1, it's treated as an ID for
// a string stored in the resources.
if (idLocal != -1) {
// Load strings from the string table and register the command.
::LoadString(_hdllInstance, idLocal, cmdLocRes, 64);
acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes, cmdFlags, cmdProc);我的问题是变量cmdLocRes是char类型,但是参数需要是ACHAR类型。
我怎样才能转换相同的?
发布于 2014-05-19 10:52:59
// Convert char to wchar_t
char cmdLocRes65;
//备注:确保cmdLocRes包含元素!
cmdLocRes = 'A';
cmdLocRes1 = '\0';
//获得一个wstringstream流
性传播疾病::wstringstream流str;
//将char数组写入Write流
str << cmdLocRes;
//从wstring流中获取wstring
wstring= str.str();
//从wstring获取一个wchar_t
const wchar_t *chr1 1= wstr.c_str();
我们看到wstr.c_str();//我们看到wchar_t == ACHAR!https://stackoverflow.com/questions/22927354
复制相似问题