将自写的卸载程序添加到控制面板中
本文以C#语言为例,但实际上你可以使用任何语言来做这件事,甚至你都可以手动添加。
先直接明了,上图片:
上图是我在注册表中找到WinRAR的卸载信息,这些信息存储在注册表的HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall的下面的子键中。
里面关键的几个:
DisplayName:软件名称
UninstallString:卸载命令
有这两个就可以做一个可以用的卸载项了。。你也可以用注册表编辑器打开这个键,参考其它软件填写的内容。
例如:
注册表信息:
常用的我们可以增加更改和修复选项:
ModifyPath:修改文件路径
DisplayVersion:版本
URLInfoAbout:网址
最后把自己写的一个类分享给大家
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
public static class UninstallHelper { private static bool creatUninstallInControlPanel(string appName, string uninstallFile, string publisher = "TsonTec", string ver = "1.0.0.0", string helpurl = "https://tson.com/dckit") { //获取注册表项 RegistryKey hkml = Registry.LocalMachine; RegistryKey software = hkml.OpenSubKey(@"SOFTWAREMicrosoftWindowsCurrentVersionUninstall", true); RegistryKey app = software.CreateSubKey(appName); app.SetValue("DisplayName", appName); //卸载命令 app.SetValue("UninstallString", uninstallFile); app.SetValue("DisplayIcon", uninstallFile); app.SetValue("Publisher", publisher); app.SetValue("InstallDate", DateTime.Now.ToString("yyyyMMdd")); app.SetValue("NoModify", 1, RegistryValueKind.DWord); app.SetValue("NoRepair", 1, RegistryValueKind.DWord); app.SetValue("DisplayVersion", ver); app.SetValue("HelpLink", helpurl); return true; } } |
说点什么