在C++/CLI中使用资源文件里的String Table字符串对应值的方法
在C++/CLI中使用资源文件里的String Table字符串对应值的方法
For Example:
Step1: Defining a string in VS String Table
IDValueCaption
IDS_STRTEST101HowtousestringdefinedinStringTable
IDS_STRTEST101HowtousestringdefinedinStringTable
Step2 Test it in a CLI Console Application
#include"atlbase.h"
#include"resource.h"
intmain(array<System::String^>^args)
{
//DeclareaCComBSTRobject
CComBSTRbsTableString;
//loadstringfromstringtable
bsTableString.LoadString(IDS_STRTEST);
//ConvertthestringintoanANSIstring
CW2CTszMyString(bsTableString);
//DisplaytheANSIstring
MessageBox(NULL,szMyString,_T("StringTest"),MB_OK);
return0;
}
#include"resource.h"
intmain(array<System::String^>^args)
{
//DeclareaCComBSTRobject
CComBSTRbsTableString;
//loadstringfromstringtable
bsTableString.LoadString(IDS_STRTEST);
//ConvertthestringintoanANSIstring
CW2CTszMyString(bsTableString);
//DisplaytheANSIstring
MessageBox(NULL,szMyString,_T("StringTest"),MB_OK);
return0;
}