Solved

How should DLL handle exception generated when it is loading

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

21 Experts available now in Live!

Get 1:1 Help Now