473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 11852
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 to upload pics to a newly created album...
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 myclass.class, is there any way to obtain the location of...
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 company. Everyone that uses it has no problems...
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 location and can display in a browser window. ...
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 firefox, this: MyInputField.postedfile.filename ...
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 or the Scripts subdirectory added to the PATH...
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 point to one app or another. I'm thinkin in...
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 there is no such file. I installed the WAMP package...
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 different roles of users, and each user type will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.