"Valdas Bucinskas" valdas.bucinskas@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