I am compiling a program for windows.
I want it to check if foo.dll exists in the system, and if not, to print an error message and exit. Is it safe to do it like this:
- pass the
/DELAYLOAD foo.dll
flag to the linker; - at the very beginning of the main(), manually call
auto handle = LoadLibraryA("foo.dll")
and check if handle is not NULL; - if it's not NULL, continue to work;
- at the end of the main(), call FreeLibrary(handle)?
I am wondering if something will break due to mixing delayed loading and manually calling LoadLibraryA(). Also, if someone could suggest a simpler or more correct way to do what I want, I would appreciate it.