How to Free a Load-Time DLL?

This is a discussion on How to Free a Load-Time DLL? within the Windows Programming forums, part of the Platform Specific Boards category; Does anyone know to Free a Load-Time DLL? When you load a DLL when your process is already running and ...

  1. #1
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    62

    Question How to Free a Load-Time DLL?

    Does anyone know to Free a Load-Time DLL?

    When you load a DLL when your process is already running and has started up, you use the LoadLibrary function to load it, that is called Run-Time Dynamic Linking. And when you are done with the DLL, you don't need it anymore, you use the FreeLibrary function to unmap it from your address space.

    But when you use a DLL at the beginning of your process, when it is starting up, you use the header files with the functions of your DLL and the .a file during compiling. Now you just can call the functions of your DLL in your program, that is called Load-Time Dynamic Linking. But when you don't need it anymore, somehow, how can you unmap the DLL from your address space? Using the FreeLibrary function doesn't work.

    Thanks in advance, Ktulu.
    This parameter is reserved

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    You can do it with delayloaded dlls
    http://msdn2.microsoft.com/en-US/library/96c1b5cf.aspx
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    62
    I am using Dev-C++ and I don't have a Visual C++ 7.0 compiler. Isn't there any other way for Dev-C++?
    This parameter is reserved

  4. #4
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    62
    I guess this awnser ends in a "You can't." or TerminateProcess, =\.
    This parameter is reserved

  5. #5
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,266
    I think the question we should be asking you is "why to free a load-time DLL? (sic)".
    Given the presence of dynamic linking that you've already described, why would you want to dismantle a static link?

    You can stick your head out of a window on a train. But aside from a death wish, why?

  6. #6
    Registered User Ktulu's Avatar
    Join Date
    Oct 2006
    Posts
    62
    To delete the DLL without terminating the process.
    This parameter is reserved

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    903
    And why would you want to do this ? That sounds like you are trying to make something illegal there.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    A load-time linked DLL is load-time linked because you have code that directly calls into that DLL. This code has absolutely no checking that this DLL is actually present: if it wasn't, the loader would already complain. Unloading a load-time linked DLL would therefore be a receipe for disaster: the next time the code in question is executed, it will jump into the memory where the DLL used to be. Probably by now it was unmapped and trying to execute it will result in an access violation.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 08:11 AM
  2. App or DLL Load address
    By bman1176 in forum Windows Programming
    Replies: 2
    Last Post: 02-28-2006, 02:36 PM
  3. Read and set\change system time
    By Hexxx in forum C++ Programming
    Replies: 9
    Last Post: 01-02-2006, 07:11 AM
  4. DLL Function / Load Library Problem
    By cboard_member in forum Windows Programming
    Replies: 5
    Last Post: 12-10-2005, 10:11 AM
  5. load MMC snap in dll
    By rohit in forum Windows Programming
    Replies: 1
    Last Post: 02-21-2002, 11:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21