Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Call A String Resource In C++

in resource.h

#define String1 333

in resource.rc

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

STRINGTABLE
{
    STRING1                   "hie people"
}

in 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;
}

and one more problem i am compiling in code blocks .it says resource.h is not there where i am wrong

like image 453
Dapu Avatar asked Jan 20 '23 13:01

Dapu


1 Answers

I assume that it is Visual C++ and you are using MFC. It is as simple as calling:

::LoadString(...)

And if you are using MFC, then

CString str;
str.LoadString(STRING1)

LoadString from MSDN

An Example here of how to use LoadString

like image 149
Aamir Avatar answered Jan 31 '23 01:01

Aamir