如何在C ++中调用字符串资源

时间:2011-06-08 08:46:16

标签: string visual-c++ resources

在resource.h中

#define String1 333

在resource.rc

#include <windows.h>
#include "resource.h"

STRINGTABLE
{
    STRING1                   "hie people"
}

在main.cpp

#include<iostream.h>
#include<resource.h>
#include<windows.h>
using namespace std;
int main{
cout<<here i want to output string value from resource how to call the string;
}

还有一个我在代码块中编译的问题。我说resource.h不存在我错的地方

1 个答案:

答案 0 :(得分:8)

我认为它是Visual C ++而你正在使用MFC。它就像调用一样简单:

::LoadString(...)

如果您使用的是MFC,那么

CString str;
str.LoadString(STRING1)

LoadString from MSDN

An Example here of how to use LoadString