views:

63

answers:

2

Does anybody knows a way how to get the default browser without doing a lookup on the registry using the .NET framework?

A: 

Why do you want to avoid registry lookup?

You can use AssocQueryString Function but internally it uses registry to get the default browser. Here is an example in C#: Getting the Default Browser Path.

Giorgi
Good question. Until now the project was able avoiding any registry lookup and it would be nice keeping this strategy. Beside this, if there is a .NET call, this way should be prefered from my point of view.Thanks for your input, i'll test it.
Patrick
@Giorgi: If there is a specialized API call that avoids needing to have knowledge of the registry, it makes sense to use it? Microsoft can change the internal implementation as needed.
Thorarin
yes this is also my point of view.
Patrick
+1  A: 

Well, you could just run System.Diagnostics.Process.Start(url); which will start the default browser and you could then check what executable the process ran, but I'm not sure if it makes much difference since Windows will be using the registry to decide which is the default.

ho1
I also tried this, and had to wait about 20 seconds until the browser appears. So this approach isn't acceptable.
Patrick
May be this works fine as long IE is the only browser on the system.
Patrick
@Patrick: Well looking at your comment to Giorgi it seems like the reason to stay away from the registry is to keep the code neat rather than any technical reason, so I'd suggest that it would actually be best to just read it from the registry directly, anything else you do will just read it from there anyway (since that's the only place it's stored as far as I know), you'll just have more layers between your code and the registry.
ho1