我如何使文件自我更新(Native C ++) [英] How do I make a file self-update (Native C++)
问题描述
我正在将Microsoft Visual Studio 2008与Windows目标部署一起使用.我将如何使文件自我更新"?我已经了解了通过网络传输"部分,但是如何使可执行文件覆盖自身呢?
I'm using Microsoft Visual Studio 2008 with a Windows target deployment. How would I make a file "update itself"? I've already got the "transmitting over a network" part down, but how do I make an executable write over itself?
基本上,我想为还包含自动更新程序的目录编写一个自动更新程序,并且该更新程序需要更新该目录中的所有内容.
Basically, I want to write an auto-updater for a directory that also includes the auto-updater, and the updater needs to update EVERYTHING in the directory.
也许可以使用一种方法对文件进行更改,直到释放文件锁为止.但是,如果要这样做,我可能会通过热补丁对其进行后续处理.
Maybe a ways to pend the changes to the file for until the file lock is released would work. If I were to do that though, I'd probably follow it up with a hot-patch.
推荐答案
编写新的可执行文件并删除或保存旧文件的副本-您可以通过网络发送diff并拥有第三个程序,即更新监视器或其他任何方式来应用它.这只是一个小脚本,当它意识到有可用更新时,可以从远程应用程序启动.更新程序可以将其自身重命名为$ UPDATER_OLD_VERSION或其他名称,并使用适当的名称编写其更新副本,然后在运行新更新程序时,检查应用程序目录中是否存在名为$ UPDATER_OLD_VERSION的文件并将其删除.其他所有文件都只能更新/覆盖.
Write a new executable and delete or save a copy of the old one -- you could send a diff over the network and have a third program, the update monitor or whatever, to apply it. It would be just a small script that could be started from the remote app when it realizes an update is available. The updater could rename itself to $UPDATER_OLD_VERSION or whatever, write an updated copy of itself with the appropriate name, and then when the new updater is run you check if there is a file named $UPDATER_OLD_VERSION in the app directory and delete it. All other files could just be updated/overwritten.
这篇关于我如何使文件自我更新(Native C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!