Lisp Knowledgebase

Title: How to start a Windows executable such as Netscape

ID: 16019


Product: LispWorks for Windows
Version: 4.1, 4.2
OS: All Windows platforms

Description:
LispWorks 4.2
Use SYS:CALL-SYSTEM. To start a process and read from it, use SYS:OPEN-PIPE.

If you want use the Windows Shell API, then follow the notes in 1) below.
Note that the HWEB::SHELL-OPEN-COMMAND functionality is in a loadable module in the 4.2 release: do
(require "hqn-web")
to load it.

LispWorks 4.1
In this release, the functionality is provided under UNIX via SYS:CALL-SYSTEM, but nothing
"officially" for the PC product in version4.1

However, there are a few things available under the Windows implementation:

(1) To start the default browser, you can call ShellExecute, with
operation "open", and the path to the file e.g. by
(HWEB::SHELL-OPEN-COMMAND <path>)

If the default browser is Internet Explorer, this suffices, because
successive calls use the same running instance of the browser, by
implicit DDE in the Windows Shell API.

If the default browser is Netscape, each call to ShellExecute fires up
a new instance of Netscape which is not very nice. The way around that
is to use Netscape's DDE interface, only calling ShellExecute if that
fails (i.e. Netscape is not yet running). LispWorks functions you can
call are WW:NETSCAPE-OPEN-URL and WW:NETSCAPE-ACTIVATE.

(2) To start another application, in general you can call the
unsupported internal functions WIN32::OPEN-PIPE (see below) and
WIN32::CALL-SYSTEM
. WIN32::CALL-SYSTEM takes the same arguments but
doesn't return until the command has finished.

---

Package: WIN32

Syntax: OPEN-PIPE &KEY APPLICATION-NAME COMMAND-LINE CURRENT-DIRECTORY

Invokes CreateProcess and returns a stream which you can read from.
See the MS documentation on CreateProcess for interpretation of the
arguments. Beware that the CL input functions may hang if there's no
input on the stream so check for this using LISTEN eg.


CL-USER 90 > (defvar *pipe*)
*PIPE*


CL-USER 91 > (setf *pipe* (win32::open-pipe :command-line "net view"))
#S(IO::TWO-WAY-PIPE-STREAM IO::UNTYID-CHAR NIL IO::INPUT #<FILE-STREAM
NIL> IO::OUTPUT #<FILE-STREAM NIL> IO::HPROCESS 372)


CL-USER 92 > (loop (loop while (and (listen *pipe*) (print (read-line
*pipe*))))
                  (sleep 1)
                  (unless (listen *pipe*) (return)))


"Server Name            Remark"
""
"----------------------------------------------------------------------"


[... lots of machine names elided ... ]

"The command completed successfully."
""
NIL


CL-USER 93 >


See Also:
Workaround:
Patch:

Hardware:N/A
Summary:
Bug#:
Patch Enhancement#:
Reported:

Company     Contact     Privacy Policy     Terms of Use