- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, hope anayone can help me.
I wrote a CVF program (console application) that uses some functions and subrotines ofa DLL also written in CVF. These functions/subroutines are not always used, just in some specific calculations.
I noticed that, when staring the main program the DLL is also loaded to memory, even if the functions/subroutines are never used. Thus, the DLL is unloaded only when the main program exits.
Questions:
1) Is there any way to load the DLL only when it is actually to be used by the main program?
2) Is there a way to unload the DLL when it is no more needed?
Thanks.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There are two ways to defer loading a DLL. The one you want is to call LoadLibrary to load the DLL, GetProcAddress to get the routine address, and use the extension that allows calling through a pointer to call the routine. You can then call FreeLibrary to unload the DLL. See the DLLLOADEXP1 sample provided with CVF.
There is also a way to defer the loading until you do a call that does not require coding changes, using a linker feature called "delayed loading", but you can't then unload the DLL.
There is also a way to defer the loading until you do a call that does not require coding changes, using a linker feature called "delayed loading", but you can't then unload the DLL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, but I still have some questions:
1) In the main CVF program I must include the LIB associated to the DLL, otherwise I get some "unsolved external" error messages. I doing so, I understand the DLL will be automatically loaded when the main program starts.
2) So, I supose LOADLIBRARY will not apply here. Am I right?
3) If so I still dont know if it is really possible to defer loading the DLL.
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you use LoadLibrary, you do not need to link against the .LIB. However, the coding of the call is slightly more complicated. Again, the sample I pointed you to illustrates this technique in detail.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now I got it to work fine.
Thanks.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page