Click to See Complete Forum and Search --> : Unloading a DLL at runtime?
Jean-Guy
July 17th, 2000, 09:02 AM
Is it possible to unload a dll at runtime? When I call a dll for the first time it loads and remains loaded untill the EXE unloads. I want to 'unbind' the dll from the EXE during runtime to free the resources the DLL uses. Is this possible?
Thanks
Jean-Guy
Lothar Haensler
July 17th, 2000, 09:09 AM
you can (safely) unload a DLL only if you load it explicitly.
1st step: LoadLibrary(Ex) returns handle to the DLL
2nd step: FreeLibrary releases the DLL; requires the handle to the DLL, though (from the 1st step).
Jean-Guy
July 17th, 2000, 09:19 AM
How do i do this is Visual basic? Loadlibrary is a C call isn't it?
Jean-Guy
Lothar Haensler
July 17th, 2000, 09:23 AM
LoadLibrary is an API function that you can call from Visual Basic.
Just get the Declare Statement from the API Declaration Add-In in VB and paste in your VB code.
Then, call it like a VB function
dim h as Long
h = LoadLibrary("yourdllpath")
..
Call FreeLibrary(H)
Jean-Guy
July 17th, 2000, 09:41 AM
I have got that part, and used GetProcAddress to get the address now how do I call it?
Jean-Guy
law
August 29th, 2000, 07:16 AM
can i also load DLL's made in Visual basic with this function?
I really hope so, because my problems are solved then. I wanted to make an App with plugins (like Winamp)
bye
Lothar Haensler
August 29th, 2000, 07:21 AM
you can load any 32-bit DLL with LoadLibrary(Ex) and unload it with FreeLibrary.
But, you can't do much with a loaded VB ActiveX DLL.
You need to use CreateObject to instantiate an ActiveX component (it you want to use late binding)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.