472,334 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

How to get the path to the users default browser?

I need to be able to get the path to the users default browser from within my application.

I am in a situation where I can't easily use System.Diagnostics.Process.Start to start
their browser with the URL I want and I must resort to using "Shell". Of course, shell
wants to know where the browser is and now you can see my dilemma!

Thanks in advance...

Nov 21 '05 #1
6 11739
You will need to query this registry path:

HKEY_CLASSES_ROOT\http\shell\open\command

The default key contains the path
Nov 21 '05 #2
Sorry, but forgot to add this one too:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\http\shell\ope n\command
Nov 21 '05 #3
On Mon, 14 Feb 2005 14:35:48 -0800, "Darious Snell" <nu**@sdlkfweu.org> wrote:

¤ I need to be able to get the path to the users default browser from within my application.
¤
¤ I am in a situation where I can't easily use System.Diagnostics.Process.Start to start
¤ their browser with the URL I want and I must resort to using "Shell". Of course, shell
¤ wants to know where the browser is and now you can see my dilemma!

Give the following a try:

Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As
String, _
ByVal lpDirectory As
String, _
ByVal lpResult As
System.Text.StringBuilder) As Int32

Function DefaultBrowserPath() As String

Dim DummyFile As String
Dim FileDir As String

Dim FilePath As New System.Text.StringBuilder(255)
DummyFile = "e:\My Documents\dummy.htm"

If FindExecutable(DummyFile, FileDir, FilePath) > 32 Then
DefaultBrowserPath = FilePath.ToString
End If

End Function
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #4
Just a quick note...

An example of what can be stored in that key...

C:\PROGRA~1\MOZILL~1\FIREFOX.EXE -url "%1"

There needs to be a little string manipulation before using
this in a "shell" command. I came up with
Dim MyString As String
Dim MySplitStrings() As String
Dim ExeString As String
Dim BrowserRegKey As String = "SOFTWARE\Classes\http\shell\open\command"
Dim rk As RegistryKey = Registry.LocalMachine.OpenSubKey(BrowserRegKey, False)
MyString += CType(rk.GetValue(""), String)
MySplitStrings = MyString.Split(" ")
ExeString = MyStrings(0).ToString

This works with IE and Firefox. Probably most anything else as well.
I am sure there are more elegant ways to do this. But, this works for
the moment.

Thanks
"Crouchie1998" <Cr**********@discussions.microsoft.com> wrote in message
news:42**********************************@microsof t.com...
You will need to query this registry path:

HKEY_CLASSES_ROOT\http\shell\open\command

The default key contains the path

Nov 21 '05 #5
In article <11*************@corp.supernews.com>, Darious Snell wrote:
I need to be able to get the path to the users default browser from within my application.

I am in a situation where I can't easily use System.Diagnostics.Process.Start to start
their browser with the URL I want and I must resort to using "Shell". Of course, shell
wants to know where the browser is and now you can see my dilemma!

Thanks in advance...


I'm a little confused... If you have a URL, you don't even need to know
their default browser using System.Diagnostics.Process. You just set
the filename property of the startinfo structure to the URL and make
sure useshellexectue is true. The system will start the default browser
automatically.

Dim browser As New Process ()
browser.StartInfo.FileName = "http://www.microsoft.com"
browser.StartInfo.UseShellExecute = True
browser.Start ()
--
Tom Shelton [MVP]
Nov 21 '05 #6
The reason I am having difficulty using .start ----

"The requested section is not present in the activation context"

This shows up due to threading model issues with the architecture.
I couldn't resolve the threading issues so I ended up using shell.
I tried using STAThread/MTAThread etc but I couldn't clear the issue.
So, "shell" produces the desired outcome. But, you are right, my first
choice was to go with the method you describe below.
"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
In article <11*************@corp.supernews.com>, Darious Snell wrote:
I need to be able to get the path to the users default browser from within my application.
I am in a situation where I can't easily use System.Diagnostics.Process.Start to start their browser with the URL I want and I must resort to using "Shell". Of course, shell wants to know where the browser is and now you can see my dilemma!

Thanks in advance...


I'm a little confused... If you have a URL, you don't even need to know
their default browser using System.Diagnostics.Process. You just set
the filename property of the startinfo structure to the URL and make
sure useshellexectue is true. The system will start the default browser
automatically.

Dim browser As New Process ()
browser.StartInfo.FileName = "http://www.microsoft.com"
browser.StartInfo.UseShellExecute = True
browser.Start ()
--
Tom Shelton [MVP]

Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: jerrygarciuh | last post by:
Hi all, I have been working on a GUI web photo album for *nix. I had thought it might be workable for users to open a browser based FTP session...
4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting...
7
by: TLM | last post by:
I am trying to build a web application that will contain links to files on a users local computer. I am assuming that the files will be in a known...
10
by: darrel | last post by:
I have an input type="file" field that I am using to accept a file upload. This works, but I'm having problems with the filename property. In...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory...
4
by: Cubaman | last post by:
Hello: Is it possible to dinamically change asp.net application path? I have two versions of my application, and based on the request i want it to...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.