Solved

How should DLL handle exception generated when it is loading

Posted on 1999-01-21
1
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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