Use Windows Resources from a DLLTag(s): WinAPI/Registry
Let's create 2 DLLs containing StringTables for a particuliar language. We create these DLLs with VC++.
First, the French DLL
- Select File - New
- Choose Win32 Dynamic Link with the name resFr
- It's a Simple DLL project
- Select Insert - Resource, and StringTable - New
- The Strings are
ST_1 Ligne un ST_2 Ligne deux
- Save the resource as res_fr.rc and add that file to the project source folder.
- Select Build - set Active Configuration to Win32 Release
- Select Build resFr.dll
The English DLL
- Select File - New
- Choose Win32 Dynamic Link with the name resEn
- It's a Simple DLL project
- Select Insert - Resource, and StringTable - New
- The Strings are
ST_1 Line one ST_2 Line two
- Save the resource as res_en.rc and add that file to the project source folder.
- Select Build - set Active Configuration to Win32 Release
- Select Build resEn.dll
FUNCTION ulong LoadLibraryA (string lpLibFileName) LIBRARY "kernel32.dll" FUNCTION boolean FreeLibrary (ulong hLibModule) LIBRARY "Kernel32.dll" FUNCTION int LoadStringA(ulong hInstance, uint UiD, ref string & lpBuffer, int nBufferMax) LIBRARY "user32.dll"
ulong lul_res string ls_temp constant uint ST_1 = 1 constant uint ST_2 = 2 lul_res = LoadLibraryA("resFr.dll") ls_temp = Space(255) LoadStringA(lul_res, ST_1, ls_temp, 255) MessageBox("The French resource ST_1", ls_temp) FreeLibrary(lul_res) lul_res = LoadLibraryA("resEn.dll") ls_temp = Space(255) LoadStringA(lul_res, ST_2, ls_temp, 255) MessageBox("The English resource ST_2", ls_temp) FreeLibrary(lul_res)
ulong lul_res string ls_temp constant uint ST_1 = 1 lul_res = LoadLibraryA("resEn.dll") ls_temp = Space(255) LoadStringA(lul_res, ST_1, ls_temp, 255) this.text = ls_temp FreeLibrary(lul_res)