Page 1 of 1

Help with Win32Process

PostPosted: 28. Jun 2009, 00:34
by danielk
Can anyone provide a simple example of using the Win32Process class? For example, let's say I have a simple C executable, all it does is sends the string 'Hello' to stdout.

Daniel Klein

Re: Help with Win32Process

PostPosted: 30. Jun 2009, 18:27
by jan_vrany
Hi,

I don't know how to use Win32Process class directly but I've never need to use it.It's better to use
OperatingSystem methods under protocol 'executing OS commands - public'. For example:
Code: Select all
OperatingSystem
        executeCommand:'dir'
        outputTo: Transcript


Look at AbstractOperatingSystem, protocol 'executing OS commands - public'. There are bunch of methods
with one or two examples at the bottom...

Re: Help with Win32Process

PostPosted: 1. Dec 2009, 12:38
by cgittinger
notice that you can execute any command with input, output and stderr redirected onto a smalltalk stream:

Unix:

Code: Select all
|myStream|

myStream := WriteStream on:(String new).
OperatingSystem executeCommand:'ls -l' outputTo:myStream.
^ myStream contents

Windows:

Code: Select all
|myStream|

myStream := WriteStream on:(String new).
OperatingSystem executeCommand:'dir' outputTo:myStream.
^ myStream contents

Re: Help with Win32Process

PostPosted: 1. Dec 2009, 12:40
by cgittinger
also notice, that Win32Process is (as the name implies) Windows OS-specific. Use OperatingSystem for portability (even if you use shell-commands, these might run unchanged on Windows with a cygwin- or similar shell installed).

Claus