Solved

How should DLL handle exception generated when it is loading

Posted on 1999-01-21
1
179 Views
Last Modified: 2010-04-06
I'm writing a DLL that initialises its internal object etc. based on an data held in an INI file - when the the DLL is loaded by an application (using LoadLibrary) initialization section code for various units in the DLL is executed.  

However, I want to be able to handle cases where the INI file is missing or its data invalid.  So far I raise an exception if any of these values are invalid but a run-time 217 error is generated by doing this.  Is there a more graceful way of handling errors when a DLL is being loaded.  Should I be raising exceptions in a DLL when it is loaded / freed.

Thanks

Andrew
0
Comment
Question by:andrewjackson
1 Comment
 
LVL 1

Accepted Solution

by:
zwarte earned 100 total points
ID: 1362679
Build a function in you dll trying to initialize it
if it fails you return false else true so that your program can decide wether or not the initialization worked or not

ex.
 in the dll

function initialize(x,y,z):boolean
var
   status
begin
   status:=true;
   if fileexists('c:\x.ini') then
      status:=true;
   else
      status:=false;
   .....
   result:=status;
end;

in your main program

if not initialize(x,y,z) then
   showmessage('dll did not initialize for some reason');
else
  ....

Or something like that ;-)
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question