I am trying to implement a String Table in resource file .rc and then load specific string using function CString::LoadStringW(). This is the code main.cpp:
#ifndef _AFXDLL
#define _AFXDLL
#endif
#include <afx.h>
#include <stdio.h>
#include "resource.h"
int main()
{
printf("Code Example: Load resource file data\n");
CString sentence;
sentence.LoadStringW(IDS_STRING101);
printf("Sentence: %s", sentence);
getchar();
return 0;
}
There are already good links with description, how to use resource files as:
http://www.cplusplus.com/forum/windows/119338/
http://www.winprog.org/tutorial/resources.html
The problem is when I compile the code and then try to run, it does not read the string. When debuging, the line with LoadStringW() function throws an assertion error:
Debug Assertion Failed!
Program: C:\WINDOWS\SYSTEM32\mfc140ud.dll
File: f:\dd\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl
Line: 24
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
In the end of the first URL I provided is (as last step) to link compiled resource file .rc and my source file main.cpp. I am not sure how to do this and perhaps this is why my program does not work as expected.
Please, do you have any recommendations?
I am trying on MSVS 2015 / 2017.
Thanks.