如何确定Windows默认浏览器(在开始菜单的顶部)

sou*_*ain 8 browser windows vb6

如何确定Windows默认浏览器(位于开始菜单的顶部)?

我正在使用VB6,但可能适应其他代码没有问题.

Stack Overflow上有类似的问题,但它们似乎提供了错误的答案.

例如,密钥HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet \在我的PC上列出了Internet Explorer和Firefox.

并且.html关联也失败了,因为HTML文件与IE相关联,但Firefox是我的默认浏览器.

请注意,我不想实际打开浏览器,只需获取它的名称即可.

Pis*_*3.0 15

HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default)是HTTP协议的当前用户的处理程序(这意味着"默认浏览器";注意:这与.html默认处理程序不同!).

但是,可以在"开始"菜单的顶部使用不同的浏览器而不更改默认值.仅供参考,"开始"菜单中的浏览器可执行文件名称存储在HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).

  • 在 Windows 10 中,`HKCU\Software\Classes\http`(和 `https`)键是空的。打开 http(即通过运行对话框)的默认浏览器由 [Greg T 的回答](/sf/answers/871147441/) 中的子键定义。 (6认同)
  • @soupagain:实际上,没有.当您单击.html**文件**时,打开它的浏览器是已注册.html扩展名的浏览器.当您打开http://**链接**(例如,通过在"开始 - >运行"框中键入)时,打开的浏览器是已注册HTTP协议的浏览器(尽管它通常是相同的浏览器)两种情况).你是对的,开始菜单中显示的内容与此无关. (2认同)

小智 8

在Windows 7 x64中测试:这是一个两步过程.用户的默认浏览器位于密钥中:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid
Run Code Online (Sandbox Code Playgroud)

常用浏览器密钥名称:

  • IE:IE.AssocFile.HTM
  • FireFox:FirefoxHTML
  • Chrome:ChromeHTML
  • Opera:Opera.HTML

<KEY NAME>以下值替换为以下值之一以查找可执行文件:

HKCR\<KEY NAME>\shell\open\command
Run Code Online (Sandbox Code Playgroud)

Autohotkey脚本显示默认浏览器路径和可执行文件:

MsgBox % "Default browser: " Browser()

Browser()
{
    ; Find the Registry key name for the default browser
    RegRead, BrowserKeyName, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice, Progid

    ; Find the executable command associated with the above Registry key
    RegRead, BrowserFullCommand, HKEY_CLASSES_ROOT, %BrowserKeyName%\shell\open\command

    ; The above RegRead will return the path and executable name of the brower contained within qoutes and optional parameters
    ; We only want the text contained inside the first set of quotes which is the path and executable
    ; Find the ending quote position (we know the beginning quote is in position 0 so start searching at position 1)
    StringGetPos, pos, BrowserFullCommand, ",,1

    ; Decrement by one for the StringMid to work correctly
    pos := --pos

    ; Extract and return the path and executable of the browser
    StringMid, BrowserPathandEXE, BrowserFullCommand, 2, %pos%
    Return BrowserPathandEXE
} 
Run Code Online (Sandbox Code Playgroud)