From: stidolph@magnet.com Subject: Re: [delphi] How do I prevent multiple instances of DLL objects? Date: Tue, 25 Jul 1995 08:39:58 -0400 In Windows 3.1 (or NT/95 16 bit subsystems) DLL's are only loaded once. The first time a DLL is loaded the routine LibMain (if there) is called passing in the HINSTANCE handle for the DLL and some other info. Your DLL will have its own data segment (DS register), but will use the stack of the calling application. When I was writing DLL's for WinHelp I would make a structure that would keep track of all information for a given task and store it in a table with one of the data elements a task handle. When a routine in my dll was called I would call GetCurrentTask and walk through the table looking for the matching task handle. If the task didn't exist I would add a new entry. Generally I would suggest that you have an initialization routine that should be called by all programs using the dll to register whatever application information you need. Also have a routine that will be called on application termination to free memory allocated for that application. Your WEP routine should delete any memory not already freed. Good Luck! ------------------------------------------------ David Stidolph stidolph@magnet.com Why is it that we drive on a parkway and park on a driveway? ------------------------------------------------