'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 1 February 2006 at 7:59:02 pm'! "Change Set: FFIWin Date: 31 January 2006 Author: Boris Gaertner example for process enumeriation: | interface array uint cb x err handleArray i j upperIdx oc processHandle | interface := Win32Window new. array := ByteArray new: 8000. uint := ByteArray new: 4. cb := 8000. x := interface apiEnumProcesses: array size: cb bytesReturned: uint . x ifFalse: [ err := interface getLastError.]. handleArray := OrderedCollection new: 2000. upperIdx := uint unsignedLongAt: 1. j := i := 1. [j < upperIdx] whileTrue: [ handleArray add: (array unsignedLongAt: j). i := i + 1. j := j + 4. ]. oc := OrderedCollection new. handleArray do: [:idx | processHandle := interface getProcessHandleWithAccessRights: 16r400 inherit: true processId: idx. processHandle notNil ifTrue: [ oc add: (Array with: idx with: (interface apiGetGuiResources: processHandle type: 0) with: (interface apiGetGuiResources: processHandle type: 1) ). interface closeHandle: processHandle.] ]. oc. "! ExternalStructure subclass: #Win32ProcessMemoryCounters instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'FFI-Examples-Win32'! !Win32ProcessMemoryCounters commentStamp: 'BG 1/31/2006 18:36' prior: 0! Evaluate this to obtain memory usage information : (for additional information, search the web for these keywords: PROCESS_MEMORY_COUNTERS GetProcessMemoryInfo ) | interface process memRec | interface := Win32Window new. process := interface apiGetCurrentProcess. memRec := Win32ProcessMemoryCounters new. interface apiGetProcessMemoryInfoFor: process into: memRec descriptorSize: memRec class byteSize. memRec inspect! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PageFaultCount "This method was automatically generated" ^handle signedLongAt: 5! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PageFaultCount: anObject "This method was automatically generated" handle signedLongAt: 5 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PagefileUsage "This method was automatically generated" ^handle unsignedLongAt: 33! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PagefileUsage: anObject "This method was automatically generated" handle unsignedLongAt: 33 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PeakPagefileUsage "This method was automatically generated" ^handle unsignedLongAt: 37! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PeakPagefileUsage: anObject "This method was automatically generated" handle unsignedLongAt: 37 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PeakWorkingSetSize "This method was automatically generated" ^handle unsignedLongAt: 9! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! PeakWorkingSetSize: anObject "This method was automatically generated" handle unsignedLongAt: 9 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaNonPagedPoolUsage "This method was automatically generated" ^handle unsignedLongAt: 29! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaNonPagedPoolUsage: anObject "This method was automatically generated" handle unsignedLongAt: 29 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPagedPoolUsage "This method was automatically generated" ^handle unsignedLongAt: 21! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPagedPoolUsage: anObject "This method was automatically generated" handle unsignedLongAt: 21 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPeakNonPagedPoolUsage "This method was automatically generated" ^handle unsignedLongAt: 25! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPeakNonPagedPoolUsage: anObject "This method was automatically generated" handle unsignedLongAt: 25 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPeakPagedPoolUsage "This method was automatically generated" ^handle unsignedLongAt: 17! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! QuotaPeakPagedPoolUsage: anObject "This method was automatically generated" handle unsignedLongAt: 17 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! WorkingSetSize "This method was automatically generated" ^handle unsignedLongAt: 13! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! WorkingSetSize: anObject "This method was automatically generated" handle unsignedLongAt: 13 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! cb "This method was automatically generated" ^handle signedLongAt: 1! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! cb: anObject "This method was automatically generated" handle signedLongAt: 1 put: anObject! ! !Win32ProcessMemoryCounters methodsFor: 'accessing' stamp: 'BG 1/31/2006 18:23'! longPrintString ^super longPrintString! ! !Win32ProcessMemoryCounters class methodsFor: 'accessing' stamp: 'BG 2/1/2006 17:59'! fields "Win32ProcessMemoryCounters defineFields" ^#( (cb 'long') (PageFaultCount 'long') (PeakWorkingSetSize 'ulong') ( WorkingSetSize 'ulong') ( QuotaPeakPagedPoolUsage 'ulong') ( QuotaPagedPoolUsage 'ulong') ( QuotaPeakNonPagedPoolUsage 'ulong') ( QuotaNonPagedPoolUsage 'ulong') ( PagefileUsage 'ulong') ( PeakPagefileUsage 'ulong') )! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 2/1/2006 19:24'! apiEnumProcesses: pProcessIds size: cp bytesReturned: pBytesReturned ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 1/31/2006 16:53'! apiGetCurrentProcess ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 1/31/2006 16:48'! apiGetCurrentProcessId ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 2/1/2006 19:56'! apiGetGuiResources: h type: int " int = 0: GDI objects, int = 1: User objects " ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 1/31/2006 17:34'! apiGetProcessMemoryInfoFor: processHnd into: ppsMemCounters descriptorSize: size ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 2/1/2006 19:44'! closeHandle: aHandle ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 2/1/2006 18:46'! getLastError ^self externalCallFailed! ! !Win32Window methodsFor: 'api calls' stamp: 'BG 2/1/2006 19:58'! getProcessHandleWithAccessRights: accessRights inherit: inherit processId: id " accessRights = 16r400: ProcessQueryInformation 16r0x1F0FFF ProcessAllAccess " ^nil! ! !Win32ProcessMemoryCounters class reorganize! ('accessing' fields) ! !Win32ProcessMemoryCounters reorganize! ('accessing' PageFaultCount PageFaultCount: PagefileUsage PagefileUsage: PeakPagefileUsage PeakPagefileUsage: PeakWorkingSetSize PeakWorkingSetSize: QuotaNonPagedPoolUsage QuotaNonPagedPoolUsage: QuotaPagedPoolUsage QuotaPagedPoolUsage: QuotaPeakNonPagedPoolUsage QuotaPeakNonPagedPoolUsage: QuotaPeakPagedPoolUsage QuotaPeakPagedPoolUsage: WorkingSetSize WorkingSetSize: cb cb: longPrintString) !