From: "Josh" no spam please. on
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

From: Family Tree Mike on
On 2/21/2010 3:55 PM, Josh wrote:
> 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();

--
Mike
From: "Josh" no spam please. on


"Family Tree Mike" <FamilyTreeMike(a)ThisOldHouse.com> wrote in message
news:emYCrmzsKHA.5356(a)TK2MSFTNGP02.phx.gbl...
> On 2/21/2010 3:55 PM, Josh wrote:
>> 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();

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.

From: Random on
On Feb 21, 12:55 pm, "Josh" <no spam please. Thanks> wrote:
> 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://
..
From: Jeff Johnson on
"Josh" <no spam please. Thanks> wrote in message
news:%23j4TchzsKHA.5356(a)TK2MSFTNGP02.phx.gbl...

> 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[S] protocol.