How to get at runtime the filename of a dll in error?

delphi package - automated exception handling
Post Reply
aaangeli
Posts: 9
Joined: Mon Sep 22, 2014 7:35 am

How to get at runtime the filename of a dll in error?

Post by aaangeli »

Hi, my program is composed by an exe and several DLLs. When an exception is raised in a DLL, I'would like to know which dll filename is in error (I need to customize some mantis sending parameters related to this filename). I'm trying to get it with exceptIntf.Module but it returns always the main exe module handle. Is it something possible to achieve?

Thank you
Davide
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to get at runtime the filename of a dll in error?

Post by madshi »

Usually it's the EXE which does the exception handling, that's why your try didn't work. What you can do is check the crash address (exceptIntf.ExceptAddr). You can use "madTools.FindModule" to get the DLL/EXE name that owns the ExceptAddr. That could be your DLL, or your EXE. But it could also be a system DLL. So for a "perfect" solution you would have to browse through the crash callstack and find the first entry that belongs to one of your DLLs or EXE. You can do that by analyzing exceptIntf.Callstacks[0].
Post Reply