Get default browser NOT by the registry

J

Josh

Hi group,

I've been searching for a while for the "right" way to get the default
program for specific protocols and file types, namely http and https
protocols as well as the various htmlfile types. Everything that I come
across has to do with querying the HKCR section of the registry, but this
doesn't seem to be the right way of doing it. When I launch a URL on my
computer, Windows performs some action to determine what program should
handle that call. I assumed that there'd be an API call in Win32 or
elsewhere that I could use to determine this same information, as opposed to
going to the registry. The location of this information varies between
OSes, so instead of trying to go around the Windows API layer to get the
info, I'd like to write my code to basically say, "Hey, Windows. YOU know
what to launch when an http request is invoked, same with https (which
~could~ be different), same with any htmlfile-associated extension. Would
you please let me know what executable you'd call for each of these?"

So, does anyone know of an API call to get this info as opposed to going to
the registry for it?

Thank you
 
F

Family Tree Mike

Hi group,

I've been searching for a while for the "right" way to get the default
program for specific protocols and file types, namely http and https
protocols as well as the various htmlfile types. Everything that I come
across has to do with querying the HKCR section of the registry, but
this doesn't seem to be the right way of doing it. When I launch a URL
on my computer, Windows performs some action to determine what program
should handle that call. I assumed that there'd be an API call in Win32
or elsewhere that I could use to determine this same information, as
opposed to going to the registry. The location of this information
varies between OSes, so instead of trying to go around the Windows API
layer to get the info, I'd like to write my code to basically say, "Hey,
Windows. YOU know what to launch when an http request is invoked, same
with https (which ~could~ be different), same with any
htmlfile-associated extension. Would you please let me know what
executable you'd call for each of these?"

So, does anyone know of an API call to get this info as opposed to going
to the registry for it?

Thank you

If I understand what you are after, I've always just done it this way:

Process p = new Process();
p.StartInfo.FileName = "http://www.microsoft.com";
p.StartInfo.Verb = "open";
p.Start();
 
J

Josh

Family Tree Mike said:
If I understand what you are after, I've always just done it this way:

Process p = new Process();
p.StartInfo.FileName = "http://www.microsoft.com";
p.StartInfo.Verb = "open";
p.Start();

Thanks Mike, but no, I'm not looking to launch a URL. I'm looking to find
out what program *would* be launched, not actually launch it. I'm looking
for info on the default http handler, default https handler, and default
htmlfile handler, but I'm not looking to launch anything.
 
R

Random

So, does anyone know of an API call to get this info as opposed to going to
the registry for it?

There isn't one. ShellExecute uses HKCR\http\shell\open to determine
which browser to launch when it's passed a string that starts with http://
..
 
J

Jeff Johnson

I've been searching for a while for the "right" way to get the default
program for specific protocols and file types, namely http and https
protocols as well as the various htmlfile types. Everything that I come
across has to do with querying the HKCR section of the registry, but this
doesn't seem to be the right way of doing it. When I launch a URL on my
computer, Windows performs some action to determine what program should
handle that call. I assumed that there'd be an API call in Win32 or
elsewhere that I could use to determine this same information, as opposed
to going to the registry. The location of this information varies between
OSes, so instead of trying to go around the Windows API layer to get the
info, I'd like to write my code to basically say, "Hey, Windows. YOU know
what to launch when an http request is invoked, same with https (which
~could~ be different), same with any htmlfile-associated extension. Would
you please let me know what executable you'd call for each of these?"

So, does anyone know of an API call to get this info as opposed to going
to the registry for it?

You could TRY using the FindExecutable() API function, but the docs state
that the file name you pass in "should be a document." I don't know it it
will work with a simple URL, like http://www.microsoft.com. You could go the
cheesy way and give it the name of an HTML file and just play the odds that
99.99999999999% of people have the same program associated with .HTM that
they do with the HTTP protocol.
 
J

Josh Agarrio

Jeff Johnson said:
"Josh" <no spam please. Thanks> wrote in message
You could TRY using the FindExecutable() API function, but the docs state
that the file name you pass in "should be a document." I don't know it it
will work with a simple URL, like http://www.microsoft.com. You could go
the cheesy way and give it the name of an HTML file and just play the odds
that 99.99999999999% of people have the same program associated with .HTM
that they do with the HTTP protocol.


Thank you Jeff. It's interesting that there isn't a single point of entry
for determining this info, but at least I know to stop looking. :)

