[futurebasic] Re: [FB] LaunchURL

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

From: Robert Purves <listrp@...>
Date: Fri, 26 Oct 2007 19:18:03 +1300
On 26/10/2007, at 6:00 PM, Brian Stevens wrote:

> My preferred method is via launch services and works fine with FBtoC.
>
> local fn LSLaunchURL( urlStr as str255 )
> '~'1
> dim as OSStatus  stat
> dim as CFURLRef  urlRef
>
> urlRef = fn CFURLCreateWithString( _nil, fn CFSTR( urlStr ), _nil )
> long if ( urlRef )
> stat = fn LSOpenCFURLRef( urlRef, #_nil )
> CFRelease( urlRef )
> end if
>
> end fn = stat


I think that would be better written as:


include "Tlbx LSOpen.incl"
toolbox fn CFURLCreateWithString( CFAllocatorRef allocator,  
CFStringRef URLString, CFURLRef baseURL ) = CFURLRef

local fn LSLaunchURL( urlStr as Str255 )
'~'1
dim as OSStatus err
dim as CFStringRef urlCFStr
dim as CFURLRef urlRef

err = _paramErr // default error
urlCFStr = fn CFStringCreateWithPascalString( _kCFAllocatorDefault,  
@urlStr, _kCFStringEncodingASCII )
long if ( urlCFStr)
urlRef = fn CFURLCreateWithString( _kCFAllocatorDefault, urlCFStr, 0 )
CFRelease( urlCFStr )
long if ( urlRef )
err = fn LSOpenCFURLRef( urlRef, #0 )
CFRelease( urlRef )
end if
end if
end fn = err


Robert P.