Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by --== Alain ==--
Fri, 15 Sep 2006 12:31
DLL with string resource
Author: --== Alain ==--
Date: Fri, 15 Sep 2006 12:31
Date: Fri, 15 Sep 2006 12:31
76 lines
3168 bytes
3168 bytes
Hi,
I have old DLLs which contain stringtable as resource.
if i use them via my DLL class wrapper, everything works well.
Now i've created a new DLL via BDS2006, *.h and *.cpp file are similar
to old DLL files. when i compile the new DLL everything is ok.
I have problem when i use it.
BDS2006 returns me the following error :
Project TESTLNG.exe raised exception class EAccessViolation with message
'Access violation at address 00000000. Read of address 00000000'
the problem seems to be located to the GetResStr function.
here is my *.h file of my class wrapper:
//---------------------------------------------------------------------------
#include <System.hpp>
#ifndef CARDLLWrapperH
#define CARDLLWrapperH
//------------------------------------------------------------------------------
static HINSTANCE m_hlibLoc;
String FAR __pascal (*locGetString)(long);
class CARDLLWrapper
{
private:
public:
HINSTANCE __fastcall InitializeLoc(AnsiString DLLName);
void __fastcall TerminateLoc(HINSTANCE hlibLoc);
String __fastcall GetResStr(long Index);
};
//---------------------------------------------------------------------------
#endif
here is my *.cpp file :
//---------------------------------------------------------------------------
#pragma hdrstop
#include "CARDLLWrapper.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//------------------------------------------------------------------------------
HINSTANCE __fastcall CARDLLWrapper::InitializeLoc(AnsiString DLLName)
{
m_hlibLoc=LoadLibrary((DLLName + String(".dll")).c_str());
if (m_hlibLoc != NULL)
{
(FARPROC) locGetString=GetProcAddress(m_hlibLoc,"GETSTRING");
return m_hlibLoc;
}
else
{
return 0;
}
}
//------------------------------------------------------------------------------
String __fastcall CARDLLWrapper::GetResStr(long Index)
{
static String strRes;
strRes=locGetString(Index);
return strRes;
}
in my DLL locGetString is declared as following :
extern "C" String __export GetString(int Index);
String GetString(int Index)
{
String res=AnsiString::LoadStr((int)Index);
return res;
}
Re: DLL with string resource
Author: Danzer
Date: Fri, 15 Sep 2006 15:33
Date: Fri, 15 Sep 2006 15:33
19 lines
1660 bytes
1660 bytes
--== Alain ==-- wrote: > Hi, > > I have old DLLs which contain stringtable as resource. > if i use them via my DLL class wrapper, everything works well. > > Now i've created a new DLL via BDS2006, *.h and *.cpp file are similar > to old DLL files. when i compile the new DLL everything is ok. > > I have problem when i use it. > BDS2006 returns me the following error : > Project TESTLNG.exe raised exception class EAccessViolation with message > 'Access violation at address 00000000. Read of address 00000000' > Have you tried madExcept to help you find where the error occurs? MadExcept is free, if you use it as specified in the EULA. Danzer
Re: DLL with string resource
Author: Bob Gonder
Date: Fri, 15 Sep 2006 20:40
Date: Fri, 15 Sep 2006 20:40
4 lines
1085 bytes
1085 bytes
--== Alain ==-- wrote: See my answer in the Language group, where you also posted this question.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads