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

时间:2010-02-01 15:52:51

标签: windows browser vb6

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

我正在使用VB6,但可能无法适应其他代码。

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

例如,HKEY_LOCAL_MACHINE \ Software \ Clients \ StartMenuInternet \键在我的电脑上列出了Internet Explorer和Firefox。

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

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

3 个答案:

答案 0 :(得分:15)

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

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

答案 1 :(得分:5)

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

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid

常用浏览器密钥名称:

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

使用上面的值之一替换下面的<KEY NAME>以查找可执行文件:

HKCR\<KEY NAME>\shell\open\command

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
} 

答案 2 :(得分:2)

默认浏览器通常基于每个用户设置。你试过HKEY_CURRENT_USER吗?正确显示在我的下面。