From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4fd79a550e1a2b09 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-29 02:14:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!dialin-145-254-039-049.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GNAT, Windows, DLLs Date: Thu, 29 May 2003 11:17:09 +0200 Organization: At home Message-ID: References: <3ED4FA4D.C8823BB8@alfred-hilscher.de> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-039-049.arcor-ip.net (145.254.39.49) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1054199684 5897211 145.254.39.49 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:37976 Date: 2003-05-29T11:17:09+02:00 List-Id: Jano wrote: > Robert A Duff dice... >> Alfred Hilscher writes: >> >> > I have the follwing problem: In gnat_ug it is said, that the code has >> > to call _ada_initialize first and _ada_finalize at last. But - my DLL >> > shall replace an existing third party DLL. So the applications using >> > this DLL are not Ada-aware, and there is no way to tell them "hey the >> > DLL is replaced, you have to call now an initialize-procedure first, >> > and you must call this finalize-procedure at the end". So is there a >> > way to make this initializing/finalizing transparent? >> >> I don't know. Surely there's some way to attach initialization code to >> a DLL? > > I don't remember the details, but I've done it in the past. DLLs have > such initialization/finalization entry points, called if present > automatically by the OS, and there is the best place to place these > procedure calls. The word "DLL" lets me suppose that it is about Windows. If so, then DllMain procedure is called each time a process loads/unloads DLL. It has a parameter to indicate the action (see MSDN DllMain). But beware: 1. DllMain is called within a critical section. Many system operations will hang, no other threads running while you are in. 2. DllMain is not called when process gets aborted. It is one of (many) reasons why the button "Reset" is so useful under Windows. Enjoy Windows programming! -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de