FutureBasic Logo

<<    Index    >> FutureBasic 5

GetProcessInfo( 32-bit Carbon builds only )   function



Syntax:
GetProcessInfo index%, processName$ [,PSN]

Description:
A "Process" is something that is currently running on your computer; this includes, but is not limited to things like applications, control strip extensions, and background applications.
The index parameter in this call indicates which process is to be queried. An index value of -1 means that the front process is used. This is generally the running FutureBasic application that you created.
Index values of zero or higher represent running processes. You may climb this list, examining processes as you go, until the process name comes back as a null string. At that point, you have exhausted the system's list of processes and you can quit searching.
The process serial number is an 8 byte value (2 long integers) that holds a unique value which cannot be used by any other concurrent process. You create a process serial number as follows:
dim psn as ProcessSerialNumber
The following example shows how to display a list of running processes.
dim indx&
dim ProcessName$
dim psn as ProcessSerialNumber

GetProcessInfo -1,ProcessName$
print "My name is:""";ProcessName$;"""
print " indx","0x-------PSN------ ","Process Name"
indx& = 0
do
  GetProcessInfo indx&,ProcessName$,psn
  long if ProcessName$[0]
    print indx&,"0x";hex$(psn.highLongOfPSN);
    print hex$(psn.lowLongOfPSN),ProcessName$
  end if
  inc(indx&)
until len(ProcessName$) == 0


For 64-bit builds:
Util_Workspace.incl provides equivalent functionality to GetProcessInfo. See functions fn WS_IsAppRunning and fn WS_CopyRunningApps

See Also:
SendAppleEvent