
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
Get the process number of an application
Has anybody tried to send AppleEvents to "yourself"? (that is, the sending program and the receiving program will be the same.) IM:IAC says to use the kCurrentProcess constant when creating an AEdesc with your target info, but I couldn't find the value for kCurrentProcess. Does anybody have that value?
Another question, along the same lines, for the AppleEvent gurus. Is this how you create an AEdesc for direct dispatching?:
myErr = AECreateDesc (_typeProcessSerialNumber, _kCurrentProcess, len(kCurrentEvent), targetAddressDesc)
DIM RECORD procSerNumRec
DIM psnHigh&
DIM psnLow&
DIM END RECORD .procSerNumRecSize
'
DIM myProcess.procSerNumRecSize
CLEAR LOCAL MODE
LOCAL FN GetFrontProcess (@psnPtr&)
` SUBQ.L #2,sp ;clear space for osErr
` MOVE.L ^psnPtr&,-(sp) ;PUSH psn ptr ON stack
` MOVEQ #-1,D0
` MOVE.L D0,-(sp)
` DC.W $3F3C,$0039,$A88F ;trap number
` MOVE.W (sp)+,^osErr% ;D0 = osErr
END FN = osErr%
LOCAL FN InitProcessManager
myProcess.psnHigh&=0:' just zero these out for now
myProcess.psnLow&=_kCurrentProcess:' to find the current process
osErr = FN GetFrontProcess(myProcess):' and get my process ser#
END FN
Call the FN InitProcessManager when your program starts (only done once). Now you have the process serial number.
I don't think "len (kCurrentEvent)" is what you want. I use the the constant created when a define the Desc record, eg:
DIM RECORD blah
DIM aVar
DIM END RECORD.blah
myErr = AECreateDesc (_typeProcessSerialNumber, _kCurrentProcess, _blah, targetAddressDesc)
|