Reputation: 159
I have searched what I am looking for in this website; but I don't understand.
So, I have written this question.
I wrote a .dll file and a program in C++ (Code Blocks IDE). If dll file and program are in same directory, my program will work.
But if I delete dll file and execute my program, Windows shows me this error:
"xxx.exe has stopped working."
I want to "The program can't start because xxx.dll is missing from your computer." message instead of this.
What should I do?
Upvotes: 0
Views: 1375
Reputation: 169
There are three kinds of linking you can do.
When the application calls the LoadLibrary or LoadLibraryEx functions, the system attempts to locate the DLL (for details, see Dynamic-Link Library Search Order). If the search succeeds, the system maps the DLL module into the virtual address space of the process and increments the reference count. If the call to LoadLibrary or LoadLibraryEx specifies a DLL whose code is already mapped into the virtual address space of the calling process, the function simply returns a handle to the DLL and increments the DLL reference count. ~ taken from here
What you want to do is a run-time link to your dll and test the result instead of what you are currently doing.
Visual Studio offers a third option, delay-loaded DLL's.~ MSalters
which handles the loadLibrary calls for you.
Upvotes: 1