From: eliza on 7 May 2010 04:58 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 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 does not 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 would 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 Previous Posts In This Thread: On Sunday, February 21, 2010 3:55 PM Josh wrote: Get default browser NOT by the registry Hi group, I have 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 does not 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 would 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 On Sunday, February 21, 2010 4:06 PM Family Tree Mike wrote: 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 On Sunday, February 21, 2010 4:09 PM Josh wrote: 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 find out what program *would* be launched, not actually launch it. I am looking for info on the default http handler, default https handler, and default htmlfile handler, but I am not looking to launch anything. On Sunday, February 21, 2010 5:17 PM Random wrote: toThere is not one. to There is not one. ShellExecute uses HKCR\http\shell\open to determine which browser to launch when it is passed a string that starts with http:// .. On Monday, February 22, 2010 1:44 PM Jeff Johnson wrote: "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[S] protocol. On Monday, February 22, 2010 2:20 PM Josh Agarrio wrote: 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/tutorials/aspnet/5261083e-6e03-4b25-8728-fc3cf6855293/free-online-courses-avail.aspx
|
Pages: 1 Prev: Microsoft Responds to the Evolution of Online Communities Next: usage of this() |