Article View: borland.public.cppbuilder.nativeapi
Article #15960Re: DLLEntryPoint question...
From: Russell Hind
Date: Thu, 05 Jun 2003 11:05
Date: Thu, 05 Jun 2003 11:05
30 lines
1967 bytes
1967 bytes
MWP wrote: > Hi all... > > Why is DLLEntryPoint being called more often than just when LoadLibrary is run? It is called more than once. It is called for the reasons in the 'reason' argument. i.e. DLL_PROCESS_ATTACH DLL_THREAD_ATTACH DLL_PROCESS_DETACH DLL_THREAD_DETACH If the dll creates lots of threads, then the entry point will get called for every thread that is created. If you only want to perform actions in it when you load and unload it, then check against DLL_PROCESS_ATTACH and DLL_PROCESS_DETACH. But remember, you are very limited in what you can do in the entry point because the only system functions that are safe to call are those from kernel32.dll. That basically means most, if not all, of the std c lib and std c++ lib are out as is all of the VCL. forcing a call into any other system routine other than those in kernel32.dll during this method causes un-predictable behaviour. Cheers Russell
Technical Details
Message-ID:
<3edf2428$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3edf0eb4$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,7c6655192f46f69f X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-05 04:17:42 PST Date: Thu, 05 Jun 2003 12:05:30 +0100 From: Russell Hind <rhind@mac.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: DLLEntryPoint question... References: <3edf0eb4$1@newsgroups.borland.com> In-Reply-To: <3edf0eb4$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 212.240.15.125 Message-ID: <3edf2428$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054811176 212.240.15.125 (5 Jun 2003 04:06:16 -0700) Lines: 31 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail