function in DLL



Hi,

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 ?

thx,

Al.
.



Relevant Pages

  • Re: function in DLL
    ... You cannot return a pointer to a local array. ... I'm still working on my DLL and is function to extract strings from the ... res is always empty... ...
    (microsoft.public.vc.language)
  • Re: Specify DLL version when using mc.exe, rc.exe and/or link.exe
    ... when I right click on the DLL. ... ResEdit and XN Resource Editor seem to be able to ... into into a RES file rather than the RC file. ... Tony Toews, Microsoft Access MVP ...
    (microsoft.public.vb.general.discussion)
  • Weird passing by reference problem.
    ... It is set up as a com dll with "Register for com interop" checked. ... Dim p1 As PassByOut.Class1 ... res = p1.Test'b and c are both blank ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: function in DLL
    ... table to my exe. ... So my question is how can i get the Handle of the DLL? ... ::LoadString,Index, res, sizeof/sizeof); ... 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. ...
    (microsoft.public.vc.language)
  • Re: C++Builder Code in Delphi Projekt verwenden? Alternative ?
    ... einer Binär-Resource ins Programmverzeichnis schreiben, ... Dann wird das EXE zwar größer aber es ... DLL aus RES anlegen wenn nicht vorhanden ...
    (de.comp.lang.delphi.misc)