使用 John Wu 所说的,我已经解决了这个问题。
此代码将程序条目添加到注册表的“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”。
图书馆:
using Microsoft.Win32
主代码:
RegistryKey software = Registry.LocalMachine.OpenSubKey("SOFTWARE");
RegistryKey microsoft = software.OpenSubKey("Microsoft");
RegistryKey windows = microsoft.OpenSubKey("Windows");
RegistryKey currentversion = windows.OpenSubKey("CurrentVersion");
RegistryKey uninstall = currentversion.OpenSubKey("Uninstall", true);
RegistryKey newappkey = uninstall.CreateSubKey("Enter the name of the program here");
newappkey.SetValue("DisplayIcon", "Path to the program or icon");
newappkey.SetValue("DisplayName", "Enter the name of the program here");
newappkey.SetValue("DisplayVersion", "1.0");
newappkey.SetValue("Publisher", "Leo");
newappkey.SetValue("UninstallString", "Path to the uninstaller");
//I don't know if this part is necessary but I included it anyway
newappkey.Close();
我在其他程序中还发现了一些其他属性,您似乎可以添加:
- InstallLocation(字符串)- 主程序目录的路径。
- ModifyPath (string) - 修改器的路径(通常是带有参数的卸载程序)。
阻止用户按照他们所说的去做的十六进制数
- NoModify - 0 或 1
- NoRemove - 0 或 1
- 无修复 - 0 或 1
估计大小
- EstimatedSize(十六进制)- 转换为十六进制的程序目录的估计大小(以 KB 为单位)。因此,例如,如果程序是 500 MB,那么这将是 500,000 KB,然后应该将其转换为 0x0007a120,这将是注册表项的最终值。