Replace exe and dll in use

V

Viviana Vc

Hi all,

I have 2 questions:

1) As I know there is no way on Windows to replace a running exe, but
somebody told me that this is doable, and I couldn't find any info on
how could this be done programmatically. Is something like this
possible? And if yes, how?

2) My product has a dll that is used by multimple application from the
system. Is there any way in which I could update this dll (without
killing all the exe that have loaded this dll)? Or this is doable only
over a reboot?
If it's only over a reboot, how could I do the following: i have in the
same dir dll and dll_new, how could I do in one step: delete dll and
rename dll_new with dll?

Thanks in advance,
Viv
 
G

Gary Chanson

Viviana Vc said:
Hi all,

I have 2 questions:

1) As I know there is no way on Windows to replace a running exe, but
somebody told me that this is doable, and I couldn't find any info on
how could this be done programmatically. Is something like this
possible? And if yes, how?

2) My product has a dll that is used by multimple application from the
system. Is there any way in which I could update this dll (without
killing all the exe that have loaded this dll)? Or this is doable only
over a reboot?
If it's only over a reboot, how could I do the following: i have in the
same dir dll and dll_new, how could I do in one step: delete dll and
rename dll_new with dll?

In both cases, you can't. Depending on what operating system you're
running you may be able to rename or move the file and copy a new file with
the old file name, but the running programs will continue to use the old
file until the programs are restarted.
 
S

Slobodan Brcin \(eMVP\)

Hi Viviana,

MoveFileEx MOVEFILE_DELAY_UNTIL_REBOOT

Does this help with question 2?

Best regards,
Slobodan
 
R

r_z_aret

Hi all,

I have 2 questions:

1) As I know there is no way on Windows to replace a running exe, but
somebody told me that this is doable, and I couldn't find any info on
how could this be done programmatically. Is something like this
possible? And if yes, how?

Not directly. But you can have an auxiliary program that stops your
main program, replaces it, and restarts it.
2) My product has a dll that is used by multimple application from the
system. Is there any way in which I could update this dll (without
killing all the exe that have loaded this dll)? Or this is doable only
over a reboot?

How about renaming the old DLL, copying in (or renaming) the
replacement, and letting each program start using the new version
whenever it restarted?

If you have a list of programs that you want to coerce, you could
close and restart them.

If it's only over a reboot, how could I do the following: i have in the
same dir dll and dll_new, how could I do in one step: delete dll and
rename dll_new with dll?

Thanks in advance,
Viv

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
 
S

Slobodan Brcin \(eMVP\)

Hi Viviana,

MoveFileEx MOVEFILE_DELAY_UNTIL_REBOOT

Does this help with question 2?

Best regards,
Slobodan

PS:
Sorry if this is second time that I post this but I can't see my yesterdays post.
 
V

Viviana Vc

Yes it does. Thx!
Looks like the following:
MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
would make the trick of: deleting the old dll and renaming the new dll
as the old one, all of them over a reboot, as those dlls are used by a
lot of application and even by the system so they can be done only over
a reboot.

Viv
 
V

Viviana Vc

Not directly. But you can have an auxiliary program that stops your
main program, replaces it, and restarts it.

Yes, already thought about this being the only way out ...
How about renaming the old DLL, copying in (or renaming) the
replacement, and letting each program start using the new version
whenever it restarted?

Upss, I didn't know that I could rename a dll that is already loaded by
some applications! Because I couldn't replace it I thought that also
renaming will fail. Seems not. And the same if for the running exes.
But in the dll case, as I don't know all the app that have loaded it, so
I can not restart only those, I will need a reboot anyhow, so I could
also use the MoveFileEx right?
 
R

r_z_aret

clip


Upss, I didn't know that I could rename a dll that is already loaded by
some applications! Because I couldn't replace it I thought that also
renaming will fail. Seems not. And the same if for the running exes.
But in the dll case, as I don't know all the app that have loaded it, so
I can not restart only those, I will need a reboot anyhow, so I could
also use the MoveFileEx right?

Rename is a special case of Move. I use MoveFile, not MoveFileEx. And
not for anything tricky. So I'm quite sure you're getting better info
about MoveFileEx in another set of responses.

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top