[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How should DLL handle exception generated when it is loading

Posted on 1999-01-21
1
Medium Priority
?
196 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 300 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

872 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