I am writing a Windows 32 bit program that can use one of multiple possible dlls. So it tries to load each dll in turn, using SysUtils.SafeLoadLibrary
and if loading succeeds, it uses that dll.
Unfortunately some of these dlls are statically linked to other dlls. These dlls may be missing from the computer. In that case I get dialog telling me
[myprogram]: [myprogram.exe] System Error
The program can't start because [some dll name] is missing from your computer. Try reinstalling the program to fix this problem."
After pressing the OK button on that dialog, the program gets the error code and tries one of the other dlls which then works fine.
Rather than showing that dialog to the user I want my program to silently ignore it.
How can I accomplish that?
In case it matters: My program is written in Delphi 2007. The Windows version is Windows 8.1, but the program should also work with other Windows versions >= Windows XP.
I have tried SetErrorMode(SEM_FAILCRITICALERRORS)
but it did not make any difference.
SetErrorMode(SEM_FAILCRITICALERRORS)
should do the trick. Do some debugging to find out if something else is changing the error mode. For instance, are you callingSafeLoadLibrary
by any chance? Passing zero as the error mode?SafeLoadLibrary
is a crock of s**t. – David Heffernan Jun 13 '17 at 10:34SafeLoadLibrary
does is to screw with the error code. I guess that they couldn't face porting the x86 asm and figured that it didn't matter. – David Heffernan Jun 13 '17 at 14:44