[futurebasic] Re: [FB] Open System Preferences

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2007 : Group Archive : Group : All Groups

From: Bernie <fb.mailing.list@...>
Date: Thu, 22 Feb 2007 07:32:17 +0000
Here are a couple functions to go with Ken's 'LaunchAppByPath'.

If we don't know the path we can launch an app by creator signature  
or by file type extension.

'----------
include "Tlbx LSInfo.incl"
include "Tlbx LSOpen.incl"

local mode
local fn LaunchAppBySignature( signature as OSType )
'~'1
dim as CFURLRef @ url

long if ( fn LSGetApplicationForInfo( 0, signature, ¬
0, _kLSRolesAll, #0, @url ) == _noErr )
call LSOpenCFURLRef( url, #0 )
end if
end fn

local mode
local fn LaunchAppByFileExtension( extension as CFStringRef )
'~'1
dim as CFURLRef @ url

long if ( fn LSGetApplicationForInfo( 0, 0, ¬
extension, _kLSRolesAll, #0, @url ) == _noErr )
call LSOpenCFURLRef( url, #0 )
end if
end fn

fn LaunchAppBySignature( _"sprf" )
fn LaunchAppByFileExtension( fn CFSTR( "webarchive" ) )
'----------

N.B: because some apps may share the same file extension,  
LaunchAppByFileExtension may not reliably launch the desired app.

Bernie