<p>一般来说,这些都是通过<em>苹果事件</em>来处理的。特别是,您的应用程序将收到一个<em>打开文档</em>事件。如何处理它取决于您编写的应用程序的类型。在</p>
<p>如果您正在编写一个基于文档的应用程序,这很简单:文档控制器接收到一条<code>openDocumentWithContentsOfURL:display:error:</code>消息(对于pre-Tiger系统,<code>openDocumentWithContentsOfFile:display:</code>),并将<a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocumentController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocumentController/openDocumentWithContentsOfURL:display:error:" rel="nofollow noreferrer">handle this accordingly</a>。在</p>
<p>对于不基于文档的Cocoa应用程序,将向应用程序委托发送一条<code>application:openFiles:</code>消息。如果委托没有对此做出响应,它将尝试发送其他消息,直到代理响应一条消息(<code>openTempFile:</code>,<code>openFiles:</code>,和{<cd6>},按顺序排列)。在</p>
<p><a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_handle_AEs/SAppsHandleAEs.html#//apple_ref/doc/uid/20001239-1119823" rel="nofollow noreferrer">Here's the documentation</a>用于在Cocoa中处理打开的苹果事件。在</p>
<p>对于Carbon应用程序,我真的记不起细节了(自从我写了Carbon代码以来已经有一段时间了),但是如果我没记错的话,您应该为带有<code>AEInstallEventHandler()</code>的<code>kAEOpenDocuments</code>事件安装一个Apple事件处理程序。有关详细信息,请参见<a href="http://developer.apple.com/documentation/Carbon/Reference/Apple_Event_Manager/Reference/reference.html#//apple_ref/c/func/AEInstallEventHandler" rel="nofollow noreferrer">the documentation</a>。在</p>