【发布时间】:2010-07-22 16:39:09
【问题描述】:
#include "stdafx.h"
#include "string.h"
#include "windows.h"
bool SCS_GetAgentInfo(char name[32],char version[32], char description[256], const char * dwAppVersion)
{
strcpy(name,gName);
strcpy(version,gVersion);
strcpy(description,gDescription);
notify(dwAppVersion);
return true;
}
void notify(const char * msg)
{
MessageBox(NULL, TEXT(msg), NULL, NULL);
}
我已经成功地处理了前三个字段,但是我遇到了 const char * 的问题。我尝试过以很多不同的方式传递和投射,但无法让它发挥作用。我四处搜索,但在 Lmsg 上找不到太多信息。我对此很陌生。我已经阅读过,我认为这可能与编码有关。真正让我困惑的是 LPCTSTR 被定义为 const char *,但直接类型转换并没有给我任何来自该领域的东西。
我收到一个错误,指出 Lmsg 未声明,我猜这意味着 TEXT 的宏扩展导致了这种情况。我怎样才能让它工作?
执行MessageBox(NULL, (LPCTSTR)msg, NULL, NULL); 反而会给我一堆框,表明它可能引用了错误的字符,但是将 dwAppsVersion 参数复制到描述中会显示正确的信息。
【问题讨论】: