Re: function in DLL
- From: "Alex Blekhman" <xfkt@xxxxxxxxx>
- Date: Sat, 30 Sep 2006 22:38:15 +0300
"--== 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
.
- Follow-Ups:
- Re: function in DLL
- From: --== Alain ==--
- Re: function in DLL
- References:
- function in DLL
- From: --== Alain ==--
- function in DLL
- Prev by Date: Re: DLL function loading issue
- Next by Date: Re: DLL function loading issue
- Previous by thread: function in DLL
- Next by thread: Re: function in DLL
- Index(es):
Relevant Pages
|