1. Executing another program
- Posted by Michael Wales <evicerator52 at hotmail.com> May 24, 2005
- 404 views
I am trying to execute the user's default browser to launch a website after the click of a button. I have looked at system() and system_exec() but neither are helping me very much. I've even tried launching iexplore with and without the full-path to the executable with no luck. Can anyone give me some ideas on where to go with this? Thanks!
2. Re: Executing another program
- Posted by Greg Haberek <ghaberek at gmail.com> May 24, 2005
- 396 views
> I am trying to execute the user's default browser to launch a website aft= er the click of a button. I have looked at system() and system_exec() but n= either are helping me very much. I've even tried launching iexplore with an= d without the full-path to the executable with no luck. > > Can anyone give me some ideas on where to go with this? Thanks! If you just want to launch a web address, you don't need to worry about launching the browser itself, Windows will handle it via file associations. You just need to 'launch' the web address. Try either of these examples: -- this causes a command window to flash on the screen: system( "start http://www.google.com/", 2 ) -- this is for Win32lib only: shellExecute( "open", "http://www.google.com/", SW_SHOWNORMAL ) ~Greg
3. Re: Executing another program
- Posted by Derek Parnell <ddparnell at bigpond.com> May 24, 2005
- 419 views
Michael Wales wrote: > > > I am trying to execute the user's default browser to launch a website after > the click > of a button. I have looked at system() and system_exec() but neither are > helping me > very much. I've even tried launching iexplore with and without the full-path > to the > executable with no luck. > > Can anyone give me some ideas on where to go with this? Thanks! As you seem to be running on a Windows environment, here is a function that can do what you want ...
--------- SHELLEXECUTE ----------- include dll.e include machine.e constant shell32 = open_dll("shell32.dll"), -- shell extentions ShellExecute = define_c_func( shell32, "ShellExecuteA", {C_LONG, C_LONG, C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG ) -- The 'pAction' parameter is usually "open" but it can be any defined -- file action. -- The 'pFile' parameter is the file you want to perform the action on. -- The 'pArgs' parameter is any optional parameter string to send to the -- application that performs the action. Usually this is an empty string. global function ShellOpen( sequence pAction, sequence pFile, sequence pArgs) atom lResultCode atom lAddr_File atom lAddr_Verb atom lAddr_Args lAddr_File = allocate_string(pFile) if length(pAction) = 0 then lAddr_Verb = allocate_string("open") else lAddr_Verb = allocate_string(pAction) end if if length(pArgs) = 0 then lAddr_Args = 0 else lAddr_Args = allocate_string(pArgs) end if lResultCode = c_func(ShellExecute, { 0, lAddr_Verb, lAddr_File, lAddr_Args, 0, 0 }) free(lAddr_File) free(lAddr_Verb) if lAddr_Args != 0 then free(lAddr_Args) end if return lResultCode end function -- Example of usage: -- ? ShellOpen("open", "http://www.rapideuphoria.com/index.html", "") -- ? ShellOpen("print", "Leave Request Form Template.doc", "") ------------------------
-- Derek Parnell Melbourne, Australia irc://irc.sorcery.net:9000/euphoria