如何使用 C# 在 Windows 8 中设置默认浏览器?

How to set default browser in windows 8 using C#?(如何使用 C# 在 Windows 8 中设置默认浏览器?)

本文介绍了如何使用 C# 在 Windows 8 中设置默认浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 8 之前(在 XP/VISTA/WIN7 中)我们都可以轻松做到这一点,只需对注册表进行少量更改即可.

We all have been easily able to do this prior to Windows 8 (in XP/VISTA/WIN7) with few changes in Registry and it was done.

在 Windows 8 中,这并不容易(我还没有弄清楚如何).Windows 8 也几乎没有下面提到的要更改的注册表设置,但除此之外,它还为每台计算机存储了一个唯一的哈希.任何人都可以帮助我为每台计算机或使用 Microsoft 提供的一些 API 来设置默认浏览器创建此哈希(SetAppAsDefaultAll"不起作用).以下是注册表项.

With Windows 8 it's not that easy (I'm yet to figure it out how). Windows 8 too has few registry settings to be changed mentioned below, but along with this it also stores a unique Hash for every computer. Can any body help me to possibly create this hash for every computer or with some API provided by Microsoft to set default browser ('SetAppAsDefaultAll' does not work). Following are the registry entries.

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmUserChoiceProgid : IE.AssocFile.HTM 哈希 : XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmUserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmlUserChoiceProgid : IE.AssocFile.HTM 哈希 : XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.htmlUserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtUserChoiceProgid : IE.AssocFile.XHT 哈希 : XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtUserChoice Progid : IE.AssocFile.XHT Hash : XXXXXXXXXXX

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtmlUserChoiceProgid:IE.AssocFile.XHT 哈希:

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionExplorerFileExts.xhtmlUserChoice Progid : IE.AssocFile.XHT Hash :

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationsftpUserChoiceProgid : IE.FTP 哈希 : XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationsftpUserChoice Progid : IE.FTP Hash : XXXXXXXXXXX

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpUserChoiceProgid : IE.HTTP 哈希 : XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpUserChoice Progid : IE.HTTP Hash : XXXXXXXXXXX

计算机HKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpsUserChoiceProgid:IE.HTTPS 哈希:XXXXXXXXXXX

ComputerHKEY_CURRENT_USERSoftwareMicrosoftWindowsShellAssociationsUrlAssociationshttpsUserChoice Progid : IE.HTTPS Hash : XXXXXXXXXXX

非常感谢.

推荐答案

致所有等待回答这个问题的人.

For all those waiting for answer to this question.

你去吧,看起来其中一种方法是通过 Win 8 提供的 DISM.exe.不过你的用户应该是机器的管理员.

Here you go, looks like that one of the way to do it is through DISM.exe provided by Win 8. Your user should be admin of the machine though.

使用 C# 代码,您应该能够使用特定参数运行此 DISM.exe.

Using C# code you should be able to run this DISM.exe with specific parameters.

以下博客有详细信息.

http://blogs.technet.com/b/mrmlcgn/archive/2013/02/26/windows-8-associate-a-file-type-or-protocol-with-a-specific-app-using-a-gpo-eg-default-mail-client-for-mailto-protocol.aspx

谢谢.

这篇关于如何使用 C# 在 Windows 8 中设置默认浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何使用 C# 在 Windows 8 中设置默认浏览器?

基础教程推荐