在WPF XBAP项目中遇到这样一个问题,程序在Windows 10上面无法运行。原因是因为Windows 10默认浏览器是Edge,而XBAP程序是需要在IE上面运行的。于是开始想办法修改Windows 10的默认浏览器。在Windows 10之前,只需要修改注册表的就可以了。将下面注册表的ProgId设置为IE.HTTP/IE.HTTPS即可。
HKEY_CURRENT_USER\ Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
HKEY_CURRENT_USER\ Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice
Code:
class Program
{ private const string HTTP_KEY = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"; private const string HTTPS_KEY = @"Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice"; static void Main(string[] args)
{
Console.WriteLine("Change default browser to IE");
KeyChange(HTTP_KEY, false);
KeyChange(HTTPS_KEY, true);
Console.WriteLine("Changed successfully.");
Console.ReadKey();
&

