Windows process info from Squeak

Boris Gaertner Boris.Gaertner at gmx.net
Tue Jan 31 18:27:13 UTC 2006


"Valdas Bucinskas" <valdas.bucinskas at ipsistemos.lt> wrote:


> Hello
>
> Is there a way to get information about Windows XP processes from Squeak?
> Smth like how much RAM is the process using? What is PID of the process?
> And so on.
> Any hints or workaraunds are very much welcome.

The FFI interface is the framework that you can use to
program what you need.
(see also: http://minnow.cc.gatech.edu/squeak/1414
and http://minnow.cc.gatech.edu/squeak/2422)

To get the process id you have to do this:

1. In Win32Window, add this instance method:

apiGetCurrentProcessId
    <apicall: long 'GetCurrentProcessId' (void) module: 'kernel32.dll'>
    ^self externalCallFailed


2. Then try in a workspace:

Win32Window new apiGetCurrentProcessId

Getting a handle to the current process is not much more
difficult:

1. you have to add these instance methods:


apiGetCurrentProcess
    <apicall: Win32Handle 'GetCurrentProcess' (void) module: 'kernel32.dll'>
    ^self externalCallFailed

apiGetGuiResources: h type: int
    <apicall: long 'GetGuiResources' (Win32Handle long) module:
'user32.dll'>
    ^self externalCallFailed


2. Then you can try:

  | interface |  " gdi resources "
  interface := Win32Window new.
  interface apiGetGuiResources: interface apiGetCurrentProcess type: 0.

 | interface |  " user resources "
  interface := Win32Window new.
  interface apiGetGuiResources: interface apiGetCurrentProcess type: 1.


The attached change set contains these methods and a
class definition that is needed to obtain memory usage information.

Please have a look at the class comment for
Win32ProcessMemoryCounters to find out how you can
obtain memory information.

It is perhaps necessary to explicitely release (with free)
some of the Win32 structures, but I am not sure about
that. Comments are highly welcome.

Hope that helps a bit.
Boris








-------------- next part --------------
A non-text attachment was scrubbed...
Name: FFIWin.1.cs
Type: application/octet-stream
Size: 4309 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060131/78357b66/FFIWin.1.obj


More information about the Squeak-dev mailing list