1 {
2 File: HIServices/Processes.h
3
4 Contains: Process Manager Interfaces.
5
6 Version: HIServices-416~44
7
8 Copyright: � 1989-2008 by Apple Computer, Inc., all rights reserved
9
10 Bugs?: For bug reports, consult the following page on
11 the World Wide Web:
12
13 http://bugs.freepascal.org
14
15 }
16 { Pascal Translation Updated: Peter N Lewis, <peter@stairways.com.au>, August 2005 }
17 { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2009 }
18 { Pascal Translation Updated: Jonas Maebe, <jonas@freepascal.org>, October 2012 }
19 {
20 Modified for use with Free Pascal
21 Version 308
22 Please report any bugs to <gpc@microbizz.nl>
23 }
24
25 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
26 {$mode macpas}
27 {$modeswitch cblocks}
28 {$packenum 1}
29 {$macro on}
30 {$inline on}
31 {$calling mwpascal}
32
33 unit Processes;
34 interface
35 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
36 {$setc GAP_INTERFACES_VERSION := $0308}
37
38 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
39 {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
40 {$endc}
41
42 {$ifc defined CPUPOWERPC and defined CPUI386}
43 {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
44 {$endc}
45 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
46 {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
47 {$endc}
48
49 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
50 {$setc __ppc__ := 1}
51 {$elsec}
52 {$setc __ppc__ := 0}
53 {$endc}
54 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
55 {$setc __ppc64__ := 1}
56 {$elsec}
57 {$setc __ppc64__ := 0}
58 {$endc}
59 {$ifc not defined __i386__ and defined CPUI386}
60 {$setc __i386__ := 1}
61 {$elsec}
62 {$setc __i386__ := 0}
63 {$endc}
64 {$ifc not defined __x86_64__ and defined CPUX86_64}
65 {$setc __x86_64__ := 1}
66 {$elsec}
67 {$setc __x86_64__ := 0}
68 {$endc}
69 {$ifc not defined __arm__ and defined CPUARM}
70 {$setc __arm__ := 1}
71 {$elsec}
72 {$setc __arm__ := 0}
73 {$endc}
74 {$ifc not defined __arm64__ and defined CPUAARCH64}
75 {$setc __arm64__ := 1}
76 {$elsec}
77 {$setc __arm64__ := 0}
78 {$endc}
79
80 {$ifc defined cpu64}
81 {$setc __LP64__ := 1}
82 {$elsec}
83 {$setc __LP64__ := 0}
84 {$endc}
85
86
87 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
88 {$error Conflicting definitions for __ppc__ and __i386__}
89 {$endc}
90
91 {$ifc defined __ppc__ and __ppc__}
92 {$setc TARGET_CPU_PPC := TRUE}
93 {$setc TARGET_CPU_PPC64 := FALSE}
94 {$setc TARGET_CPU_X86 := FALSE}
95 {$setc TARGET_CPU_X86_64 := FALSE}
96 {$setc TARGET_CPU_ARM := FALSE}
97 {$setc TARGET_CPU_ARM64 := FALSE}
98 {$setc TARGET_OS_MAC := TRUE}
99 {$setc TARGET_OS_IPHONE := FALSE}
100 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
101 {$setc TARGET_OS_EMBEDDED := FALSE}
102 {$elifc defined __ppc64__ and __ppc64__}
103 {$setc TARGET_CPU_PPC := FALSE}
104 {$setc TARGET_CPU_PPC64 := TRUE}
105 {$setc TARGET_CPU_X86 := FALSE}
106 {$setc TARGET_CPU_X86_64 := FALSE}
107 {$setc TARGET_CPU_ARM := FALSE}
108 {$setc TARGET_CPU_ARM64 := FALSE}
109 {$setc TARGET_OS_MAC := TRUE}
110 {$setc TARGET_OS_IPHONE := FALSE}
111 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
112 {$setc TARGET_OS_EMBEDDED := FALSE}
113 {$elifc defined __i386__ and __i386__}
114 {$setc TARGET_CPU_PPC := FALSE}
115 {$setc TARGET_CPU_PPC64 := FALSE}
116 {$setc TARGET_CPU_X86 := TRUE}
117 {$setc TARGET_CPU_X86_64 := FALSE}
118 {$setc TARGET_CPU_ARM := FALSE}
119 {$setc TARGET_CPU_ARM64 := FALSE}
120 {$ifc defined iphonesim}
121 {$setc TARGET_OS_MAC := FALSE}
122 {$setc TARGET_OS_IPHONE := TRUE}
123 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
124 {$elsec}
125 {$setc TARGET_OS_MAC := TRUE}
126 {$setc TARGET_OS_IPHONE := FALSE}
127 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
128 {$endc}
129 {$setc TARGET_OS_EMBEDDED := FALSE}
130 {$elifc defined __x86_64__ and __x86_64__}
131 {$setc TARGET_CPU_PPC := FALSE}
132 {$setc TARGET_CPU_PPC64 := FALSE}
133 {$setc TARGET_CPU_X86 := FALSE}
134 {$setc TARGET_CPU_X86_64 := TRUE}
135 {$setc TARGET_CPU_ARM := FALSE}
136 {$setc TARGET_CPU_ARM64 := FALSE}
137 {$ifc defined iphonesim}
138 {$setc TARGET_OS_MAC := FALSE}
139 {$setc TARGET_OS_IPHONE := TRUE}
140 {$setc TARGET_IPHONE_SIMULATOR := TRUE}
141 {$elsec}
142 {$setc TARGET_OS_MAC := TRUE}
143 {$setc TARGET_OS_IPHONE := FALSE}
144 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
145 {$endc}
146 {$setc TARGET_OS_EMBEDDED := FALSE}
147 {$elifc defined __arm__ and __arm__}
148 {$setc TARGET_CPU_PPC := FALSE}
149 {$setc TARGET_CPU_PPC64 := FALSE}
150 {$setc TARGET_CPU_X86 := FALSE}
151 {$setc TARGET_CPU_X86_64 := FALSE}
152 {$setc TARGET_CPU_ARM := TRUE}
153 {$setc TARGET_CPU_ARM64 := FALSE}
154 {$setc TARGET_OS_MAC := FALSE}
155 {$setc TARGET_OS_IPHONE := TRUE}
156 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
157 {$setc TARGET_OS_EMBEDDED := TRUE}
158 {$elifc defined __arm64__ and __arm64__}
159 {$setc TARGET_CPU_PPC := FALSE}
160 {$setc TARGET_CPU_PPC64 := FALSE}
161 {$setc TARGET_CPU_X86 := FALSE}
162 {$setc TARGET_CPU_X86_64 := FALSE}
163 {$setc TARGET_CPU_ARM := FALSE}
164 {$setc TARGET_CPU_ARM64 := TRUE}
165 {$ifc defined ios}
166 {$setc TARGET_OS_MAC := FALSE}
167 {$setc TARGET_OS_IPHONE := TRUE}
168 {$setc TARGET_OS_EMBEDDED := TRUE}
169 {$elsec}
170 {$setc TARGET_OS_MAC := TRUE}
171 {$setc TARGET_OS_IPHONE := FALSE}
172 {$setc TARGET_OS_EMBEDDED := FALSE}
173 {$endc}
174 {$setc TARGET_IPHONE_SIMULATOR := FALSE}
175 {$elsec}
176 {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
177 {$endc}
178
179 {$ifc defined __LP64__ and __LP64__ }
180 {$setc TARGET_CPU_64 := TRUE}
181 {$elsec}
182 {$setc TARGET_CPU_64 := FALSE}
183 {$endc}
184
185 {$ifc defined FPC_BIG_ENDIAN}
186 {$setc TARGET_RT_BIG_ENDIAN := TRUE}
187 {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
188 {$elifc defined FPC_LITTLE_ENDIAN}
189 {$setc TARGET_RT_BIG_ENDIAN := FALSE}
190 {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
191 {$elsec}
192 {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
193 {$endc}
194 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
195 {$setc CALL_NOT_IN_CARBON := FALSE}
196 {$setc OLDROUTINENAMES := FALSE}
197 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
198 {$setc OPAQUE_UPP_TYPES := TRUE}
199 {$setc OTCARBONAPPLICATION := TRUE}
200 {$setc OTKERNEL := FALSE}
201 {$setc PM_USE_SESSION_APIS := TRUE}
202 {$setc TARGET_API_MAC_CARBON := TRUE}
203 {$setc TARGET_API_MAC_OS8 := FALSE}
204 {$setc TARGET_API_MAC_OSX := TRUE}
205 {$setc TARGET_CARBON := TRUE}
206 {$setc TARGET_CPU_68K := FALSE}
207 {$setc TARGET_CPU_MIPS := FALSE}
208 {$setc TARGET_CPU_SPARC := FALSE}
209 {$setc TARGET_OS_UNIX := FALSE}
210 {$setc TARGET_OS_WIN32 := FALSE}
211 {$setc TARGET_RT_MAC_68881 := FALSE}
212 {$setc TARGET_RT_MAC_CFM := FALSE}
213 {$setc TARGET_RT_MAC_MACHO := TRUE}
214 {$setc TYPED_FUNCTION_POINTERS := TRUE}
215 {$setc TYPE_BOOL := FALSE}
216 {$setc TYPE_EXTENDED := FALSE}
217 {$setc TYPE_LONGLONG := TRUE}
218 uses MacTypes,CFBase,CFDictionary,Events,Files,MacOSXPosix;
219 {$endc} {not MACOSALLINCLUDE}
220
221
222 {$ifc TARGET_OS_MAC}
223
224 {$ALIGN MAC68K}
225
226 const
227 { Process identifier - Various reserved process serial numbers }
228 kNoProcess = 0;
229 kSystemProcess = 1;
230 kCurrentProcess = 2;
231
232 { Definition of the parameter block passed to _Launch }
233 { Typedef and flags for launchControlFlags field}
234 type
235 LaunchFlags = UInt16;
236 const
237 launchContinue = $4000;
238 launchNoFileFlags = $0800;
239 launchUseMinimum = $0400;
240 launchDontSwitch = $0200;
241 launchAllow24Bit = $0100;
242 launchInhibitDaemon = $0080;
243
244 { Format for first AppleEvent to pass to new process. The size of the overall
245 buffer variable: the message body immediately follows the messageLength }
246 type
247 AppParameters = record
248 theMsgEvent: EventRecord;
249 eventRefCon: UInt32;
250 messageLength: UInt32;
251 end;
252 AppParametersPtr = ^AppParameters;
253 { Parameter block to _Launch }
254 {$ifc TARGET_CPU_64}
255 type
256 LaunchParamBlockRec = record
257 reserved1: UInt32;
258 reserved2: UInt16;
259 launchBlockID: UInt16;
260 launchEPBLength: UInt32;
261 launchFileFlags: UInt16;
262 launchControlFlags: LaunchFlags;
263 launchAppRef: FSRefPtr;
264 launchProcessSN: ProcessSerialNumber;
265 launchPreferredSize: UInt32;
266 launchMinimumSize: UInt32;
267 launchAvailableSize: UInt32;
268 launchAppParameters: AppParametersPtr;
269 end;
270 {$elsec}
271 type
272 LaunchParamBlockRec = record
273 reserved1: UInt32;
274 reserved2: UInt16;
275 launchBlockID: UInt16;
276 launchEPBLength: UInt32;
277 launchFileFlags: UInt16;
278 launchControlFlags: LaunchFlags;
279 launchAppSpec: FSSpecPtr;
280 launchProcessSN: ProcessSerialNumber;
281 launchPreferredSize: UInt32;
282 launchMinimumSize: UInt32;
283 launchAvailableSize: UInt32;
284 launchAppParameters: AppParametersPtr;
285 end;
286 {$endc} {TARGET_CPU_64}
287 LaunchParamBlockRecPtr = ^LaunchParamBlockRec;
288
289 type
290 LaunchPBPtr = LaunchParamBlockRecPtr;
291 { Set launchBlockID to extendedBlock to specify that extensions exist.
292 Set launchEPBLength to extendedBlockLen for compatibility.}
293 const
294 extendedBlock = $4C43; { 'LC' }
295 extendedBlockLen = SizeOf(LaunchParamBlockRec) - 12;
296
297 const
298 { Definition of the information block returned by GetProcessInformation }
299 modeReserved = $01000000;
300 modeControlPanel = $00080000;
301 modeLaunchDontSwitch = $00040000;
302 modeDeskAccessory = $00020000;
303 modeMultiLaunch = $00010000;
304 modeNeedSuspendResume = $00004000;
305 modeCanBackground = $00001000;
306 modeDoesActivateOnFGSwitch = $00000800;
307 modeOnlyBackground = $00000400;
308 modeGetFrontClicks = $00000200;
309 modeGetAppDiedMsg = $00000100;
310 mode32BitCompatible = $00000080;
311 modeHighLevelEventAware = $00000040;
312 modeLocalAndRemoteHLEvents = $00000020;
313 modeStationeryAware = $00000010;
314 modeUseTextEditServices = $00000008;
315 modeDisplayManagerAware = $00000004;
316
317 type
318 ProcessApplicationTransformState = UInt32;
319 const
320 kProcessTransformToForegroundApplication = 1;
321 kProcessTransformToBackgroundApplication = 2; { functional in Mac OS X Barolo and later }
322 kProcessTransformToUIElementApplication = 4; { functional in Mac OS X Barolo and later }
323
324 {
325 Record returned by GetProcessInformation
326 When calling GetProcessInformation(), the input ProcessInfoRec
327 should have the processInfoLength set to sizeof(ProcessInfoRec),
328 the processName field set to nil or a pointer to a Str255, and
329 processAppSpec set to nil or a pointer to an FSSpec. If
330 processName or processAppSpec are not specified, this routine
331 will very likely write data to whatever random location in memory
332 these happen to point to, which is not a good thing.
333 Note: The processName field may not be what you expect, especially if
334 an application has a localized name. The .processName field, if not NULL,
335 on return will contain the filename part of the executable file of the
336 application. If you want the localized, user-displayable name for an
337 application, call CopyProcessName().
338 On Mac OS X, some flags in processMode will not be set as they were on
339 Mac OS 9, even for Classic applications. Mac OS X doesn't support
340 applications which can't be sent into the background, so
341 modeCanBackground will always be set. Similarly, Mac OS X applications
342 will always have mode32BitCompatible and modeHighLevelEventAware
343 set.
344
345 }
346 {$ifc TARGET_CPU_64}
347 type
348 ProcessInfoRec = record
349 processInfoLength: UInt32;
350 processName: StringPtr;
351 processNumber: ProcessSerialNumber;
352 processType: UInt32;
353 processSignature: OSType;
354 processMode: UInt32;
355 processLocation: Ptr;
356 processSize: UInt32;
357 processFreeMem: UInt32;
358 processLauncher: ProcessSerialNumber;
359 processLaunchDate: UInt32;
360 processActiveTime: UInt32;
361 processAppRef: FSRefPtr;
362 end;
363 {$elsec}
364 type
365 ProcessInfoRec = record
366 processInfoLength: UInt32;
367 processName: StringPtr;
368 processNumber: ProcessSerialNumber;
369 processType: UInt32;
370 processSignature: OSType;
371 processMode: UInt32;
372 processLocation: Ptr;
373 processSize: UInt32;
374 processFreeMem: UInt32;
375 processLauncher: ProcessSerialNumber;
376 processLaunchDate: UInt32;
377 processActiveTime: UInt32;
378 processAppSpec: FSSpecPtr;
379 end;
380 {$endc} {TARGET_CPU_64}
381
382 ProcessInfoRecPtr = ^ProcessInfoRec;
383 {
384 Some applications assumed the size of a ProcessInfoRec would never change,
385 which has caused problems trying to return additional information. In
386 the future, we will add fields to ProcessInfoExtendedRec when necessary,
387 and callers which wish to access 'more' data than originally was present
388 in ProcessInfoRec should allocate space for a ProcessInfoExtendedRec,
389 fill in the processInfoLength ( and processName and processAppSpec ptrs ),
390 then coerce this to a ProcessInfoRecPtr in the call to
391 GetProcessInformation().
392 Note: The processName field may not be what you expect, especially if
393 an application has a localized name. The .processName field, if not NULL,
394 on return will contain the filename part of the executable file of the
395 application. If you want the localized, user-displayable name for an
396 application, call CopyProcessName().
397 On Mac OS X, some flags in processMode will not be set as they were on
398 Mac OS 9, even for Classic applications. Mac OS X doesn't support
399 applications which can't be sent into the background, so
400 modeCanBackground will always be set. Similarly, Mac OS X applications
401 will always have mode32BitCompatible and modeHighLevelEventAware
402 set.
403
404 }
405 {$ifc TARGET_CPU_64}
406 type
407 ProcessInfoExtendedRec = record
408 processInfoLength: UInt32;
409 processName: StringPtr;
410 processNumber: ProcessSerialNumber;
411 processType: UInt32;
412 processSignature: OSType;
413 processMode: UInt32;
414 processLocation: Ptr;
415 processSize: UInt32;
416 processFreeMem: UInt32;
417 processLauncher: ProcessSerialNumber;
418 processLaunchDate: UInt32;
419 processActiveTime: UInt32;
420 processAppRef: FSRefPtr;
421 processTempMemTotal: UInt32;
422 processPurgeableTempMemTotal: UInt32;
423 end;
424 {$elsec}
425 type
426 ProcessInfoExtendedRec = record
427 processInfoLength: UInt32;
428 processName: StringPtr;
429 processNumber: ProcessSerialNumber;
430 processType: UInt32;
431 processSignature: OSType;
432 processMode: UInt32;
433 processLocation: Ptr;
434 processSize: UInt32;
435 processFreeMem: UInt32;
436 processLauncher: ProcessSerialNumber;
437 processLaunchDate: UInt32;
438 processActiveTime: UInt32;
439 processAppSpec: FSSpecPtr;
440 processTempMemTotal: UInt32;
441 processPurgeableTempMemTotal: UInt32;
442 end;
443 {$endc} {TARGET_CPU_64}
444
445 ProcessInfoExtendedRecPtr = ^ProcessInfoExtendedRec;
446 { Record corresponding to the SIZE resource definition }
447 type
448 SizeResourceRec = record
449 flags: UInt16;
450 preferredHeapSize: UInt32;
451 minimumHeapSize: UInt32;
452 end;
453 SizeResourceRecPtr = ^SizeResourceRec;
454 type
455 SizeResourceRecHandle = ^SizeResourceRecPtr;
456
457 {
458 * Summary:
459 * Options for ProcessInformationCopyDictionary
460 }
461 const
462 {
463 * Return all information known about the application in the
464 * dictionary.
465 }
466 kProcessDictionaryIncludeAllInformationMask = $FFFFFFFF;
467
468 {
469 Applications and background applications can control when they are asked to quit
470 by the system at restart/shutdown by setting these bits in a 'quit' ( 0 ) resource
471 in their application's resource fork. Applications without a 'quit' ( 0 ) will
472 be quit at kQuitAtNormalTime mask.
473 These options only function on Mac OS 9.x at this time.
474 }
475 const
476 kQuitBeforeNormalTimeMask = 1;
477 kQuitAtNormalTimeMask = 2;
478 kQuitBeforeFBAsQuitMask = 4;
479 kQuitBeforeShellQuitsMask = 8;
480 kQuitBeforeTerminatorAppQuitsMask = 16;
481 kQuitNeverMask = 32;
482 kQuitOptionsMask = $7F;
483 kQuitNotQuitDuringInstallMask = $0100;
484 kQuitNotQuitDuringLogoutMask = $0200;
485
486
487 {
488 * LaunchApplication()
489 *
490 * Mac OS X threading:
491 * Thread safe since version 10.3
492 *
493 * Availability:
494 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
495 * CarbonLib: in CarbonLib 1.0 and later
496 * Non-Carbon CFM: in InterfaceLib 7.1 and later
497 }
LaunchApplicationnull498 function LaunchApplication( LaunchParams: LaunchPBPtr ): OSErr; external name '_LaunchApplication';
499 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
500
501
502 {$ifc not TARGET_CPU_64}
503 {
504 * LaunchDeskAccessory()
505 *
506 * Availability:
507 * Mac OS X: not available [32-bit only]
508 * CarbonLib: not available
509 * Non-Carbon CFM: in InterfaceLib 7.1 and later
510 }
511
512
513 {$endc} {not TARGET_CPU_64}
514
515 {
516 * [Mac]GetCurrentProcess()
517 *
518 * Discussion:
519 * Return the canonical process serial number to the caller.
520 *
521 * All applications ( things which can appear in the Dock or which
522 * are not documents and are launched by the Finder or Dock ) on Mac
523 * OS 10 have a unique process serial number. This number is created
524 * when the application launches, and remains until the application
525 * quits. Other system services, like AppleEvents, use the
526 * ProcessSerialNumber to specify an application.
527 *
528 * During launch, every application 'checks in' with the Process
529 * Manager. Before this checkin, the application can not receive
530 * events or draw to the screen. Prior to Mac OS 10.2, this 'check
531 * in' happened before the applications's main() function was
532 * entered. In Mac OS 10.2 and later, this 'check in' does not
533 * happen until the first time the application calls a Process
534 * Manager function, or until it enters CFRunLoopRun() for the main
535 * runloop. This allows tools and other executables which do not
536 * need to receive events to link against more of the higher level
537 * toolbox frameworks, but may cause a problem if the application
538 * expects to be able to retrieve events or use CoreGraphics
539 * services before this checkin has occurred.
540 *
541 * An application can force the connection to the Process Manager to
542 * be set up by calling any Process Manager routine, but the
543 * recommended way to do this is to call GetCurrentProcess() to ask
544 * for the current application's PSN. This will initialize the
545 * connection to the Process Manager if it has not already been set
546 * up and 'check in' the application with the system.
547 *
548 * This function is named MacGetCurrentProcess() on non Macintosh
549 * platforms and GetCurrentProcess on the Macintosh. However, even
550 * Macintosh code can use the MacGetCurrentProcess() name since
551 * there is a macro which maps back to GetCurrentProcess().
552 *
553 * Lastly, it is usually not necessary to call GetCurrentProcess()
554 * to get the 'current' process psn merely to pass it to another
555 * Process Manager routine. Instead, just construct a
556 * ProcessSerialNumber with 0 in highLongOfPSN and kCurrentProcess
557 * in lowLongOfPSN and pass that. For example, to make the current
558 * process the frontmost process, use ( C code follows )
559 *
560 * ProcessSerialNumber psn = ( 0, kCurrentProcess );
561 *
562 * OSErr err = SetFrontProcess( & psn );
563 *
564 * If you need to pass a ProcessSerialNumber to another application
565 * or use it in an AppleEvent, you do need to get the canonical PSN
566 * with this routine.
567 *
568 * Mac OS X threading:
569 * Thread safe since version 10.3
570 *
571 * Parameters:
572 *
573 * PSN:
574 * Pass in where the current application process serial number
575 * should be returned.
576 *
577 * Result:
578 * An operating system status code.
579 *
580 * Availability:
581 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
582 * CarbonLib: in CarbonLib 1.0 and later
583 * Non-Carbon CFM: in InterfaceLib 7.1 and later
584 }
585 {$ifc TARGET_OS_MAC}
MacGetCurrentProcessnull586 function MacGetCurrentProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetCurrentProcess';
587 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
588 {$endc} {TARGET_OS_MAC}
GetCurrentProcessnull589 function GetCurrentProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetCurrentProcess';
590 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
591
592 {
593 * GetFrontProcess()
594 *
595 * Mac OS X threading:
596 * Thread safe since version 10.3
597 *
598 * Availability:
599 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
600 * CarbonLib: in CarbonLib 1.0 and later
601 * Non-Carbon CFM: in InterfaceLib 7.1 and later
602 }
GetFrontProcessnull603 function GetFrontProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetFrontProcess';
604 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
605
606
607 {
608 * GetNextProcess()
609 *
610 * Mac OS X threading:
611 * Thread safe since version 10.3
612 *
613 * Availability:
614 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
615 * CarbonLib: in CarbonLib 1.0 and later
616 * Non-Carbon CFM: in InterfaceLib 7.1 and later
617 }
GetNextProcessnull618 function GetNextProcess( var PSN: ProcessSerialNumber ): OSErr; external name '_GetNextProcess';
619 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
620
621
622 {
623 * GetProcessInformation()
624 *
625 * Discussion:
626 * Fill in the provided record with information about the process
627 * with the provided process serial number.
628 *
629 * The caller must fill in the .processInfoLength field with the
630 * value sizeof ( ProcessInformationRecord ) before making this
631 * call. Also, the .processName field must point to either NULL or
632 * to a Str31 structure in the caller's memory space, and the
633 * .processAppSpec field must point to a FSSpec in the caller's
634 * memory space.
635 *
636 * If the caller does not care about the process name or the process
637 * application spec values, then setting those fields in the
638 * structure to NULL before this call means less work must be done
639 * to construct these values and so the call is more
640 * efficient.
641 *
642 * The processName field may not be what you expect, especially if
643 * an application has a localized name. The .processName field, if
644 * not NULL, on return will contain the filename part of the
645 * executable file of the application. If you want the localized,
646 * user-displayable name for an application, call
647 * CopyProcessName().
648 *
649 * On Mac OS X, the processSize and processFreeMem fields are
650 * returned with the value 0.
651 *
652 * On Mac OS X 10.6 and later, the processLaunchDate field is an
653 * integer value with the same scale as CFAbsoluteTime. Prior
654 * releases used a value in 60th of a second with a random zero
655 * time, making it difficult to use. Since most applications just
656 * look at the comparison from this field to other launch dates this
657 * change should not affect many applications.
658 *
659 * Mac OS X threading:
660 * Thread safe since version 10.3
661 *
662 * Parameters:
663 *
664 * PSN:
665 * Pass in the process serial number of the process to return
666 * information for.
667 *
668 * info:
669 * Pass in a structure where the information will be returned.
670 *
671 * Availability:
672 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
673 * CarbonLib: in CarbonLib 1.0 and later
674 * Non-Carbon CFM: in InterfaceLib 7.1 and later
675 }
GetProcessInformationnull676 function GetProcessInformation( const (*var*) PSN: ProcessSerialNumber; var info: ProcessInfoRec ): OSErr; external name '_GetProcessInformation';
677 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
678
679
680 {
681 * ProcessInformationCopyDictionary()
682 *
683 * Discussion:
684 * Return a CFDictionary containing information about the given
685 * process. This is intended to return a superset of the information
686 * returned by GetProcessInformation(), in more modern datatypes.
687 *
688 * Mac OS X threading:
689 * Thread safe since version 10.3
690 *
691 * Parameters:
692 *
693 * PSN:
694 * Pass in the process serial number of the process to return
695 * information for.
696 *
697 * infoToReturn:
698 * Pass in the value kProcessDictionaryIncludeAllInformationMask.
699 *
700 * Result:
701 * An immutable CFDictionaryRef containing these keys and their
702 * values. Keys marked with a '*' are optional. Over time more keys
703 * may be added.
704 *
705 * Key Name Type
706 * -------- ----
707 * "PSN" CFNumber, kCFNumberLongLongType
708 * "Flavor" CFNumber, kCFNumberSInt32. A hint
709 * as to the flavor of the application. Note that this should only
710 * be used as a hint, since a bundle of a different flavor might be
711 * loaded into an application's address space. The assigned values
712 * at present are: Mac OS Classic aplications have the value 0,
713 * Carbon applications have the value 2, Cocoa applications have the
714 * value 3. Other undocumented values may also be returned.
715 * "Attributes" CFNumber, kCFNumberSInt32
716 * "ParentPSN" * CFNumber, kCFNumberLongLong
717 * "FileType" * CFString, file type
718 * "FileCreator" * CFString, file creator
719 * "pid" * CFNumber, kCFNumberLongType
720 * "LSBackgroundOnly" CFBoolean
721 * "LSUIElement" CFBoolean
722 * "IsHiddenAttr" CFBoolean
723 * "IsCheckedInAttr" CFBoolean
724 * "RequiresCarbon" CFBoolean
725 * "LSUserQuitOnly" * CFBoolean
726 * "LSUIPresentationMode" CFNumber, kCFNumberShortType
727 * "BundlePath" * CFString
728 * kCFBundleExecutableKey * CFString
729 * kCFBundleNameKey * CFString
730 * kCFBundleIdentifierKey * CFString
731 *
732 * Availability:
733 * Mac OS X: in version 10.2 and later in ApplicationServices.framework
734 * CarbonLib: not available in CarbonLib 1.x
735 * Non-Carbon CFM: not available
736 }
ProcessInformationCopyDictionarynull737 function ProcessInformationCopyDictionary( const (*var*) PSN: ProcessSerialNumber; infoToReturn: UInt32 ): CFDictionaryRef; external name '_ProcessInformationCopyDictionary';
738 (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
739
740
741 {
742 * SetFrontProcess()
743 *
744 * Mac OS X threading:
745 * Thread safe since version 10.3
746 *
747 * Availability:
748 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
749 * CarbonLib: in CarbonLib 1.0 and later
750 * Non-Carbon CFM: in InterfaceLib 7.1 and later
751 }
SetFrontProcessnull752 function SetFrontProcess( const (*var*) PSN: ProcessSerialNumber ): OSErr; external name '_SetFrontProcess';
753 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
754
755
756 {
757 * Summary:
758 * Options for SetFrontProcessWithOptions
759 }
760 const
761 {
762 * Activate the process, but bring only the frontmost non-floating
763 * window forward. If this option is not set, all process windows are
764 * brought forward.
765 }
766 kSetFrontProcessFrontWindowOnly = 1 shl 0;
767 kSetFrontProcessCausedByUser = 1 shl 1; { indicates that direct user activity is causing this SetFrontProcessWithOptions() call }
768
769
770 {
771 * SetFrontProcessWithOptions()
772 *
773 * Discussion:
774 * Brings a process to the front of the process list and activates
775 * it. This is much like the SetFrontProcess API, though we allow
776 * more control here. Passing 0 for the options is equivalent to
777 * calling SetFrontProcess. Alternatively, you can pass
778 * kSetFrontProcessFrontWindowOnly, which will activate a process
779 * without bringing all of the process's windows forward (just the
780 * front window of the process will come forward).
781 *
782 * Mac OS X threading:
783 * Thread safe since version 10.3
784 *
785 * Parameters:
786 *
787 * inProcess:
788 * The process to make frontmost.
789 *
790 * inOptions:
791 * Any options you wish to specify.
792 *
793 * Result:
794 * An operating system status code.
795 *
796 * Availability:
797 * Mac OS X: in version 10.2 and later in ApplicationServices.framework
798 * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
799 * Non-Carbon CFM: not available
800 }
SetFrontProcessWithOptionsnull801 function SetFrontProcessWithOptions( const (*var*) inProcess: ProcessSerialNumber; inOptions: OptionBits ): OSStatus; external name '_SetFrontProcessWithOptions';
802 (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
803
804
805 {
806 * WakeUpProcess()
807 *
808 * Mac OS X threading:
809 * Thread safe since version 10.3
810 *
811 * Availability:
812 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
813 * CarbonLib: in CarbonLib 1.0 and later
814 * Non-Carbon CFM: in InterfaceLib 7.1 and later
815 }
WakeUpProcessnull816 function WakeUpProcess( const (*var*) PSN: ProcessSerialNumber ): OSErr; external name '_WakeUpProcess';
817 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
818
819
820 {
821 * SameProcess()
822 *
823 * Mac OS X threading:
824 * Thread safe since version 10.3
825 *
826 * Availability:
827 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
828 * CarbonLib: in CarbonLib 1.0 and later
829 * Non-Carbon CFM: in InterfaceLib 7.1 and later
830 }
SameProcessnull831 function SameProcess( const (*var*) PSN1: ProcessSerialNumber; const (*var*) PSN2: ProcessSerialNumber; var result: Boolean ): OSErr; external name '_SameProcess';
832 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
833
834
835 { ExitToShell was previously in SegLoad.h}
836 {
837 * ExitToShell()
838 *
839 * Discussion:
840 * In general, you need to call ExitToShell only if you want your
841 * application to terminate without reaching the end of its main
842 * function.
843 *
844 * The ExitToShell function terminates the calling process. The
845 * Process Manager removes your application from the list of open
846 * processes and performs any other necessary cleanup operations. If
847 * necessary, the Application Died Apple event is sent to the
848 * process that launched your application.
849 *
850 * Availability:
851 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
852 * CarbonLib: in CarbonLib 1.0 and later
853 * Non-Carbon CFM: in InterfaceLib 7.1 and later
854 }
855 procedure ExitToShell; external name '_ExitToShell';
856 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
857
858
859 {
860 * KillProcess()
861 *
862 * Discussion:
863 * Kills the process with the given process serial number, without
864 * sending it a 'quit' AppleEvent or otherwise allowing it to save
865 * user data or clean up. This should be a last resort way to 'kill'
866 * an application, after all other attempts to make it stop have
867 * failed. It is not guaranteed that this will succeed and that the
868 * target application will be killed, even if this function returns
869 * noErr and seems to work.
870 *
871 * Mac OS X threading:
872 * Thread safe since version 10.3
873 *
874 * Parameters:
875 *
876 * inProcess:
877 * The process to kill.
878 *
879 * Result:
880 * An operating system status code.
881 *
882 * Availability:
883 * Mac OS X: in version 10.2 and later in ApplicationServices.framework
884 * CarbonLib: not available in CarbonLib 1.x
885 * Non-Carbon CFM: not available
886 }
KillProcessnull887 function KillProcess( const (*var*) inProcess: ProcessSerialNumber ): OSErr; external name '_KillProcess';
888 (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
889
890
891 {
892 LaunchControlPanel is similar to LaunchDeskAccessory, but for Control Panel files instead.
893 It launches a control panel in an application shell maintained by the Process Manager.
894 }
895 {$ifc not TARGET_CPU_64}
896 {
897 * LaunchControlPanel()
898 *
899 * Availability:
900 * Mac OS X: not available [32-bit only]
901 * CarbonLib: not available
902 * Non-Carbon CFM: in InterfaceLib 9.0 and later
903 }
904
905
906 {$endc} {not TARGET_CPU_64}
907
908 {
909 * GetProcessBundleLocation()
910 *
911 * Summary:
912 * Retrieve the filesystem location of the process bundle, or
913 * executable if unbundled.
914 *
915 * Discussion:
916 * Retrieves a reference to the filesystem location of the specified
917 * application. For an application that is packaged as an app
918 * bundle, this will be the app bundle directory; otherwise it will
919 * be the location of the executable itself.
920 *
921 * Mac OS X threading:
922 * Thread safe since version 10.3
923 *
924 * Parameters:
925 *
926 * psn:
927 * Serial number of the target process
928 *
929 * location:
930 * Location of the bundle or executable, as an FSRef
931 *
932 * Availability:
933 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
934 * CarbonLib: in CarbonLib 1.5 and later
935 * Non-Carbon CFM: not available
936 }
GetProcessBundleLocationnull937 function GetProcessBundleLocation( const (*var*) psn: ProcessSerialNumber; var location: FSRef ): OSStatus; external name '_GetProcessBundleLocation';
938 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
939
940
941 {
942 * CopyProcessName()
943 *
944 * Summary:
945 * Get a copy of the name of a process.
946 *
947 * Discussion:
948 * Use this call to get the name of a process as a CFString. The
949 * name returned is a copy, so the caller must CFRelease the name
950 * when finished with it. The difference between this call and the
951 * processName field filled in by GetProcessInformation is that the
952 * name here is a CFString, and thus is capable of representing a
953 * multi-lingual name, whereas previously only a mac-encoded string
954 * was possible.
955 *
956 * Mac OS X threading:
957 * Thread safe since version 10.3
958 *
959 * Parameters:
960 *
961 * psn:
962 * Serial number of the target process
963 *
964 * name:
965 * CFString representing the name of the process (must be released
966 * by caller with CFRelease)
967 *
968 * Availability:
969 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
970 * CarbonLib: in CarbonLib 1.5 and later
971 * Non-Carbon CFM: not available
972 }
CopyProcessNamenull973 function CopyProcessName( const (*var*) psn: ProcessSerialNumber; var name: CFStringRef ): OSStatus; external name '_CopyProcessName';
974 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
975
976
977 {
978 * GetProcessPID()
979 *
980 * Summary:
981 * Get the UNIX process ID corresponding to a process.
982 *
983 * Discussion:
984 * Given a Process serial number, this call will get the UNIX
985 * process ID for that process. Note that this call does not make
986 * sense for Classic apps, since they all share a single UNIX
987 * process ID.
988 *
989 * Mac OS X threading:
990 * Thread safe since version 10.3
991 *
992 * Parameters:
993 *
994 * psn:
995 * Serial number of the target process
996 *
997 * pid:
998 * UNIX process ID of the process
999 *
1000 * Availability:
1001 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
1002 * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
1003 * Non-Carbon CFM: not available
1004 }
GetProcessPIDnull1005 function GetProcessPID( const (*var*) psn: ProcessSerialNumber; var pid: pid_t ): OSStatus; external name '_GetProcessPID';
1006 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
1007
1008
1009 {
1010 * GetProcessForPID()
1011 *
1012 * Summary:
1013 * Get the process serial number corresponding to a UNIX process ID.
1014 *
1015 * Discussion:
1016 * Given a UNIX process ID, this call will get the process serial
1017 * number for that process, if appropriate. Note that this call does
1018 * not make sense for Classic apps, since they all share a single
1019 * UNIX process ID.
1020 *
1021 * Mac OS X threading:
1022 * Thread safe since version 10.3
1023 *
1024 * Parameters:
1025 *
1026 * psn:
1027 * Serial number of the process
1028 *
1029 * pid:
1030 * UNIX process ID of the target process
1031 *
1032 * Availability:
1033 * Mac OS X: in version 10.0 and later in ApplicationServices.framework
1034 * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
1035 * Non-Carbon CFM: not available
1036 }
GetProcessForPIDnull1037 function GetProcessForPID( pid: pid_t; var psn: ProcessSerialNumber ): OSStatus; external name '_GetProcessForPID';
1038 (* AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER *)
1039
1040
1041 {************************************************************************
1042 * Process Visibility.
1043 ************************************************************************}
1044 {
1045 * IsProcessVisible()
1046 *
1047 * Summary:
1048 * Determines whether a particular process is visible or not.
1049 *
1050 * Discussion:
1051 * Given a psn, this call will return true or false depending on
1052 * whether or not the process is currently visible.
1053 *
1054 * Mac OS X threading:
1055 * Thread safe since version 10.3
1056 *
1057 * Parameters:
1058 *
1059 * psn:
1060 * Serial number of the process
1061 *
1062 * Availability:
1063 * Mac OS X: in version 10.1 and later in ApplicationServices.framework
1064 * CarbonLib: in CarbonLib 1.5 and later
1065 * Non-Carbon CFM: not available
1066 }
IsProcessVisiblenull1067 function IsProcessVisible( const (*var*) psn: ProcessSerialNumber ): Boolean; external name '_IsProcessVisible';
1068 (* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
1069
1070
1071 {
1072 * ShowHideProcess()
1073 *
1074 * Summary:
1075 * Hides or shows a given process.
1076 *
1077 * Discussion:
1078 * Given a psn, this call will hide or show the process specified in
1079 * the psn parameter. You determine whether you would like to show
1080 * or hide the process with the visible parameter. True passed into
1081 * visible indicates you wish for the process to become visible.
1082 *
1083 * Mac OS X threading:
1084 * Thread safe since version 10.3
1085 *
1086 * Parameters:
1087 *
1088 * psn:
1089 * Serial number of the process
1090 *
1091 * visible:
1092 * true = show process; false = hide process
1093 *
1094 * Availability:
1095 * Mac OS X: in version 10.1 and later in ApplicationServices.framework
1096 * CarbonLib: in CarbonLib 1.5 and later
1097 * Non-Carbon CFM: not available
1098 }
ShowHideProcessnull1099 function ShowHideProcess( const (*var*) psn: ProcessSerialNumber; visible: Boolean ): OSErr; external name '_ShowHideProcess';
1100 (* AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER *)
1101
1102
1103 {
1104 * TransformProcessType()
1105 *
1106 * Summary:
1107 * Changes the 'type' of the process specified in the psn parameter.
1108 * The type is specified in the transformState parameter.
1109 *
1110 * Discussion:
1111 * Given a psn for an application, this call transforms that
1112 * application into the given type. Foreground applications have a
1113 * menu bar and appear in the Dock. Background applications do not
1114 * appear in the Dock, do not have a menu bar ( and should not have
1115 * windows or other user interface ). UIElement applications do not
1116 * have a menu bar, do not appear in the dock, but may in limited
1117 * circumstances present windows and user interface. If a foreground
1118 * application is frontmost when transformed into a background
1119 * application, it is first hidden and another application is made
1120 * frontmost. A UIElement or background-only application which is
1121 * transformed into a foreground application is not brought to the
1122 * front (use SetFrontProcess() after the transform if this is
1123 * required) nor will it be shown if it is hidden ( even if hidden
1124 * automatically by being transformed into a background-only
1125 * application ), so the caller should use ShowHideProcess() to show
1126 * the application after it is transformed into a foreground
1127 * application. Applications can only transform themselves; this
1128 * call cannot change the type of another application.
1129 *
1130 * Mac OS X threading:
1131 * Thread safe since version 10.3
1132 *
1133 * Parameters:
1134 *
1135 * psn:
1136 * Serial number of the process
1137 *
1138 * transformState:
1139 * state to tranform the application to.
1140 *
1141 * Availability:
1142 * Mac OS X: in version 10.3 and later in ApplicationServices.framework
1143 * CarbonLib: not available in CarbonLib 1.x
1144 * Non-Carbon CFM: not available
1145 }
TransformProcessTypenull1146 function TransformProcessType( const (*var*) psn: ProcessSerialNumber; transformState: ProcessApplicationTransformState ): OSStatus; external name '_TransformProcessType';
1147 (* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
1148
1149
1150 { Values of the 'message' parameter to a Control Panel 'cdev' }
1151 const
1152 initDev = 0; {Time for cdev to initialize itself}
1153 hitDev = 1; {Hit on one of my items}
1154 closeDev = 2; {Close yourself}
1155 nulDev = 3; {Null event}
1156 updateDev = 4; {Update event}
1157 activDev = 5; {Activate event}
1158 deactivDev = 6; {Deactivate event}
1159 keyEvtDev = 7; {Key down/auto key}
1160 macDev = 8; {Decide whether or not to show up}
1161 undoDev = 9;
1162 cutDev = 10;
1163 copyDev = 11;
1164 pasteDev = 12;
1165 clearDev = 13;
1166 cursorDev = 14;
1167
1168 { Special values a Control Panel 'cdev' can return }
1169 const
1170 cdevGenErr = -1; {General error; gray cdev w/o alert}
1171 cdevMemErr = 0; {Memory shortfall; alert user please}
1172 cdevResErr = 1; {Couldn't get a needed resource; alert}
1173 cdevUnset = 3; { cdevValue is initialized to this}
1174
1175 { Control Panel Default Proc }
1176
1177
1178 {$endc} {TARGET_OS_MAC}
1179 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
1180
1181 end.
1182 {$endc} {not MACOSALLINCLUDE}
1183