Re: Telling if a DLL is in use
- From: "Geoff" <geoffreyh333@xxxxxxxxx>
- Date: Tue, 11 Oct 2005 22:11:17 -0700
First make a copy of the .dll, then rename the original to something-else,
then try to delete the something-else.
If the renamed-original failed to delete, then it is in use. You can rename
it back to the original name, and delete the copy, and return IN-USE (to
skip trying to delete it).
If the renamed-original deleted successfully, then it was not in use. you
still have the copy, and you can return NOT-IN-USE, and that will continue
to be true (because now there is no file with the original name, just the
copy).
Deleting the file before attempting to delete it may seem to violate your
requirement that you detect in-use before attempting deletion, but it is the
only way to get a detection-routine whose return-value is not potentially
immediately obsolete.
If you return (const char*) 0 for IN-USE, and (const char*) "name-of-copy",
then your detection routine works properly, with the unavoidable side-effect
of making you work with a name-of-copy if it was NOT-IN-USE. But, since you
know the filename you gave the detection routine, and it gives you the name
of the copy, you can rename it back to the original if you decide to not
delete it.
"Rich S." <RichS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3F624DCE-D443-4ECE-A9EA-D5C3FAF6F1AD@xxxxxxxxxxxxxxxx
> Hello,
>
> I need to be able to tell if a DLL is in use before I attempt to delete it
> and replace it with a newer version.
>
> For some reason, Windows is allowing me to call MoveFile(OldDLL, NewDLL)
> on
> the DLL even when it is in use! What's more, it even allows me to copy a
> new
> DLL into its place! The only thing it does not allow is calling
> DeleteFile.
>
> Is this because I am a member of the DEBUGGING group on XP that I am able
> to
> do this?
>
> Is there a better way to tell if a DLL is in use rather than relying on
> receiving an error message when renaming or deleting the DLL?
>
> Thank you very much,
> Rich
.
- Prev by Date: Re: Get command send to COM port
- Next by Date: Re: OpenThread
- Previous by thread: Re: Telling if a DLL is in use
- Next by thread: I need references about hooking
- Index(es):
Relevant Pages
|