Article View: borland.public.cppbuilder.database.multi-tier
Article #1519Dynamically loaded functions crash
From: Lawerence McHugh
Date: Tue, 02 Nov 1999 00:00
Date: Tue, 02 Nov 1999 00:00
54 lines
2118 bytes
2118 bytes
I am using C++ builder 3 to interface to a database via a dynamically loaded
DLL. Can anyone explain why the program crashes if I do not allocate local
storage in the a module that is not used. for example this code crashes out
with an memory access error.
void __fastcall TForm1::Callit(TObject *Sender);
{
hLib = LoadLibrary("C:\\Program Files\\Goldmine\\gm4s32.dll");
if( hLib ){
// Get address
fnGMW_DB_Append GMW_DB_Append = (fnGMW_DB_Append)
etProcAddress( (HINSTANCE) hLib,"GMW_DB_Append");
// pArea & szBuf are public members
pArea = GMW_DB_Open( "OPMGR" );
if(pArea)
{
if( GMW_DB_Append( pArea, szBuf )!= 0) {
GMW_DB_Unlock(pArea);
}
}}}
however if I add char store[1000] in the module all works fine.
void __fastcall TForm1::Callit(TObject *Sender);
{
char store[1000]
hLib = LoadLibrary("C:\\Program Files\\Goldmine\\gm4s32.dll");
if( hLib ){
// Get address
fnGMW_DB_Append GMW_DB_Append = (fnGMW_DB_Append)
etProcAddress( (HINSTANCE) hLib,"GMW_DB_Append");
// pArea & szBuf are public members
pArea = GMW_DB_Open( "OPMGR" );
if(pArea)
{
if( GMW_DB_Append( pArea, szBuf )!= 0) {
GMW_DB_Unlock(pArea);
}
}}}
I don't want to leave the program like this as I cannot understand what is
happening. The more calls I make to functions in the DLL I need to increase
the size of store. I'm sure there is a simple explanation. possibly I'm
doing something stupid can anyone point me in the right direction?
Technical Details
Message-ID:
<7vm59c$34t6@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fcd2b,7fd0e155acbef3d5,start X-Google-Attributes: gidfcd2b,public From: "Lawerence McHugh" <Law@nireland.com> Subject: Dynamically loaded functions crash Date: 1999/11/02 Message-ID: <7vm59c$34t6@forums.borland.com> X-Deja-AN: 543425038 X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Reply-To: "Lawerence McHugh" <Law@nireland.com> Newsgroups: borland.public.cppbuilder.database.multi-tier