问题
How do I substitute the running EXE with a new version ?
回答1:
You can do it this way:
- rename the running EXE,
- copy the new version to the old name,
- when the new version is started have it delete the renamed EXE
Note that this is definitely not recommended behaviour.
回答2:
Short: By stopping it, and starting the new version.
Long: When you start an application, the operating system loads the application in memory (or at least the parts that are needed) and sets up all the memory regions the run the program. While the application is running, the binary (what you call the EXE) is not needed anymore by the operating system.
If you would want to replace code in a running application, you could do that by replacing the code segment. I do not know if it is possible or easy in Windows. Another option could be to use some kind of plugin system, where you can replace parts of the application while it is still running.
来源:https://stackoverflow.com/questions/12261007/how-do-i-update-the-running-exe