Windows process info from Squeak

Valdas Bucinskas valdas.bucinskas at ipsistemos.lt
Wed Feb 1 10:55:38 UTC 2006


Hello,
I liked your example a lot. I was playing with it recently, and got some
questions.
1. Is there any documentation on what methods can be called from user32.dll,
kernel32.dll, psapi.dll (the dlls I see in Win32Window instance methods)?
2. I tried to know some information about other process than Squeak.exe, but
couldn't figure out how to do that ?
Comments are as always welcome.

Best regards,
Valdas Bucinskas

-----Original Message-----
From: squeak-dev-bounces at lists.squeakfoundation.org
[mailto:squeak-dev-bounces at lists.squeakfoundation.org]On Behalf Of Boris
Gaertner
Sent: Tuesday, January 31, 2006 8:27 PM
To: The general-purpose Squeak developers list
Subject: Re: Windows process info from Squeak


"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












More information about the Squeak-dev mailing list