views:

320

answers:

3

How can i which is the default browser in my system programatically. the codes must be developed using vc++ Is there any API for this

Where in the registry is the default browser value changed can somebody help me out.

+5  A: 

you can find the default browser in the registry

ie for windows xp is located at

HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\

edit: Actually the same applies for Vista as well.

Konstantinos
Instead of this check out thisHKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer \FileExts\.html\UserChoice this gives the default browser in the machine
subbu
sabbu: this does not necessarily give you the default browser only the default program for opening html files. On my machine ultraedit is the default for htmlfiles.
Qwark
You can get the name of the default browser from "HKCU\SOFTWARE\Clients\StartMenuInternet" and look up the commandline from the HKLM key
fmuecke
A: 

Read the default value of HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet

and optionally check

HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet\XXX\shell\open\command

where XXX is that value picked up from the first key

Stijn Sanders
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer \FileExts\.html\UserChoice
subbu
+3  A: 

You normally do not need to know this. ShellExecute(0,0,"http://stackoverflow.com",0,0,SW_SHOWNORMAL); will do the trick. Windows will spot the http:// and figure out from there that you want to open a URL. The "default" webbrowser is pretty much defined as the webbrowser used by Windows for this task.

It's not just http:// which is supported. ShellExecute can start the default webbrowser with https:// URLs as well. For mailto: URLs, it starts the default mail client.

MSalters