473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Diagnost ics.Process.Sta rt 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 11859
You will need to query this registry path:

HKEY_CLASSES_RO OT\http\shell\o pen\command

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

HKEY_LOCAL_MACH INE\SOFTWARE\Cl asses\http\shel l\open\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.Diagnost ics.Process.Sta rt 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.dl l" Alias "FindExecutable A" (ByVal lpFile As
String, _
ByVal lpDirectory As
String, _
ByVal lpResult As
System.Text.Str ingBuilder) As Int32

Function DefaultBrowserP ath() As String

Dim DummyFile As String
Dim FileDir As String

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

If FindExecutable( DummyFile, FileDir, FilePath) > 32 Then
DefaultBrowserP ath = FilePath.ToStri ng
End If

End Function
Paul ~~~ pc******@amerit ech.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\MOZ ILL~1\FIREFOX.E XE -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\Class es\http\shell\o pen\command"
Dim rk As RegistryKey = Registry.LocalM achine.OpenSubK ey(BrowserRegKe y, False)
MyString += CType(rk.GetVal ue(""), String)
MySplitStrings = MyString.Split( " ")
ExeString = MyStrings(0).To String

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
"Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message
news:42******** *************** ***********@mic rosoft.com...
You will need to query this registry path:

HKEY_CLASSES_RO OT\http\shell\o pen\command

The default key contains the path

Nov 21 '05 #5
In article <11************ *@corp.supernew s.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.Diagnost ics.Process.Sta rt 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.Diagnost ics.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.StartIn fo.FileName = "http://www.microsoft.c om"
browser.StartIn fo.UseShellExec ute = 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*@YOUKNOWTHE DRILLmtogden.co m> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
In article <11************ *@corp.supernew s.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.Diagnost ics.Process.Sta rt 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.Diagnost ics.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.StartIn fo.FileName = "http://www.microsoft.c om"
browser.StartIn fo.UseShellExec ute = 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
14782
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 directory. The problem I am having is opening the FTP session in the new folder. I.E. we have just created images/myAlbum1. Using realpath(.) we get...
4
12359
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 the file myclass.class? Will this work if it's run from a relative path, like: java ../progs/myclass
10
1820
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 hitting the site. The other two applications are running on my personal server which has Windows 2003, IIS 6, and .Net 1.1 Most of my users can use...
7
6370
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. I have my ASP.NET application building links along the lines of file://c:/<path to file>
10
2779
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 returns the filename...and just the filename. Which is what I want. In IE, however, this returns the ENTIRE local user's system path to the file
34
3927
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 environment variable. Every time, I've had to go through and add this by hand, to have something resembling a usable Python installation. No such...
4
1411
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 implement IHttpModule interface, but all the path related propertys of HttpRequest are readonly. Thank you all, Oscar
11
26546
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 and PEAR is in c:\wamp\php\pear I modified php.ini in the c:\wamp\php directory to reflect the actual path, but even stopping and restarting my...
9
2325
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 have access to a completely different set of pages. "Client" pages are in the root folder and "Admin" and "Trainer" pages each have their own...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.