
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
SYSTEM
Know which is the active application
The routine GetFrontProcess returns an 8-byte process ID which identifies the front process (this, basically, is the process that currently has the checkmark in the Application Menu):
DIM frontProcess.8
OSErr = FN GetFrontProcess(@frontProcess)
You can then pass the process ID to FN GetProcessInfo to get a 60-byte block of information about the process:
_myProcessAppSpec = 56 '(constant in FB mis-defined)
DIM processInfo.60, appSpec.70, 255 pname$
processInfo.processInfoLength = 60
processInfo.processName& = @pname$
processInfo.myProcessAppSpec& = @appSpec
OSErr = FN GetProcessInformation(frontProcess, @processInfo)
If you call it as above, the process name will be put into pname$, and the FS spec record for the application file will be put into the appSpec record. See Inside Macintosh for the other kinds of information that are returned in the processInfo block.
Here are listings for FN GetFrontProcess and FN GetProcessInformation:
'----------------------------------------------------------------
LOCAL FN GetFrontProcess(PSNptr&)
'Call as follows:
' OSErr = FN GetFrontProcess(@PSN)
'where PSN is an 8-byte record.
DIM OSErr
` CLR.W -(SP)
` MOVE.L ^PSNptr&,-(SP)
` DC.W $70FF
` DC.W $2F00
` MOVE.W #$0039,-(SP)
` DC.W $A88F
` MOVE.W (SP)+,^OSErr
END FN = OSErr
'----------------------------------------------------------------
'=======================
LOCAL FN GetProcessInformation(@PSNptr&, infoPtr&)
' -------------------------------------------------------------
' Call as follows:
' OSErr = FN GetProcessInformation(PSN, @ProcessInfo)
' PSN is an 8-byte record containing the Process Serial Number;
' ProcessInfo is a 60-byte record.
' -------------------------------------------------------------
` CLR.W -(SP)
` MOVE.L ^PSNptr&,-(SP)
` MOVE.L ^infoPtr&,-(SP)
` MOVE.W #$003A,-(SP)
` DC.W $A88F
` MOVE.W (SP)+,^OSErr
END FN = OSErr
'=======================
|