How to set default browser in windows 8 using C#?

只谈情不闲聊 提交于 2019-12-18 16:53:15

问题


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.

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.

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.htm\UserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.html\UserChoice Progid : IE.AssocFile.HTM Hash : XXXXXXXXXXX

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.xht\UserChoice Progid : IE.AssocFile.XHT Hash : XXXXXXXXXXX

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.xhtml\UserChoice Progid : IE.AssocFile.XHT Hash :

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\ftp\UserChoice Progid : IE.FTP Hash : XXXXXXXXXXX

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice Progid : IE.HTTP Hash : XXXXXXXXXXX

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice Progid : IE.HTTPS Hash : XXXXXXXXXXX

Many Thanks in advance.


回答1:


For all those waiting for answer to this question.

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.

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

Following blog has the details.

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-e-g-default-mail-client-for-mailto-protocol.aspx

Thanks.




回答2:


I believe the reason is so that the user, not your software, gets to control this setting.

You ought to be able to trigger the "Your computer has new applications for Web Browsing" popup, however, so that the user can easily choose your program if they want.




回答3:


I asked about this too and managed to find a solution, this might be of a help to you since I tested this on Windows 8.1 and it worked: How to set the default browser on Windows 7 using c#?

This actually fits to a case where you want to make any program as the default of it's protocols and file extensions.



来源:https://stackoverflow.com/questions/16707684/how-to-set-default-browser-in-windows-8-using-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!