在程序卸载时调用函数/ Api

时间:2012-07-14 09:37:31

标签: c# .net c windows winapi

如何实现以下方案,

1)应该只有一个exe应该执行一些代码

2)此外,它应该在添加/删除程序中添加一个条目

3)当我从添加/删除程序中卸载条目时,我需要调用一些函数/ api来完成卸载。

1 个答案:

答案 0 :(得分:2)

如果你需要“调用一些函数/ api”就像在下次重启时删除文件一样简单 - 按照here的说明将其设为“重新启动时删除”:

  

Windows注册表编辑器版本5.00   [HKEY_CLASSES_ROOT * \ shell \在reboot \ command上删除]   @ =“CMD / E:OFF / C REG ADD> HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ Currentversion \ RunOnce / v \”Del%1> OnNextReboot \“/ d ^ \”cmd.exe / c DEL / F / Q \\“%1 \\”\“/ f \”“   [HKEY_CLASSES_ROOT * \壳\打开]   [HKEY_CLASSES_ROOT \ Folder \ shell \在reboot \ command上删除]   @ =“CMD / E:OFF / C REG ADD> HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ Currentversion \ RunOnce / v \”Del%1> OnNextReboot \“/ d ^ \”cmd.exe / c RD / S / Q \\“%1 \\”\“/ f \”“

要在重新启动时删除注册表项,请使用此(解释here):

  

[HKEY_CLASSES_ROOT * \ shell \在reboot \ command上删除]   @ =“CMD / E:OFF / C REG ADD> HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ Currentversion \ RunOnce / v \”Del%1> OnNextReboot \“/ d ^ \”cmd.exe / c DEL / F / Q \\“%1 \\”\“/ f \”“   [HKEY_CLASSES_ROOT * \壳\打开]   [HKEY_CLASSES_ROOT \ Folder \ shell \在reboot \ command上删除]   @ =“CMD / E:OFF / C REG ADD> HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ Currentversion \ RunOnce / v \”Del%1> OnNextReboot \“/ d ^ \”cmd.exe / c RD / S / Q \\“%1 \\”\“/ f \”“