table to my exe. i would like to avoid it.
Al.
"--== Alain ==--" wrote:
I'm still working on my DLL and is function to extract strings from
the stringtable stored in the DLL.
it looks like that :
// -- mydll.cpp
extern "C" __declspec(dllexport) LPTSTR GetString(int Index)
{
TCHAR res[2048];
::LoadString(GetModuleHandle(NULL),Index, res,
sizeof(res)/sizeof(TCHAR));
LPTSTR Answer(res);
return((Answer));
}
// -- mydll.h
extern "C" __declspec(dllexport) LPTSTR GetString(int Index);
however, on code --> ::LoadString(GetModuleHandle(NULL),Index, res,
sizeof(res)/sizeof(TCHAR));
res is always empty... i guess that issue is with getModuleHandle.
However, after reading some post on internet, it seems correct...so
where is the mistake ?
The mistake is that GetModuleHandle(NULL) will return handle to the
module used to create the running process. I.e., your .EXE file, not
.DLL, which contains string table.
Youy could eliminate `GetString' function at all. Just store somewhere
in main program handle to the .DLL and call CString::LoadString with
this handle passed as first parameter and string index as second.
HTH
Alex