Solved

How should DLL handle exception generated when it is loading

Posted on 1999-01-21
1
178 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now