Board index » cppbuilder » Launch another exe process

Launch another exe process

Hello,

How do I launch another program from Builder's application. Say, I need
to call Netscape Communicator with a html file as a reaction on user's
input.
stdlib's system() does not launch anything which requires a graphical
window output (but fine if you want to run "dir").

Thanks. Sergey.

 

Re:Launch another exe process


Quote
"Sergey Polyakov" <se...@creol.ucf.edu> wrote in message

news:3A8B0CF9.4A53CD7B@creol.ucf.edu...

Quote
> How do I launch another program from Builder's application.

Have a look in the Win32 API reference at WinExec(), ShellExecute(), or
CreateProcess()

Quote
> Say, I need to call Netscape Communicator with a html file as a
> reaction on user's input.

ShellExecute() is usually used for that.  It loads the html file in the
system's default browser, which may or may not be Netscape.  If you must
load it in Netscape, you'll have to read the Registry first to get
Netscape's path, then pass the path to the html file as a command-line
parameter.

Gambit

Re:Launch another exe process


You really should not assume that the user has netscape on his computer.
You could check the registry keys to find out what program is registered
as the default html browser and run that program passing the link as an
argument.

As to your problems launching a process, that can be painful. Windows
allowing spaces in lfn filenames is one of the stupidest things Redmond
ever did. You may have better luck using DOS style filenames PROGRA~1
instead of Program Files. If you want to use the lfn style wrapping it in
double quotes " works. I have noticed wierd problem with command
lines where the first token is parsed differently by the shells parser than
all
subsequent tokens. Also when you use those API fuctions you are bypassing
the command shell and interacting directly with the OS. So anything that the
cmd
shell normally does like wildcard expansion, will not take place.

Quote
Remy Lebeau wrote:
> "Sergey Polyakov" <se...@creol.ucf.edu> wrote in message
> news:3A8B0CF9.4A53CD7B@creol.ucf.edu...

> > How do I launch another program from Builder's application.

> Have a look in the Win32 API reference at WinExec(), ShellExecute(), or
> CreateProcess()

> > Say, I need to call Netscape Communicator with a html file as a
> > reaction on user's input.

> ShellExecute() is usually used for that.  It loads the html file in the
> system's default browser, which may or may not be Netscape.  If you must
> load it in Netscape, you'll have to read the Registry first to get
> Netscape's path, then pass the path to the html file as a command-line
> parameter.

> Gambit

Re:Launch another exe process


Quote
"Frank Gleeson" <fglee...@netzero.net> wrote in message

news:3A8EF626.6AF4403@netzero.net...

Quote
> You really should not assume that the user has netscape on his computer.
> You could check the registry keys to find out what program is registered
> as the default html browser and run that program passing the link as an
> argument.

That's what I said before.   And I also said ShellExecute() loads the
default browser without needing to look in the registry first.

Quote
> You may have better luck using DOS style filenames PROGRA~1
> instead of Program Files

Not always, because PROGRA~1 may not always be the valid path.  On my
system, It's PROGRAMF, for example, because I have ~1 disabled

Gambit

Other Threads