[futurebasic] Re: Launching Applications

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Wed, 26 Nov 1997 19:12:05 -0600
Jamin wrote:
> I am using the following routine to launch an application.  On a 68k Mac 
> the code will launch another 68k Application, BUT on a PowerMac it only 
> launches 68k applications, not native or fat apps.  The routine returns 
> no error when it fails to launch a fat app.  In MacsBugs via "procinfo", 
> you can see the app does exisit for a few seconds, but then it dies 
> without error.  The fat app is not at fault, as I have tried launching 
> Acrobat, Photoshop etc, all with the same results. I am sure that my 
> parameter block is correct, because launching a 68k app works.  
> 
> I re-wrote the whole routine & parameter block in C, then compiled it 
> into a code resource. If you call the code resource from a C app it 
> works, but from a FB app it fails as before ?

There are two different techniques for calling the Launch (a.k.a
LaunchApplication) procedure; the "old" way and the "new" way.  The
"old" way requires you to pass a pointer to a 6-byte buffer, of which
the first 4 bytes are a pointer to a string containing the application's
complete path name.  The "new" way requires you to pass a pointer to a
44-byte buffer, of which the first 6 bytes are zeros and the other 38
contain much useful information about how exactly you want to launch
your application.

So, I wonder if you're using the "old" technique to launch?  Apple has
been advising people for some time to use only the "new" technique, and
I speculate that it's possible that the "old" technique does not work
when you're trying to launch a PPC-native app.

You might try the following code, which uses the "new" technique; I've
verified that it works when launching PPC-native app's.  You need to
call FN Sublaunch, and pass it a pointer to an "FSSpec" record (a
70-byte record containing the app's volume ref. number, parent directory
ID, and name).  If you need advice on how to create an FSSpec record,
let me know (it's not complicated).

Hope this helps.
- Rick

_myReserved1 = 0
_myReserved2 = 4
_mylaunchAppParameters = 40
'--------------------------------------------------------
LOCAL FN LaunchApplication(pbAddr&)
`     MOVE.L  ^pbAddr&,A0
`     DC.W    $A9F2
`     MOVE.W  D0,^OSErr
END FN = OSErr
'--------------------------------------------------------
LOCAL FN SubLaunch(AppSpecAddr&)
'Call as follows:
'  OSErr = FN SubLaunch(@FSSpec)
'where FSSpec is a 70-byte file spec record identifying the application.
DIM LaunchParams.44
LaunchParams.myReserved1& = 0
LaunchParams.myReserved2% = 0
LaunchParams.launchBlockID% = _extendedBlock
LaunchParams.launchEPBLength& = _extendedBlockLen
LaunchParams.launchControlFlags% = _launchNoFileFlags + _launchContinue
LaunchParams.launchAppSpec& = AppSpecAddr&
LaunchParams.mylaunchAppParameters& = _nil        '(sends default event)
OSErr = FN LaunchApplication(@LaunchParams)
END FN = OSErr
'--------------------------------------------------------