[futurebasic] Re: INIT

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 1998 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Mon, 16 Mar 1998 20:37:33 -0600
Hans wrote:
> I am working on an INIT that shall response to a specific program.
> How do I catch the program name or other program identifer of the front
> most current running program from an INIT?

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
'=====================================================

Hope this helps.
- Rick