Questions about smalltalk/x and its class library

Help with Win32Process

Postby danielk » 28. Jun 2009, 00:34

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
danielk
 
Posts: 1
Joined: 24. Jun 2009, 04:40

Re: Help with Win32Process

Postby jan_vrany » 30. Jun 2009, 18:27

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...
jan_vrany
 
Posts: 28
Joined: 10. Dec 2008, 12:37

Re: Help with Win32Process

Postby cgittinger » 1. Dec 2009, 12:38

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
cgittinger
 
Posts: 61
Joined: 12. Nov 2008, 17:05

Re: Help with Win32Process

Postby cgittinger » 1. Dec 2009, 12:40

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
cgittinger
 
Posts: 61
Joined: 12. Nov 2008, 17:05


Return to Programming Help

Users browsing this forum: No registered users and 0 guests

Design by GB