在默认浏览器列表中显示自己的应用 (C#) Windows10
Show own app in list for default browser (C#) Windows10
我希望我的应用程序在默认浏览器下显示。在过去的 3 天里,我找到了很多关于它的文章。没有解决方案似乎是正确的。
它应该出现在这里:
enter image description here
它应该适用于 Windows 10。在文章 ( https://docs.microsoft.com/en-us/windows/win32/shell/default-programs?redirectedfrom=MSDN ) 中显示了哪些注册表项应该处理这个问题。但它不起作用。是的,我已经阅读了有关改变 win 10 中标准应用程序设置方式的警告,但我不想以编程方式设置它,我希望我的应用程序显示在那里。
谁有更具体的信息给我?
我的代码设置了文章和注册表中的注册表项,我可以在使用我的应用程序后看到它们。所以我不会在这里显示我添加注册表项的代码,但是当然,有没有解决方案,我会添加代码...
谢谢!
又是我。
我终于找到了解决办法。
请原谅我这段代码,但我没有找到注册表项的“官方”文档。我确定我的代码中有一些不是必需的键,但它可以工作,因此您可以自己测试哪些键可以省略。
该代码是搜索 www
~ 7 天的结果
public static void SetDefaultBrowser(string _appName, string _appPath, string _appID, string _appDescription)
{
string pfadschluessel = "SOFTWARE\Clients\StartMenuInternet\" + _appName;
string pfadschluessel_cap = pfadschluessel + "\Capabilities";
string pfadschluessel_cap_fileA = pfadschluessel_cap + "\FileAssociations";
string pfadschluessel_cap_Startmenu = pfadschluessel_cap + "\Startmenu";
string pfadschluessel_cap_URL = pfadschluessel_cap + "\URLAssociations";
Registry.LocalMachine.CreateSubKey(pfadschluessel).SetValue("", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel).SetValue("LocalizedString", "@" + _appPath);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationDescription", _appDescription);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationIcon", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationName", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".htm", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".html", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".shtml", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".xhtml", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".xht", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_Startmenu).SetValue("StartMenuInternet", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("ftp", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("http", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("https", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("mailto", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("webcal", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\InstallInfo").SetValue("", "");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\shell\open\command").SetValue("", "\"" + _appPath + "\"");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\.htm\OpenWithProgIds").SetValue(_appID, "");
string PFAD_software_ = "SOFTWARE\" + _appName;
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationDescription", _appDescription);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationName", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationIcon", _appPath);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".htm", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".html", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".shtml", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".xhtml", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".xht", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\Startmenu").SetValue("StartmenuInternet", _appPath);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("ftp", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("http", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("https", _appID);
Registry.LocalMachine.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, PFAD_software_ + "\Capabilities");
Registry.CurrentUser.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, PFAD_software_ + "\Capabilities");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("FriendlyTypeName", _appName);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("Editflags", 2);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + _appName + ".exe").SetValue("Path", _appPath);
Registry.ClassesRoot.CreateSubKey(_appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.ClassesRoot.CreateSubKey(_appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.ClassesRoot.CreateSubKey(_appID).SetValue("AppUserModelId", _appName);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationDescription", _appDescription);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationName", _appName);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationIcon", _appPath);
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\shell\open\command").SetValue("", _appPath);
Registry.LocalMachine.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, pfadschluessel_cap);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("FriendlyTypeName", _appName);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("Editflags", 2);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.LocalMachine.CreateSubKey("SOFTWARE\MDK\" + _appID + "\Capabilities").SetValue("ApplicationName", _appName);
}
_appName = 您的浏览器名称FooBar 浏览器
_appPath = .exe 的路径,例如C:\foobar\foobar.exe
_appID = 软件的appID。如果您编写了一个新的控制台应用程序(classname = Program,Projectname = foobar),那么它将是“foobar.Program”
_appDescription = 一个简短的描述,它是什么
我希望我的应用程序在默认浏览器下显示。在过去的 3 天里,我找到了很多关于它的文章。没有解决方案似乎是正确的。 它应该出现在这里: enter image description here
它应该适用于 Windows 10。在文章 ( https://docs.microsoft.com/en-us/windows/win32/shell/default-programs?redirectedfrom=MSDN ) 中显示了哪些注册表项应该处理这个问题。但它不起作用。是的,我已经阅读了有关改变 win 10 中标准应用程序设置方式的警告,但我不想以编程方式设置它,我希望我的应用程序显示在那里。 谁有更具体的信息给我?
我的代码设置了文章和注册表中的注册表项,我可以在使用我的应用程序后看到它们。所以我不会在这里显示我添加注册表项的代码,但是当然,有没有解决方案,我会添加代码...
谢谢!
又是我。 我终于找到了解决办法。 请原谅我这段代码,但我没有找到注册表项的“官方”文档。我确定我的代码中有一些不是必需的键,但它可以工作,因此您可以自己测试哪些键可以省略。 该代码是搜索 www
~ 7 天的结果 public static void SetDefaultBrowser(string _appName, string _appPath, string _appID, string _appDescription)
{
string pfadschluessel = "SOFTWARE\Clients\StartMenuInternet\" + _appName;
string pfadschluessel_cap = pfadschluessel + "\Capabilities";
string pfadschluessel_cap_fileA = pfadschluessel_cap + "\FileAssociations";
string pfadschluessel_cap_Startmenu = pfadschluessel_cap + "\Startmenu";
string pfadschluessel_cap_URL = pfadschluessel_cap + "\URLAssociations";
Registry.LocalMachine.CreateSubKey(pfadschluessel).SetValue("", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel).SetValue("LocalizedString", "@" + _appPath);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationDescription", _appDescription);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationIcon", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap).SetValue("ApplicationName", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".htm", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".html", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".shtml", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".xhtml", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_fileA).SetValue(".xht", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_Startmenu).SetValue("StartMenuInternet", _appName);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("ftp", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("http", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("https", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("mailto", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel_cap_URL).SetValue("webcal", _appID);
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\InstallInfo").SetValue("", "");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\shell\open\command").SetValue("", "\"" + _appPath + "\"");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\.htm\OpenWithProgIds").SetValue(_appID, "");
string PFAD_software_ = "SOFTWARE\" + _appName;
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationDescription", _appDescription);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationName", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities").SetValue("ApplicationIcon", _appPath);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".htm", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".html", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".shtml", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".xhtml", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\FileAssociations").SetValue(".xht", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\Startmenu").SetValue("StartmenuInternet", _appPath);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("ftp", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("http", _appID);
Registry.LocalMachine.CreateSubKey(PFAD_software_ + "\Capabilities\UrlAssociations").SetValue("https", _appID);
Registry.LocalMachine.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, PFAD_software_ + "\Capabilities");
Registry.CurrentUser.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, PFAD_software_ + "\Capabilities");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("FriendlyTypeName", _appName);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("Editflags", 2);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" + _appName + ".exe").SetValue("Path", _appPath);
Registry.ClassesRoot.CreateSubKey(_appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.ClassesRoot.CreateSubKey(_appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.ClassesRoot.CreateSubKey(_appID).SetValue("AppUserModelId", _appName);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationDescription", _appDescription);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationName", _appName);
Registry.ClassesRoot.CreateSubKey(_appID + "\Application").SetValue("ApplicationIcon", _appPath);
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey(pfadschluessel + "\shell\open\command").SetValue("", _appPath);
Registry.LocalMachine.CreateSubKey("SOFTWARE\RegisteredApplications").SetValue(_appName, pfadschluessel_cap);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("FriendlyTypeName", _appName);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID).SetValue("Editflags", 2);
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\DefaultIcon").SetValue("", _appPath + ",0");
Registry.LocalMachine.CreateSubKey("SOFTWARE\Classes\" + _appID + "\shell\open\command").SetValue("", "\"" + _appPath + "\"%1");
Registry.LocalMachine.CreateSubKey("SOFTWARE\MDK\" + _appID + "\Capabilities").SetValue("ApplicationName", _appName);
}
_appName = 您的浏览器名称FooBar 浏览器
_appPath = .exe 的路径,例如C:\foobar\foobar.exe
_appID = 软件的appID。如果您编写了一个新的控制台应用程序(classname = Program,Projectname = foobar),那么它将是“foobar.Program”
_appDescription = 一个简短的描述,它是什么