Disable System Error Popup On Run time (DLL Dependencies)

779 views Asked by At

I am working on a WINAPI project which has a few .dll dependencies. Just for clarification, see below:

MyApplication.exe
Util.dll
MySpecialValuable.dll

Let's say I took away MySpecialValuable.dll from the folder path; I will get a message like this: My question is, is there a way I can disable the popup entirely - silently exit? Or somehow hide the name of the .dll inside the popup? This may seem pointless to most but I do not want to expose the libraries I am using.

2

There are 2 answers

0
IInspectable On BEST ANSWER

You cannot "silently exit". The process hasn't started executing user code when the dialog is displayed by the system. Imports are resolved by the loader prior to executing user code.

While there may be ways to configure the system to prevent the error dialog (which I am not aware of), you have other options:

  • The obvious one: Ship all your dependencies. As the author you know your dependencies. There won't be any error messages when all imports can be resolved at load time.
  • Postpone import resolution until you have a chance to handle failure. Marking the respective DLLs as /DELAYLOAD will allow you to do that. See Linker Support for Delay-Loaded DLLs for more information.
  • Use run-time dynamic linking.

Make sure you understand, that none of those options will provide a solution to what you are ultimately trying to accomplish. A user could easily enable loader snaps and get full information on every single module that is loaded into your process.

0
Swordfish On

When you don't link to the .dll with an import library but load it during runtime with LoadLibrary() you can fail silently.