How can I copy/replace a DLL?

好久不见. 提交于 2019-12-04 03:22:49

Your method is fine - just rename the file and copy the new DLL into the proper location. Once that is done, you can use the Windows API function MoveFileEx to register the old file for deletion the next time the machine is restarted. From the MSDN documentation:

If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.

So you would want to do something like:

MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);

I have not worked much with Delphi. Presumably you could either import the proper Windows API functions and make this call directly from Delphi, or else write a small C++ program that you can call to take care of this for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!