Re: operator new[] fails in DLL when being called from within VB6 process
- From: "Hector Santos" <nospamhere@xxxxxxxxxxxxxx>
- Date: Fri, 21 Oct 2005 15:10:43 -0400
In lieu of showing code, you might need to call CoInitialize() or
CoInitializeEx() when the DLL is first loaded.
I can't remember the details, and our DLL is a complex multi-threaded RPC
client/server wire handler for client applications, but I recall running
into similar memory related GPFs when 3rd party VB6 applications were
importing our standard client/server WINAPI based dlls. Every native
language applications (C/C++, Delphi, etc) worked fine except VB6-based
applets.
You would call CoInitialize() in DLL_PROCESS_ATTACH and you would call
CoUninitialize() in DLL_PROCESS_DETACH.
PS: You didn't mention it, but if your DLL uses threads, you definitely need
to call CoInitialize().
--
Hector Santos, Santronics Software, Inc.
http://www.santronics.com
"Jo Siffert" <jo.siffert@xxxxxxx> wrote in message
news:eVdyCYm1FHA.1028@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I have written a DLL in C/C++ which is used by a VB6 program. Everything
> works fine unless the DLL uses the operator new[] - e.g.
>
> m_pBuffer = new CHAR[ dwApproxPayloadLen ];
>
> then an Access Violation Exception is thrown within ntdll!_RtlAllocHeap.
>
> Calling
> CFoo *f = new Cfoo()
> works just fine - only arrays will not work.
>
> The same code works just fine when being called from a C/C++ program.
>
> Is there something special about calling CRT functions when my lib is
> loaded into a VB6 process? Maybe VB6 does not initialize the CRT as it
> does not use it or something like that?
>
> Thanks in advance,
> Jo
.
- Follow-Ups:
- References:
- Prev by Date: operator new[] fails in DLL when being called from within VB6 process
- Next by Date: Re: Reasonable values for CRITICAL_SECTION spin-count
- Previous by thread: operator new[] fails in DLL when being called from within VB6 process
- Next by thread: Re: operator new[] fails in DLL when being called from within VB6 process
- Index(es):
Relevant Pages
|