DLL function loading issue

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi,

I have an issue with loading a function from my DLL.

here is the DLL *.cpp file :
extern "C" __declspec(dllexport) LPTSTR GetString(int Index)
{
LPTSTR res="";
LoadString(GetModuleHandle(NULL),Index, res, sizeof(res));
return(_T(res));
}

here is my class which should load the DLL and open the function :
*.cpp file :
HINSTANCE CARDLLWrapper::InitializeLoc(CString DLLName)
{
m_hlibLoc=LoadLibrary(DLLName);
if (m_hlibLoc != NULL)
{
LocGetString = (LPTSTR)GetProcAddress(m_hlibLoc, TEXT("GetString"));
return m_hlibLoc;
}
else
{
return 0;
}
}
/------------------
*.h file
class CARDLLWrapper
{
private:
static LPTSTR (*LocGetString)(long);
static HINSTANCE m_hlibLoc;
CString GetResStr(long Index);

public:
HINSTANCE InitializeLoc(CString DLLName);
void TerminateLoc();
CString STR(long);
};

when i try to compile my class CARDLLWrapper, VC tells me :
cannot convert from 'LPTSTR' to 'LPTSTR (__cdecl *)(long)'

now, i'm confused... i'm turning around and around without seeing what is wrong :-(
a little help would be fantastic.
thx.

Al.
.



Relevant Pages

  • Re: using exe as dll
    ... LoadLibrary fails to load the DLL properly (the entrypoint is never ... BOOL __stdcall _DllMainCRTStartup(HINSTANCE hInstance, DWORD dwReason, PVOID ... int __cdecl WinMainCRTStartup; ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Dll containing class with static member, Linker error
    ... This code is in a DLL called DllTest. ... I figured out if I put the intialization of myint into the header file ... initialization in my cpp file, ... When you initialize the static in the class definition, ...
    (microsoft.public.vc.language)
  • RE: Accessing VC++ classes from .NET
    ... Depending on how your VC++ 6 DLL is structured, ... Add your .CPP file to a VC++.NET Class Library that is in turn referenced ... > platform and I dont' want to migrate the VC++ library (API) to .NET. ... > existing VC++ core client into DLL and add it as a reference to .NET ...
    (microsoft.public.dotnet.languages.csharp)
  • afxMapHWND with Shared Release DLL
    ... Everything works fine in DEBUG mode. ... return CreateDlgIndirect(lpDialogTemplate, m_lpParent, hInstance); ... Also I can STATICALLY link the MFC DLL to the program... ... nafxcw.lib; second definition ignored ...
    (microsoft.public.vc.mfc)
  • FAO J Navia
    ... following is the stack dump for the errors. ... I am also giving the code for the dll along with this mail... ... DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) ... If this Extension DLL is being implicitly linked to by ...
    (comp.lang.c)