Re: File Version without GetFileVersionInfo
- From: "Alexander Grigoriev" <alegr@xxxxxxxxxxxxx>
- Date: Tue, 21 Jun 2005 21:10:51 -0700
I think in NT+ OS you cannot rename a file if it's open without
FILE_SHARE_DELETE flag. Mapped executables and DLLs are opened without it.
It worked in Win9x, IIRC.
A big mistake of Microsoft was implementing /SWAPRUN flag for CD and network
files only, whereas the really useful feature would be having a file running
from swap no matter what media it's loaded from. This would solve the wicked
problem of deleting loaded executables.
"Mihajlo Cvetanoviæ" <mac@xxxxxxxxxxxxxxxxxx> wrote in message
news:O4ez75kdFHA.412@xxxxxxxxxxxxxxxxxxxxxxx
> Joseph M. Newcomer wrote:
>> OK, I'm curious. How can you replace a currently-installed DLL? (Note
>> that I think I know
>> one trick, but I'm not sure it still works).
>>
>> Note that if the resources are in use, it is normally impossible to
>> replace a DLL.
>
> Suppose we want to update some example.dll (place another with the same
> name). Many processes have it loaded and we can't just call MoveFile on
> it. Suppose further that we choose not to use MoveFileEx with
> MOVEFILE_DELAY_UNTIL_REBOOT, which would be the logical thing to do (but
> requires administrator privileges).
>
> So, we do this (and I believe this is the trick you're referring to):
> rename example.dll to old_example.dll, copy there new example.dll, and
> tell each process to either reload the library, or to restart itself (if
> it's a service) or we just close the process and open it again. When all
> the processes load new example.dll we can safely delete old_example.dll.
>
> In the mean time some processes will have old_example.dll loaded, but if
> they call GetFileVersionInfo they will "think" they have new example.dll,
> which may have undesired results. So to avoid this we can't use
> GetFileVersionInfo, and instead we should use something that deals with
> HMODULE, like FindResourceEx-LoadResource.
>
> The point is that IF we can restart the computer OR we can stop all
> processes, replace the file, and start all processes OR there aren't any
> undesired results with GetFileVersionInfo THEN we don't need
> FindResourceEx.
.
- Follow-Ups:
- Re: File Version without GetFileVersionInfo
- From: Doug Harrison [MVP]
- Re: File Version without GetFileVersionInfo
- References:
- File Version without GetFileVersionInfo
- From: tnewton@xxxxxxxxx
- Re: File Version without GetFileVersionInfo
- From: Yan K. Avlasov
- Re: File Version without GetFileVersionInfo
- From: Joseph M . Newcomer
- Re: File Version without GetFileVersionInfo
- From: Mihajlo Cvetanović
- Re: File Version without GetFileVersionInfo
- From: Joseph M . Newcomer
- Re: File Version without GetFileVersionInfo
- From: Mihajlo Cvetanović
- File Version without GetFileVersionInfo
- Prev by Date: Re: My first thread... program-wise that is
- Next by Date: Re: How to hide project's implementation files
- Previous by thread: Re: File Version without GetFileVersionInfo
- Next by thread: Re: File Version without GetFileVersionInfo
- Index(es):
Relevant Pages
|