Newsgroup: it.comp.lang.visual-basic
Titolo: [?] Sovrascrivere DLL in uso

Con un programma di installazione da me realizzato devo sovrascrivere delle
DLL in uso da Windows. Come faccio a chiuderle per poi sovrascriverle?? Mi
possono aiutare le API o c'è un modo più semplice???
grazie anticipatamente.....

Da MSDN
Summary: How to update a DLL without requiring the system to reboot during
installation.
Although it is not a requirement of the Microsoft Windows® 2000 Logo program
(see 
http://msdn.microsoft.com/winlogo/default.asp
), it is a good idea to
avoid causing a need for reboots during installation of your application.
Your application install should not prompt the user to reboot unless you are
deploying a Windows pack or Service pack as part of your install.
There is a common misperception that, in order to upgrade a DLL that is in
use, the system must be rebooted in order for the DLL update to complete.
This is not how Windows NT® and Windows 2000 work. It is possible to
properly update a shared, in-use DLL without needing a reboot.
If there is a need for a DLL update (which should be determined by a proper
version check), you can update the in-use DLL in a way that allows existing
applications using the original DLL to continue to run with the original
DLL; new applications started after the update can use the new, updated DLL.
To update a DLL this way:
.   Use MoveFileEx to rename foo.dll ->
foo.dll.delete_on_reboot. Do not specify MOVEFILE_COPY_ALLOWED. Make sure
the rename is on the same volume. The easiest way to ensure this is to do
the rename in the same directory as the original file. So, if foo.dll is in
c:\program files\freds house of software, your code would look like the
following example:
MoveFileEx("c:\\program  files\\freds
house  of
software\\foo.dll","c:\\program
files\\freds  house  of
software\\foo.dll.delete_on_reboot",0;
Copy your new, updated DLL to c:\program files\freds house of
software\foo.dll. From this point forward, all applications using foo.dll
will use your new, updated foo.dll.
Use MoveFileEx's delay delete feature to schedule a deletion of
foo.dll.delete_on_reboot on the next reboot of the system. To do this, your
code will look like the following example:
MoveFileEx(
"c:\\program  files\\freds  house  of
software\\foo.dll.deleted_on_reboot",
NULL,
MOVEFILE_DELAY_UNTIL_REBOOT
);
Applications running prior to the DLL update code sequence will use the
original DLL as long as they manually keep it in their address spaces (that
is, if these applications FreeLibrary("foo.dll"), a subsequent
LoadLibrary("foo.dll") will cause them to get the new, updated DLL.)
Applications that are launched and DLL loads that are executed after the
code sequence will get the new DLL.
Be sure to check that the DLL behavior is acceptable. Be especially
observant if the DLL maintains a global state or communicates with other
services and protocols or if shared state layouts have changed. For these
types of DLLs, a reboot will probably be required to ensure that all users
of the DLL are manipulating the same type of state. Of course, if the DLLs
are designed for side-by-side execution, this issue will be solved or
avoided.
Ciao,
Corrado