[Pythonmac-SIG] Help: how to programmatically set "open with" app in OSX
Dan Brotsky
dev@brotsky.com
Tue, 31 Dec 2002 10:19:36 -0800
On Monday, December 30, 2002, at 12:04 PM, Jack Jansen wrote:
>> It's private LaunchServices API, unfortunately. From doing 'nm
>> LaunchServices' it appears what you want is probably
>> _LSSetWeakBindingForType.
There's a great utility I use to do this kind of stuff called XRay
<http://www.brockerhoff.net/xray> by Rainer Brockerhoff
<rainer@brockerhoff.net>. Doing nm of the XRay app also shows that it
uses _LSSetWeakBindingForType (as well as the undocumented
_LSGet/SetStrongBindingForRef); having looked at the XRay UI I suspect
whoever suggested this is on the right track. You might just ask
Rainer if he'd be willing to send you the prototype he discovered for
using it.
> Bah. And is there a way to send an AppleScript command to the finder
> (or maybe something else? A preference panel? A shell interface?) to
> accomplish this?
The Finder's GetInfo window seems to work based on type and creator
using the old DT database; I don't think there's a way to set
extension-based defaults there.
> Adobe Acrobat Reader does seem to have a way to do this. At least:
> when you fire up a new Acrobat Reader for the first time it tells you
> it isn't the default app for pdf files, and whether you want to change
> that. Would they be using the private LS API, or would they have found
> some other way of doing this?
I'm pretty sure Acrobat uses the DT database as well: whatever they do
doesn't apply to files with a PDF extension but an unknown type/creator
combo. Also Acrobat is a PEF app, so I doubt it uses LaunchServices at
all (except, of course, in its plst resource).
dan