Launch default web browser with a parameter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Launch default web browser with a parameter

Louis LaBrunda
Hi All,

I would like to launch the users default web browser with a parameter from some of my VA Smalltalk GUI (windows) programs. The idea is to use the web browser to view HTML based help files. The parm is like "?www-xxx-yyy-zzz" which some JavaScript code (run onload) will use to find and display a section of the help file. I have been playing with a few methods of doing this.

1) OSHwnd>shellExecute:lpFile:lpParameters:lpDirectory:nShowCmd:. This works if the filename includes the path and the parms and diectory are nil. This is very fast to open the browser. The trouble is I need to pass the parm. I thought of passing the parm through the clipboard but some browsers won't read the clipboard from JavaScript.

I can dynamically create a small .htm or .html or .url file that contains the URL/parm and run it with this method. It works and starts the browser and finds the correct section very fast. I'm just not comfortable with windows being ably to consistantly find the file. Lately I have seen windows write files where it wants to and not where you tell it to, for what I think are security reasons and then the file isn't where you think it is.

If I could create the contents (a string) of a .url file and run it directly from memory (without writing the file), that would be ideal.

2) I can get the name of the default browser from the windows registry and run it with a program starter. In this case I pass the URL/parms through the program starter and everything works (the JavaScript finds the correct section). The problem with this is that it is very, very slow. I have no idea why. It is also somewhat dicey as to whether I find the correct default browser entry in the registry as there seems to be more than one. Also, when you change your default browser this entry may or may not change depending upon how you change it and which browser you change to.

Any ideas are greatly appreciated.

Lou

PS  This is the second time I'm making this post.  The first time it seemed like it took and then it disappeared.  So, if it shows up twice, please forgive the double post.
 

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Launch default web browser with a parameter

Louis LaBrunda
Hi,

Me again. After writing that long post and thinking I liked the URL/file/string_in_memory approach, I decided to search all of the system for URL to see what I could find. A class method of AbtHTMLHelpAccessor #helpFromURL: seems to do what I want and it is fast (at least not horribly slow).

It looks in the registry for the default browser at HKEY_CLASSES_ROOT\.htm. The (default) entry looks like Opera.HTML, ChromeHTML, SafariHTML, FirefoxHTML and htmlfile (opens IE).  Changing this entry via RegEdit works fine.  Calling  AbtHTMLHelpAccessor helpFromURL: myUrlToHelpFileWithPathAndParms, does the trick.

One odd thing did happen when testing.  I change the registry entry to "htmlfile" to test IE in the VA dev env and Trend Micro (virus checker) killed abt.exe because it thought it was doing something suspicious, until I told it that abt.exe was safe.  This only happened with the test for IE.  I'm not sure why Trend Micro thought it was suspicious, could be it was looking in the registry too much.  I doubt abt.exe was trying to change anything it shouldn't.  I will have to see if Trend Micro or others have a problem after I package and run on other machines.

Lou

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Launch default web browser with a parameter

Michael LaMantia
In reply to this post by Louis LaBrunda
I use a program starter using rundll32 with the parameter url.dll,FileProtocolHandler <url>
Obviously a windows only situation, but I've been using it for quite a few years now without incident.  Why I chose this over any other method is lost to time.

Mike


On Thursday, May 30, 2013 5:01:55 PM UTC-4, Louis LaBrunda wrote:
Hi All,

I would like to launch the users default web browser with a parameter from some of my VA Smalltalk GUI (windows) programs. The idea is to use the web browser to view HTML based help files. The parm is like "?www-xxx-yyy-zzz" which some JavaScript code (run onload) will use to find and display a section of the help file. I have been playing with a few methods of doing this.

1) OSHwnd>shellExecute:lpFile:lpParameters:lpDirectory:nShowCmd:. This works if the filename includes the path and the parms and diectory are nil. This is very fast to open the browser. The trouble is I need to pass the parm. I thought of passing the parm through the clipboard but some browsers won't read the clipboard from JavaScript.

I can dynamically create a small .htm or .html or .url file that contains the URL/parm and run it with this method. It works and starts the browser and finds the correct section very fast. I'm just not comfortable with windows being ably to consistantly find the file. Lately I have seen windows write files where it wants to and not where you tell it to, for what I think are security reasons and then the file isn't where you think it is.

If I could create the contents (a string) of a .url file and run it directly from memory (without writing the file), that would be ideal.

2) I can get the name of the default browser from the windows registry and run it with a program starter. In this case I pass the URL/parms through the program starter and everything works (the JavaScript finds the correct section). The problem with this is that it is very, very slow. I have no idea why. It is also somewhat dicey as to whether I find the correct default browser entry in the registry as there seems to be more than one. Also, when you change your default browser this entry may or may not change depending upon how you change it and which browser you change to.

Any ideas are greatly appreciated.

Lou

PS  This is the second time I'm making this post.  The first time it seemed like it took and then it disappeared.  So, if it shows up twice, please forgive the double post.
 

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.