Processes.pas 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. {
  2. File: HIServices/Processes.h
  3. Contains: Process Manager Interfaces.
  4. Version: HIServices-162.0.81~21
  5. Copyright: © 1989-2005 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://www.freepascal.org/bugs.html
  9. }
  10. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit Processes;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,CFBase,CFDictionary,Quickdraw,AEDataModel,Events,Files,TextCommon,CFString,MacOSXPosix;
  92. {$ALIGN MAC68K}
  93. const
  94. { Process identifier - Various reserved process serial numbers }
  95. kNoProcess = 0;
  96. kSystemProcess = 1;
  97. kCurrentProcess = 2;
  98. { Definition of the parameter block passed to _Launch }
  99. { Typedef and flags for launchControlFlags field}
  100. type
  101. LaunchFlags = UInt16;
  102. const
  103. launchContinue = $4000;
  104. launchNoFileFlags = $0800;
  105. launchUseMinimum = $0400;
  106. launchDontSwitch = $0200;
  107. launchAllow24Bit = $0100;
  108. launchInhibitDaemon = $0080;
  109. { Format for first AppleEvent to pass to new process. The size of the overall
  110. buffer variable: the message body immediately follows the messageLength }
  111. type
  112. AppParameters = record
  113. theMsgEvent: EventRecord;
  114. eventRefCon: UInt32;
  115. messageLength: UInt32;
  116. end;
  117. AppParametersPtr = ^AppParameters;
  118. { Parameter block to _Launch }
  119. type
  120. LaunchParamBlockRecPtr = ^LaunchParamBlockRec;
  121. LaunchParamBlockRec = record
  122. reserved1: UInt32;
  123. reserved2: UInt16;
  124. launchBlockID: UInt16;
  125. launchEPBLength: UInt32;
  126. launchFileFlags: UInt16;
  127. launchControlFlags: LaunchFlags;
  128. launchAppSpec: FSSpecPtr;
  129. launchProcessSN: ProcessSerialNumber;
  130. launchPreferredSize: UInt32;
  131. launchMinimumSize: UInt32;
  132. launchAvailableSize: UInt32;
  133. launchAppParameters: AppParametersPtr;
  134. end;
  135. type
  136. LaunchPBPtr = LaunchParamBlockRecPtr;
  137. { Set launchBlockID to extendedBlock to specify that extensions exist.
  138. Set launchEPBLength to extendedBlockLen for compatibility.}
  139. const
  140. extendedBlock = $4C43; { 'LC' }
  141. extendedBlockLen = SizeOf(LaunchParamBlockRec) - 12;
  142. const
  143. { Definition of the information block returned by GetProcessInformation }
  144. modeReserved = $01000000;
  145. modeControlPanel = $00080000;
  146. modeLaunchDontSwitch = $00040000;
  147. modeDeskAccessory = $00020000;
  148. modeMultiLaunch = $00010000;
  149. modeNeedSuspendResume = $00004000;
  150. modeCanBackground = $00001000;
  151. modeDoesActivateOnFGSwitch = $00000800;
  152. modeOnlyBackground = $00000400;
  153. modeGetFrontClicks = $00000200;
  154. modeGetAppDiedMsg = $00000100;
  155. mode32BitCompatible = $00000080;
  156. modeHighLevelEventAware = $00000040;
  157. modeLocalAndRemoteHLEvents = $00000020;
  158. modeStationeryAware = $00000010;
  159. modeUseTextEditServices = $00000008;
  160. modeDisplayManagerAware = $00000004;
  161. type
  162. ProcessApplicationTransformState = UInt32;
  163. const
  164. kProcessTransformToForegroundApplication = 1;
  165. {
  166. Record returned by GetProcessInformation
  167. When calling GetProcessInformation(), the input ProcessInfoRec
  168. should have the processInfoLength set to sizeof(ProcessInfoRec),
  169. the processName field set to nil or a pointer to a Str255, and
  170. processAppSpec set to nil or a pointer to an FSSpec. If
  171. processName or processAppSpec are not specified, this routine
  172. will very likely write data to whatever random location in memory
  173. these happen to point to, which is not a good thing.
  174. Note: The processName field may not be what you expect, especially if
  175. an application has a localized name. The .processName field, if not NULL,
  176. on return will contain the filename part of the executable file of the
  177. application. If you want the localized, user-displayable name for an
  178. application, call CopyProcessName().
  179. On Mac OS X, some flags in processMode will not be set as they were on
  180. Mac OS 9, even for Classic applications. Mac OS X doesn't support
  181. applications which can't be sent into the background, so
  182. modeCanBackground will always be set. Similarly, Mac OS X applications
  183. will always have mode32BitCompatible and modeHighLevelEventAware
  184. set.
  185. }
  186. type
  187. ProcessInfoRec = record
  188. processInfoLength: UInt32;
  189. processName: StringPtr;
  190. processNumber: ProcessSerialNumber;
  191. processType: UInt32;
  192. processSignature: OSType;
  193. processMode: UInt32;
  194. processLocation: Ptr;
  195. processSize: UInt32;
  196. processFreeMem: UInt32;
  197. processLauncher: ProcessSerialNumber;
  198. processLaunchDate: UInt32;
  199. processActiveTime: UInt32;
  200. processAppSpec: FSSpecPtr;
  201. end;
  202. ProcessInfoRecPtr = ^ProcessInfoRec;
  203. {
  204. Some applications assumed the size of a ProcessInfoRec would never change,
  205. which has caused problems trying to return additional information. In
  206. the future, we will add fields to ProcessInfoExtendedRec when necessary,
  207. and callers which wish to access 'more' data than originally was present
  208. in ProcessInfoRec should allocate space for a ProcessInfoExtendedRec,
  209. fill in the processInfoLength ( and processName and processAppSpec ptrs ),
  210. then coerce this to a ProcessInfoRecPtr in the call to
  211. GetProcessInformation().
  212. Note: The processName field may not be what you expect, especially if
  213. an application has a localized name. The .processName field, if not NULL,
  214. on return will contain the filename part of the executable file of the
  215. application. If you want the localized, user-displayable name for an
  216. application, call CopyProcessName().
  217. On Mac OS X, some flags in processMode will not be set as they were on
  218. Mac OS 9, even for Classic applications. Mac OS X doesn't support
  219. applications which can't be sent into the background, so
  220. modeCanBackground will always be set. Similarly, Mac OS X applications
  221. will always have mode32BitCompatible and modeHighLevelEventAware
  222. set.
  223. }
  224. type
  225. ProcessInfoExtendedRec = record
  226. processInfoLength: UInt32;
  227. processName: StringPtr;
  228. processNumber: ProcessSerialNumber;
  229. processType: UInt32;
  230. processSignature: OSType;
  231. processMode: UInt32;
  232. processLocation: Ptr;
  233. processSize: UInt32;
  234. processFreeMem: UInt32;
  235. processLauncher: ProcessSerialNumber;
  236. processLaunchDate: UInt32;
  237. processActiveTime: UInt32;
  238. processAppSpec: FSSpecPtr;
  239. processTempMemTotal: UInt32;
  240. processPurgeableTempMemTotal: UInt32;
  241. end;
  242. ProcessInfoExtendedRecPtr = ^ProcessInfoExtendedRec;
  243. { Record corresponding to the SIZE resource definition }
  244. type
  245. SizeResourceRec = record
  246. flags: UInt16;
  247. preferredHeapSize: UInt32;
  248. minimumHeapSize: UInt32;
  249. end;
  250. SizeResourceRecPtr = ^SizeResourceRec;
  251. type
  252. SizeResourceRecHandle = ^SizeResourceRecPtr;
  253. {
  254. * Summary:
  255. * Options for ProcessInformationCopyDictionary
  256. }
  257. const
  258. {
  259. * Return all information known about the application in the
  260. * dictionary.
  261. }
  262. kProcessDictionaryIncludeAllInformationMask = $FFFFFFFF;
  263. {
  264. Applications and background applications can control when they are asked to quit
  265. by the system at restart/shutdown by setting these bits in a 'quit' ( 0 ) resource
  266. in their application's resource fork. Applications without a 'quit' ( 0 ) will
  267. be quit at kQuitAtNormalTime mask.
  268. These options only function on Mac OS 9.x at this time.
  269. }
  270. const
  271. kQuitBeforeNormalTimeMask = 1;
  272. kQuitAtNormalTimeMask = 2;
  273. kQuitBeforeFBAsQuitMask = 4;
  274. kQuitBeforeShellQuitsMask = 8;
  275. kQuitBeforeTerminatorAppQuitsMask = 16;
  276. kQuitNeverMask = 32;
  277. kQuitOptionsMask = $7F;
  278. kQuitNotQuitDuringInstallMask = $0100;
  279. kQuitNotQuitDuringLogoutMask = $0200;
  280. {
  281. * LaunchApplication()
  282. *
  283. * Availability:
  284. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  285. * CarbonLib: in CarbonLib 1.0 and later
  286. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  287. }
  288. function LaunchApplication( LaunchParams: LaunchPBPtr ): OSErr; external name '_LaunchApplication';
  289. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  290. {
  291. * LaunchDeskAccessory()
  292. *
  293. * Availability:
  294. * Mac OS X: not available
  295. * CarbonLib: not available
  296. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  297. }
  298. {
  299. * [Mac]GetCurrentProcess()
  300. *
  301. * Discussion:
  302. * Return the canonical process serial number to the caller.
  303. *
  304. * All applications ( things which can appear in the Dock or which
  305. * are not documents and are launched by the Finder or Dock ) on Mac
  306. * OS 10 have a unique process serial number. This number is created
  307. * when the application launches, and remains until the application
  308. * quits. Other system services, like AppleEvents, use the
  309. * ProcessSerialNumber to specify an application.
  310. *
  311. * During launch, every application 'checks in' with the Process
  312. * Manager. Before this checkin, the application can not receive
  313. * events or draw to the screen. Prior to Mac OS 10.2, this 'check
  314. * in' happened before the applications's main() function was
  315. * entered. In Mac OS 10.2 and later, this 'check in' does not
  316. * happen until the first time the application calls a Process
  317. * Manager function, or until it enters CFRunLoopRun() for the main
  318. * runloop. This allows tools and other executables which do not
  319. * need to receive events to link against more of the higher level
  320. * toolbox frameworks, but may cause a problem if the application
  321. * expects to be able to retrieve events or use CoreGraphics
  322. * services before this checkin has occurred.
  323. *
  324. * An application can force the connection to the Process Manager to
  325. * be set up by calling any Process Manager routine, but the
  326. * recommended way to do this is to call GetCurrentProcess() to ask
  327. * for the current application's PSN. This will initialize the
  328. * connection to the Process Manager if it has not already been set
  329. * up and 'check in' the application with the system.
  330. *
  331. * This function is named MacGetCurrentProcess() on non Macintosh
  332. * platforms and GetCurrentProcess on the Macintosh. However, even
  333. * Macintosh code can use the MacGetCurrentProcess() name since
  334. * there is a macro which maps back to GetCurrentProcess().
  335. *
  336. * Lastly, it is usually not necessary to call GetCurrentProcess()
  337. * to get the 'current' process psn merely to pass it to another
  338. * Process Manager routine. Instead, just construct a
  339. * ProcessSerialNumber with 0 in highLongOfPSN and kCurrentProcess
  340. * in lowLongOfPSN and pass that. For example, to make the current
  341. * process the frontmost process, use ( C code follows )
  342. *
  343. * ProcessSerialNumber psn = ( 0, kCurrentProcess );
  344. *
  345. * OSErr err = SetFrontProcess( & psn );
  346. *
  347. * If you need to pass a ProcessSerialNumber to another application
  348. * or use it in an AppleEvent, you do need to get the canonical PSN
  349. * with this routine.
  350. *
  351. * Parameters:
  352. *
  353. * PSN:
  354. * Pass in where the current application process serial number
  355. * should be returned.
  356. *
  357. * Result:
  358. * An operating system status code.
  359. *
  360. * Availability:
  361. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  362. * CarbonLib: in CarbonLib 1.0 and later
  363. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  364. }
  365. function GetCurrentProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetCurrentProcess';
  366. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  367. function MacGetCurrentProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetCurrentProcess';
  368. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  369. {
  370. * GetFrontProcess()
  371. *
  372. * Availability:
  373. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  374. * CarbonLib: in CarbonLib 1.0 and later
  375. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  376. }
  377. function GetFrontProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetFrontProcess';
  378. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  379. {
  380. * GetNextProcess()
  381. *
  382. * Availability:
  383. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  384. * CarbonLib: in CarbonLib 1.0 and later
  385. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  386. }
  387. function GetNextProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetNextProcess';
  388. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  389. {
  390. * GetProcessInformation()
  391. *
  392. * Discussion:
  393. * Fill in the provided record with information about the process
  394. * with the provided process serial number.
  395. *
  396. * The caller must fill in the .processInfoLength field with the
  397. * value sizeof ( ProcessInformationRecord ) before making this
  398. * call. Also, the .processName field must point to either NULL or
  399. * to a Str31 structure in the caller's memory space, and the
  400. * .processAppSpec field must point to a FSSpec in the caller's
  401. * memory space.
  402. *
  403. * If the caller does not care about the process name or the process
  404. * application spec values, then setting those fields in the
  405. * structure to NULL before this call means less work must be done
  406. * to construct these values and so the call is more
  407. * efficient.
  408. *
  409. * The processName field may not be what you expect, especially if
  410. * an application has a localized name. The .processName field, if
  411. * not NULL, on return will contain the filename part of the
  412. * executable file of the application. If you want the localized,
  413. * user-displayable name for an application, call
  414. * CopyProcessName().
  415. *
  416. * On Mac OS X, the processSize and processFreeMem fields are
  417. * returned with the value 0.
  418. *
  419. * Parameters:
  420. *
  421. * PSN:
  422. * Pass in the process serial number of the process to return
  423. * information for.
  424. *
  425. * info:
  426. * Pass in a structure where the information will be returned.
  427. *
  428. * Availability:
  429. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  430. * CarbonLib: in CarbonLib 1.0 and later
  431. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  432. }
  433. function GetProcessInformation( const (*var*) PSN: ProcessSerialNumber; var info: ProcessInfoRec ): OSErr; external name '_GetProcessInformation';
  434. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  435. {
  436. * ProcessInformationCopyDictionary()
  437. *
  438. * Discussion:
  439. * Return a CFDictionary containing information about the given
  440. * process. This is intended to return a superset of the information
  441. * returned by GetProcessInformation(), in more modern datatypes.
  442. *
  443. * Parameters:
  444. *
  445. * PSN:
  446. * Pass in the process serial number of the process to return
  447. * information for.
  448. *
  449. * infoToReturn:
  450. * Pass in the value kProcessDictionaryIncludeAllInformationMask.
  451. *
  452. * Result:
  453. * An immutable CFDictionaryRef containing these keys and their
  454. * values. Keys marked with a '*' are optional. Over time more keys
  455. * may be added.
  456. *
  457. * Key Name Type
  458. * -------- ----
  459. * "PSN" CFNumber, kCFNumberLongLongType
  460. * "Flavor" CFNumber, kCFNumberSInt32. A hint
  461. * as to the flavor of the application. Note that this should only
  462. * be used as a hint, since a bundle of a different flavor might be
  463. * loaded into an application's address space. The assigned values
  464. * at present are: Mac OS Classic aplications have the value 0,
  465. * Carbon applications have the value 2, Cocoa applications have the
  466. * value 4. Other undocumented values may also be returned.
  467. * "Attributes" CFNumber, kCFNumberSInt32
  468. * "ParentPSN" * CFNumber, kCFNumberLongLong
  469. * "FileType" * CFString, file type
  470. * "FileCreator" * CFString, file creator
  471. * "pid" * CFNumber, kCFNumberLongType
  472. * "LSBackgroundOnly" CFBoolean
  473. * "LSUIElement" CFBoolean
  474. * "IsHiddenAttr" CFBoolean
  475. * "IsCheckedInAttr" CFBoolean
  476. * "RequiresClassic" CFBoolean
  477. * "RequiresCarbon" CFBoolean
  478. * "LSUserQuitOnly" CFBoolean
  479. * "LSUIPresentationMode" CFNumber, kCFNumberShortType
  480. * "BundlePath" * CFString
  481. * kIOBundleExecutableKey * CFString
  482. * kIOBundleNameKey * CFString
  483. * kIOBundleIdentifierKey * CFString
  484. *
  485. * Availability:
  486. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  487. * CarbonLib: not available in CarbonLib 1.x
  488. * Non-Carbon CFM: not available
  489. }
  490. function ProcessInformationCopyDictionary( const (*var*) PSN: ProcessSerialNumber; infoToReturn: UInt32 ): CFDictionaryRef; external name '_ProcessInformationCopyDictionary';
  491. (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  492. {
  493. * SetFrontProcess()
  494. *
  495. * Availability:
  496. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  497. * CarbonLib: in CarbonLib 1.0 and later
  498. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  499. }
  500. function SetFrontProcess( const (*var*) PSN: ProcessSerialNumber ): OSErr; external name '_SetFrontProcess';
  501. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  502. {
  503. * Summary:
  504. * Options for SetFrontProcessWithOptions
  505. }
  506. const
  507. {
  508. * Activate the process, but bring only the frontmost non-floating
  509. * window forward. If this option is not set, all process windows are
  510. * brought forward.
  511. }
  512. kSetFrontProcessFrontWindowOnly = 1 shl 0;
  513. {
  514. * SetFrontProcessWithOptions()
  515. *
  516. * Discussion:
  517. * Brings a process to the front of the process list and activates
  518. * it. This is much like the SetFrontProcess API, though we allow
  519. * more control here. Passing 0 for the options is equivalent to
  520. * calling SetFrontProcess. Alternatively, you can pass
  521. * kSetFrontProcessFrontWindowOnly, which will activate a process
  522. * without bringing all of the process's windows forward (just the
  523. * front window of the process will come forward).
  524. *
  525. * Parameters:
  526. *
  527. * inProcess:
  528. * The process to make frontmost.
  529. *
  530. * inOptions:
  531. * Any options you wish to specify.
  532. *
  533. * Result:
  534. * An operating system status code.
  535. *
  536. * Availability:
  537. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  538. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  539. * Non-Carbon CFM: not available
  540. }
  541. function SetFrontProcessWithOptions( const (*var*) inProcess: ProcessSerialNumber; inOptions: OptionBits ): OSStatus; external name '_SetFrontProcessWithOptions';
  542. (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  543. {
  544. * WakeUpProcess()
  545. *
  546. * Availability:
  547. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  548. * CarbonLib: in CarbonLib 1.0 and later
  549. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  550. }
  551. function WakeUpProcess( const (*var*) PSN: ProcessSerialNumber ): OSErr; external name '_WakeUpProcess';
  552. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  553. {
  554. * SameProcess()
  555. *
  556. * Availability:
  557. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  558. * CarbonLib: in CarbonLib 1.0 and later
  559. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  560. }
  561. function SameProcess( const (*var*) PSN1: ProcessSerialNumber; const (*var*) PSN2: ProcessSerialNumber; var result: Boolean ): OSErr; external name '_SameProcess';
  562. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  563. { ExitToShell was previously in SegLoad.h}
  564. {
  565. * ExitToShell()
  566. *
  567. * Availability:
  568. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  569. * CarbonLib: in CarbonLib 1.0 and later
  570. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  571. }
  572. procedure ExitToShell; external name '_ExitToShell';
  573. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  574. {
  575. * KillProcess()
  576. *
  577. * Discussion:
  578. * Kills the process with the given process serial number, without
  579. * sending it a 'quit' AppleEvent or otherwise allowing it to save
  580. * user data or clean up. This should be a last resort way to 'kill'
  581. * an application, after all other attempts to make it stop have
  582. * failed. It is not guaranteed that this will succeed and that the
  583. * target application will be killed, even if this function returns
  584. * noErr and seems to work.
  585. *
  586. * Parameters:
  587. *
  588. * inProcess:
  589. * The process to kill.
  590. *
  591. * Result:
  592. * An operating system status code.
  593. *
  594. * Availability:
  595. * Mac OS X: in version 10.2 and later in ApplicationServices.framework
  596. * CarbonLib: not available in CarbonLib 1.x
  597. * Non-Carbon CFM: not available
  598. }
  599. function KillProcess( const (*var*) inProcess: ProcessSerialNumber ): OSErr; external name '_KillProcess';
  600. (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  601. {
  602. LaunchControlPanel is similar to LaunchDeskAccessory, but for Control Panel files instead.
  603. It launches a control panel in an application shell maintained by the Process Manager.
  604. }
  605. {
  606. * LaunchControlPanel()
  607. *
  608. * Availability:
  609. * Mac OS X: not available
  610. * CarbonLib: not available
  611. * Non-Carbon CFM: in InterfaceLib 9.0 and later
  612. }
  613. {
  614. * GetProcessBundleLocation()
  615. *
  616. * Summary:
  617. * Retrieve the filesystem location of the process bundle, or
  618. * executable if unbundled.
  619. *
  620. * Discussion:
  621. * Retrieves a reference to the filesystem location of the specified
  622. * application. For an application that is packaged as an app
  623. * bundle, this will be the app bundle directory; otherwise it will
  624. * be the location of the executable itself.
  625. *
  626. * Parameters:
  627. *
  628. * psn:
  629. * Serial number of the target process
  630. *
  631. * location:
  632. * Location of the bundle or executable, as an FSRef
  633. *
  634. * Availability:
  635. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  636. * CarbonLib: in CarbonLib 1.5 and later
  637. * Non-Carbon CFM: not available
  638. }
  639. function GetProcessBundleLocation( const (*var*) psn: ProcessSerialNumber; var location: FSRef ): OSStatus; external name '_GetProcessBundleLocation';
  640. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  641. {
  642. * CopyProcessName()
  643. *
  644. * Summary:
  645. * Get a copy of the name of a process.
  646. *
  647. * Discussion:
  648. * Use this call to get the name of a process as a CFString. The
  649. * name returned is a copy, so the caller must CFRelease the name
  650. * when finished with it. The difference between this call and the
  651. * processName field filled in by GetProcessInformation is that the
  652. * name here is a CFString, and thus is capable of representing a
  653. * multi-lingual name, whereas previously only a mac-encoded string
  654. * was possible.
  655. *
  656. * Parameters:
  657. *
  658. * psn:
  659. * Serial number of the target process
  660. *
  661. * name:
  662. * CFString representing the name of the process (must be released
  663. * by caller with CFRelease)
  664. *
  665. * Availability:
  666. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  667. * CarbonLib: in CarbonLib 1.5 and later
  668. * Non-Carbon CFM: not available
  669. }
  670. function CopyProcessName( const (*var*) psn: ProcessSerialNumber; var name: CFStringRef ): OSStatus; external name '_CopyProcessName';
  671. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  672. {
  673. * GetProcessPID()
  674. *
  675. * Summary:
  676. * Get the UNIX process ID corresponding to a process.
  677. *
  678. * Discussion:
  679. * Given a Process serial number, this call will get the UNIX
  680. * process ID for that process. Note that this call does not make
  681. * sense for Classic apps, since they all share a single UNIX
  682. * process ID.
  683. *
  684. * Parameters:
  685. *
  686. * psn:
  687. * Serial number of the target process
  688. *
  689. * pid:
  690. * UNIX process ID of the process
  691. *
  692. * Availability:
  693. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  694. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  695. * Non-Carbon CFM: not available
  696. }
  697. function GetProcessPID( const (*var*) psn: ProcessSerialNumber; var pid: pid_t ): OSStatus; external name '_GetProcessPID';
  698. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  699. {
  700. * GetProcessForPID()
  701. *
  702. * Summary:
  703. * Get the process serial number corresponding to a UNIX process ID.
  704. *
  705. * Discussion:
  706. * Given a UNIX process ID, this call will get the process serial
  707. * number for that process, if appropriate. Note that this call does
  708. * not make sense for Classic apps, since they all share a single
  709. * UNIX process ID.
  710. *
  711. * Parameters:
  712. *
  713. * psn:
  714. * Serial number of the process
  715. *
  716. * pid:
  717. * UNIX process ID of the target process
  718. *
  719. * Availability:
  720. * Mac OS X: in version 10.0 and later in ApplicationServices.framework
  721. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  722. * Non-Carbon CFM: not available
  723. }
  724. function GetProcessForPID( pid: pid_t; var psn: ProcessSerialNumber ): OSStatus; external name '_GetProcessForPID';
  725. (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
  726. {************************************************************************
  727. * Process Visibility.
  728. ************************************************************************}
  729. {
  730. * IsProcessVisible()
  731. *
  732. * Summary:
  733. * Determines whether a particular process is visible or not.
  734. *
  735. * Discussion:
  736. * Given a psn, this call will return true or false depending on
  737. * whether or not the process is currently visible.
  738. *
  739. * Parameters:
  740. *
  741. * psn:
  742. * Serial number of the process
  743. *
  744. * Availability:
  745. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  746. * CarbonLib: in CarbonLib 1.5 and later
  747. * Non-Carbon CFM: not available
  748. }
  749. function IsProcessVisible( const (*var*) psn: ProcessSerialNumber ): Boolean; external name '_IsProcessVisible';
  750. (* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
  751. {
  752. * ShowHideProcess()
  753. *
  754. * Summary:
  755. * Hides or shows a given process.
  756. *
  757. * Discussion:
  758. * Given a psn, this call will hide or show the process specified in
  759. * the psn parameter. You determine whether you would like to show
  760. * or hide the process with the visible parameter. True passed into
  761. * visible indicates you wish for the process to become visible.
  762. *
  763. * Parameters:
  764. *
  765. * psn:
  766. * Serial number of the process
  767. *
  768. * visible:
  769. * true = show process; false = hide process
  770. *
  771. * Availability:
  772. * Mac OS X: in version 10.1 and later in ApplicationServices.framework
  773. * CarbonLib: in CarbonLib 1.5 and later
  774. * Non-Carbon CFM: not available
  775. }
  776. function ShowHideProcess( const (*var*) psn: ProcessSerialNumber; visible: Boolean ): OSErr; external name '_ShowHideProcess';
  777. (* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
  778. {
  779. * TransformProcessType()
  780. *
  781. * Summary:
  782. * Changes the 'type' of the process specified in the psn parameter.
  783. * The type is specified in the transformState parameter.
  784. *
  785. * Discussion:
  786. * Given a psn which is a background-only application, this call can
  787. * cause that application to be transformed into a foreground
  788. * application. A background only application does not appear in
  789. * the Dock or in the Force Quit dialog, and never has a menu bar or
  790. * is frontmost, while a foreground application does appear in the
  791. * Dock and Force Quit dialog and does have a menu bar. This call
  792. * does not cause the application to be brought to the front ( use
  793. * SetFrontProcess for that ).
  794. *
  795. * Parameters:
  796. *
  797. * psn:
  798. * Serial number of the process
  799. *
  800. * transformState:
  801. * state to tranform the application to.
  802. *
  803. * Availability:
  804. * Mac OS X: in version 10.3 and later in ApplicationServices.framework
  805. * CarbonLib: not available in CarbonLib 1.x
  806. * Non-Carbon CFM: not available
  807. }
  808. function TransformProcessType( const (*var*) psn: ProcessSerialNumber; transformState: ProcessApplicationTransformState ): OSStatus; external name '_TransformProcessType';
  809. (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
  810. { Values of the 'message' parameter to a Control Panel 'cdev' }
  811. const
  812. initDev = 0; {Time for cdev to initialize itself}
  813. hitDev = 1; {Hit on one of my items}
  814. closeDev = 2; {Close yourself}
  815. nulDev = 3; {Null event}
  816. updateDev = 4; {Update event}
  817. activDev = 5; {Activate event}
  818. deactivDev = 6; {Deactivate event}
  819. keyEvtDev = 7; {Key down/auto key}
  820. macDev = 8; {Decide whether or not to show up}
  821. undoDev = 9;
  822. cutDev = 10;
  823. copyDev = 11;
  824. pasteDev = 12;
  825. clearDev = 13;
  826. cursorDev = 14;
  827. { Special values a Control Panel 'cdev' can return }
  828. const
  829. cdevGenErr = -1; {General error; gray cdev w/o alert}
  830. cdevMemErr = 0; {Memory shortfall; alert user please}
  831. cdevResErr = 1; {Couldn't get a needed resource; alert}
  832. cdevUnset = 3; { cdevValue is initialized to this}
  833. { Control Panel Default Proc }
  834. end.