在WPF XBAP項(xiàng)目中遇到這樣一個(gè)問題,程序在Windows 10上面無法運(yùn)行。原因是因?yàn)閃indows 10默認(rèn)瀏覽器是Edge,而XBAP程序是需要在IE上面運(yùn)行的。于是開始想辦法修改Windows 10的默認(rèn)瀏覽器。在Windows 10之前,只需要修改注冊表的就可以了。將下面注冊表的ProgId設(shè)置為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(); &