There is a slight chance for this product I'm making that someone would want
to distinguish among http, https, and htmlfile, but I'm not going to get
bogged down by it now. We'll save that for release 2!

Thanks a lot for your input.
 
E

eliza sahoo

Following is the sample code in [VB.NET]

'--Declaration
Public Declare Auto Function FindExecutable Lib "shell32.dll" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Int32

'--
Dim intRetval As Integer = FindExecutable(PDF FILE FULL PATH NAME, "", "")

If intRetval < = 32

MessageBox.Show("The Adobe Reader, which is required to view this file, may not be correctly installed.", "Adobe Reader Not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

End if

http://www.mindfiresolutions.com/FindExecutable-API-569.php



Josh wrote:

Get default browser NOT by the registry
21-Feb-10

Hi group

I have been searching for a while for the "right" way to get the defaul
program for specific protocols and file types, namely http and http
protocols as well as the various htmlfile types. Everything that I com
across has to do with querying the HKCR section of the registry, but thi
does not seem to be the right way of doing it. When I launch a URL on m
computer, Windows performs some action to determine what program shoul
handle that call. I assumed that there'd be an API call in Win32 o
elsewhere that I could use to determine this same information, as opposed t
going to the registry. The location of this information varies betwee
OSes, so instead of trying to go around the Windows API layer to get th
info, I'd like to write my code to basically say, "Hey, Windows. YOU kno
what to launch when an http request is invoked, same with https (whic
~could~ be different), same with any htmlfile-associated extension. Woul
you please let me know what executable you would call for each of these?

So, does anyone know of an API call to get this info as opposed to going t
the registry for it

Thank you

Previous Posts In This Thread:

Get default browser NOT by the registry
Hi group

I have been searching for a while for the "right" way to get the defaul
program for specific protocols and file types, namely http and http
protocols as well as the various htmlfile types. Everything that I com
across has to do with querying the HKCR section of the registry, but thi
does not seem to be the right way of doing it. When I launch a URL on m
computer, Windows performs some action to determine what program shoul
handle that call. I assumed that there'd be an API call in Win32 o
elsewhere that I could use to determine this same information, as opposed t
going to the registry. The location of this information varies betwee
OSes, so instead of trying to go around the Windows API layer to get th
info, I'd like to write my code to basically say, "Hey, Windows. YOU kno
what to launch when an http request is invoked, same with https (whic
~could~ be different), same with any htmlfile-associated extension. Woul
you please let me know what executable you would call for each of these?

So, does anyone know of an API call to get this info as opposed to going t
the registry for it

Thank you

On 2/21/2010 3:55 PM, Josh wrote:If I understand what you are after, I have
On 2/21/2010 3:55 PM, Josh wrote

If I understand what you are after, I have always just done it this way

Process p = new Process()
p.StartInfo.FileName = "http://www.microsoft.com"
p.StartInfo.Verb = "open"
p.Start()

-
Mike

Thanks Mike, but no, I am not looking to launch a URL.
Thanks Mike, but no, I am not looking to launch a URL. I am looking to fin
out what program *would* be launched, not actually launch it. I am lookin
for info on the default http handler, default https handler, and defaul
htmlfile handler, but I am not looking to launch anything.

toThere is not one.
t

There is not one. ShellExecute uses HKCR\http\shell\open to determin
which browser to launch when it is passed a string that starts with http:/
..

"Josh" <no spam please.
"Josh" <no spam please. Thanks> wrote in message


You could TRY using the FindExecutable() API function, but the docs state
that the file name you pass in "should be a document." I do not know it it
will work with a simple URL, like http://www.microsoft.com. You could go the
cheesy way and give it the name of an HTML file and just play the odds that
99.99999999999% of people have the same program associated with .HTM that
they do with the HTTP protocol.

Thank you Jeff.
Thank you Jeff. it is interesting that there is not a single point of entry
for determining this info, but at least I know to stop looking. :)

There is a slight chance for this product I am making that someone would want
to distinguish among http, https, and htmlfile, but I am not going to get
bogged down by it now. We'll save that for release 2!

Thanks a lot for your input.


Submitted via EggHeadCafe - Software Developer Portal of Choice
Free Online Courses Available for Eggheadcafe.com Users
http://www.eggheadcafe.com/tutorial...8-fc3cf6855293/free-online-courses-avail.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top