home *** CD-ROM | disk | FTP | other *** search
- /*********
- ** ak_ppc.c
- **
- ** contains code for ppc functions of the program
- ** and code for launching other apps.
- ***********/
-
- #ifndef THINK_C
- /* include the <standard mac headers> */
- #include <AppleEvents.h>
- #include <Desk.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Fonts.h>
- #include <GestaltEqu.h>
- #include <Menus.h>
- #include <OSEvents.h>
- #include <QuickDraw.h>
- #include <THINK.h>
- #include <ToolUtils.h>
- #include <Types.h>
- #include <Windows.h>
- #else
- #include "ak_headers"
- #endif
- #include <StandardFile.h>
- #include <string.h>
- #include "ak_ppc.h"
-
- void DoAlert(Str255, Str255, Str255, Str255); /* appkiller.c */
-
- void MyPPCInit(void)
- {
- OSErr err;
- err = PPCInit();
- } /* MyPPCInit() */
-
-
- void PostWithPPCBrowser(void) /* p. 5-25, IM-6 */
- {
- EventRecord myHLEvent;
- OSErr myErr;
- PortInfoRec myPortInfo;
- TargetID myTarget;
-
- myErr = PPCBrowser("\pSelect an Application to Stop", "\pApplication", FALSE,
- &myTarget.location, &myPortInfo, NULL, "\p");
- if (myErr == noErr) {
- /* copy portname into myTarget.name */
- void *tmp;
- /*DebugStr("Before memcpy()"); */
- tmp = memcpy( &myTarget.name, &myPortInfo.name,
- sizeof(myPortInfo.name));
- /*DebugStr("After memcpy()"); */
- myHLEvent.what = kHighLevelEvent;
- myHLEvent.message = (long)kCoreEventClass;
- *(long*)(&myHLEvent.where) = (long)kAEQuitApplication;
-
- /*DebugStr("\pbefore PostHighLevelEvent()."); */
- myErr = PostHighLevelEvent(&myHLEvent, (long)&myTarget, 0, NULL,0,
- receiverIDisTargetID);
- /*DebugStr("\pafter PostHighLevelEvent()."); */
- } /* if */
- } /* PostWithPPCBrowser() */
-
-
- void DoLaunch(void)
- {
- // PLAN OF ATTACK:
- //
- // 1) pop up standard file open box; select any file of type APPL
- // 2) SubLaunch the application, while keeping ourselves alive.
- // 3) Cleanup(?) and exit.
-
- StandardFileReply theSFR;
- SFTypeList theTypes;
- OSErr err;
-
- theTypes[0] = 'APPL'; /* to launch any application */
- theTypes[1] = 'FNDR'; /* to launch the finder again */
-
- StandardGetFile(NULL, 2, theTypes, &theSFR); // 1)
-
- if ( theSFR.sfGood == TRUE) {
- LaunchParamBlockRec launchParams;
- ProcessSerialNumber psn;
- long psize, msize,asize; /* preferred, min, available sizes */
-
- launchParams.launchBlockID = extendedBlock;
- launchParams.launchEPBLength = extendedBlockLen;
- launchParams.launchFileFlags = 0;
- launchParams.launchControlFlags = launchContinue +
- launchNoFileFlags;
- launchParams.launchAppSpec = &(theSFR.sfFile);
- launchParams.launchAppParameters = NULL;
-
- err = LaunchApplication(&launchParams); // 2)
-
- if (err != noErr) DoAlert("\pSorry, an error occured and",
- "\pSystem 7 choked.", "\p", "\p");
- } /* if user selected file... */
-
- return; // 3)
- } /* DoLaunch() */
-
-
-
-
-