CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    29

    Unloading a DLL at runtime?

    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


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Unloading a DLL at runtime?

    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).



  3. #3
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    29

    Re: Unloading a DLL at runtime?

    How do i do this is Visual basic? Loadlibrary is a C call isn't it?

    Jean-Guy


  4. #4
    Join Date
    May 1999
    Posts
    3,332

    Re: Unloading a DLL at runtime?

    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)


  5. #5
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    29

    Re: Unloading a DLL at runtime?

    I have got that part, and used GetProcAddress to get the address now how do I call it?

    Jean-Guy


  6. #6
    Join Date
    Aug 2000
    Location
    Rotterdam, Netherlands
    Posts
    115

    Re: Unloading a DLL at runtime?

    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



  7. #7
    Join Date
    May 1999
    Posts
    3,332

    Re: Unloading a DLL at runtime?

    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)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured