【问题标题】:How do I make my program show up in apps and features?如何让我的程序显示在应用程序和功能中?
【发布时间】:2021-07-02 20:24:48
【问题描述】:

我是一名 c# 开发人员,我想知道如何让我的应用程序显示在 windows 设置的应用程序和功能部分。

【问题讨论】:

  • 通过你喜欢的任何安装程序安装它
  • 要显示在应用和功能下,它必须具有被卸载的能力。这类程序在寄存器中注册自己(参见HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall)。您可能不应该自己尝试这样做。用作安装程序设置程序,例如Wix
  • 谢谢@JohnWu

标签: c# .net windows


【解决方案1】:

使用 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,这将是注册表项的最终值。

【讨论】:

    猜你喜欢
    • 2016-05-21
    • 1970-01-01
    • 2011-04-28
    • 1970-01-01
    • 2021-10-16
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多