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).
小智 8
在Windows 7 x64中测试:这是一个两步过程.用户的默认浏览器位于密钥中:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.html\UserChoice\Progid
常用浏览器密钥名称:
将<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
}