0

I am looking to load a DLL in Windows and catch the error if a dependency DLL is missing. For now, I get the following error:

[prog.exe] - System Error

The program can't start because issue.dll is missing from your computer. Try reinstalling the program to fix this problem.

Instead of having this error popping up, I would like to be able to either catch that when I load the DLL, or be able to know if I would get an error before loading the dll. And on the Microsoft website, I only see references of LoadLibrary[Ex], but nothing for a kind of SafeLoadLibrary.

Surprisingly, I only found a similar question with the language Delphi on StackOverflow.

Emile D.
  • 602
  • 2
  • 11
  • 20
  • 2
    I think the same solution applies as Delphi. From the doc for LoadLibrary It says ***To enable or disable error messages displayed by the loader during DLL loads, use the SetErrorMode function.*** https://msdn.microsoft.com/en-us/b88f5577-9124-433c-a7e8-a7f713b7b27d – drescherjm Apr 08 '19 at 19:41
  • 1
    `LoadLibrary()` does not throw C++ exceptions, which makes your question very misleading. Anyhow, that's just one point that makes it very unclear what your question actually is, as explicit loading (e.g. via `LoadLibrary()`) has nothing to do with the error you quoted. – Ulrich Eckhardt Apr 08 '19 at 19:43
  • 1
    this error popup when loader can not load dll which is statically linked to your exe, or to dll statically linked to exe. it apper before your exe code begin execute. only solution - remove this dll from static import, and use say delayload, for load it when it first will be need. here you already can control how handle error – RbMm Apr 08 '19 at 20:12
  • https://learn.microsoft.com/en-us/windows/desktop/dlls/using-run-time-dynamic-linking – Cody Gray - on strike Apr 08 '19 at 23:09

0 Answers0