How to determine the Windows default browser (at the top of the start menu)

后端 未结 3 716
南笙
南笙 2020-12-01 14:58

How can I determine the Windows default browser (at the top of the start menu)?

I am using VB6 but can probably adapt other code no problem.

There are simila

相关标签:
3条回答
  • 2020-12-01 15:32

    Default browsers are usually set on a per user basis. Have you tried HKEY_CURRENT_USER instead? Shows up on mine under there correctly.

    0 讨论(0)
  • 2020-12-01 15:36

    Tested in Windows 7 x64: This is a two step process. The user's default browser is in key:

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

    Common browser Key Name:

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

    Replace <KEY NAME> below with one of the values above to find the executable:

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

    Autohotkey script to display the default browser path and executable:

    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
    } 
    
    0 讨论(0)
  • 2020-12-01 15:49

    HKEY_CURRENT_USER\Software\Classes\http\shell\open\command\(Default) is the current user's handler for the HTTP protocol (which means "default browser"; NOTE: this is NOT the same thing as the .html default handler!).

    However, it is possible to have a different browser at the top of Start Menu without changing the default. FYI, the browser executable name in Start menu is stored in HKEY_CURRENT_USER\Software\Clients\StartMenuInternet\(Default).

    0 讨论(0)
提交回复
热议问题