[파워빌더] Use Windows Resources from a DLL
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
To use these resources from PowerScript, you need the following local external function declarations.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"
Then from your scriptulong 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)
From a static text constructorulong 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)
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
To use these resources from PowerScript, you need the following local external function declarations.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"
Then from your scriptulong 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)
From a static text constructorulong 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)