Cocoa:组件管理器未找到 64 位应用程序中的所有组件

发布于 2025-01-01 23:33:59 字数 1330 浏览 1 评论 0 原文

我正在使用 组件管理器,用于获取已安装组件的列表(我的应用程序是 a视频播放器,我想获取已安装的 QuickTime 编解码器的列表)。

我有这样的代码:

- (void) findComponents
{
    ComponentDescription desc;
    desc.componentType = 0;
    desc.componentSubType = 0;
    desc.componentManufacturer = 0;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;

    long numComps = CountComponents( &desc );
    NSLog( @"found %ld components", numComps );

    Component aComponent = 0;
    while( (aComponent = FindNextComponent( aComponent, &desc) ) ) {
        // Do stuff with this component.
    }
}

当我编译我的应用程序 32 位时,它按我的预期工作(从 CountComponents 返回 927 个组件)。然而,当编译为 64 位时,CountComponents 仅返回 85 个组件(其中没有一个是我正在寻找的 QuickTime 编解码器)。

组件管理器文档没有提及 CountComponents/FindNextComponent 的 64 位问题。值得注意的是(诚然古老)Apple DTS 示例代码此代码所基于的 在编译 64 位时也存在相同的问题。

有什么想法我做错了吗?我不想手动查找组件并解析“thng”资源。

编辑:在 64 位应用程序中,组件管理器是否可能仅列出 64 位组件?在这种情况下,也许可以将此功能内置到 32 位共享库中,并从我的 64 位应用程序中调用?

I'm using Component Manager in a Mac app to get the list of installed components (my app is a video player, and I want to get at the list of of installed QuickTime codecs).

I have code like this:

- (void) findComponents
{
    ComponentDescription desc;
    desc.componentType = 0;
    desc.componentSubType = 0;
    desc.componentManufacturer = 0;
    desc.componentFlags = 0;
    desc.componentFlagsMask = 0;

    long numComps = CountComponents( &desc );
    NSLog( @"found %ld components", numComps );

    Component aComponent = 0;
    while( (aComponent = FindNextComponent( aComponent, &desc) ) ) {
        // Do stuff with this component.
    }
}

When I compile my app 32-bit, it works as I'd expect (927 components come back from CountComponents). However, when compiled 64-bit, CountComponents returns only 85 components (none of which are the QuickTime codecs I'm looking for).

The Component Manager docs don't say anything about 64-bit issues with CountComponents/FindNextComponent. It's worth noting that the (admittedly ancient) Apple DTS sample code upon which this code is based has the same issue when compiled 64-bit.

Any ideas what I'm doing wrong? I don't want to have to resort to manually finding components and parsing 'thng' resources.

EDIT: is it possible that in a 64-bit app, Component Manager is only listing the 64-bit components? In which case, perhaps this functionality could be built into a 32-bit shared library, and called from my 64-bit app?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤寂小茶 2025-01-08 23:33:59

但是,当编译为 64 位时,CountComponents 仅返回 85 个组件(其中没有一个是我正在寻找的 QuickTime 编解码器)。

使用 QuickTime C API 的 QuickTime 编解码器仅限 32 位,Apple 尚未将该 API 移植到 64 位。请注意,在应用程序方面,您可以使用 QTKit,即新的 Objective-C API。 QTKit 尝试使用 QuickTime X 播放电影;如果由于没有合适的 QuickTime X 编解码器可用而无法使用,则会回退到 QuickTime 7,后者又可以使用旧的 QuickTime 组件。这对于使用 QTKit 的开发人员来说是透明的。

在 64 位应用程序中,组件管理器是否可能仅列出 64 位组件?

是的,这是正确的。请注意,不可能在同一进程中混合使用 32 位和 64 位代码,因此组件管理器将查询限制为可以加载到进程中的组件是有道理的:32 位组件用于 32 位组件。位进程,64 位进程的 64 位组件。

在这种情况下,也许可以将此功能内置到 32 位共享库中,并从我的 64 位应用程序调用?

如上所述,您将无法将 32 位动态库加载到 64 位进程上。您可以做的是创建一个单独的 32 位帮助程序可执行文件,并使用它来获取 32 位组件的列表。您可以共享列出主应用程序和帮助程序可执行文件之间的组件的源代码,但它们必须是单独的可执行文件。

事实上,如果您使用 QuickTime X 播放需要 32 位 QuickTime 组件的电影,您可以看到这一点:生成一个 32 位 QTKitServer 进程,以便使用 QuickTime 组件解码电影并将结果发回到 64 位 QuickTime X。 John Siracusa 在他的 Snow Leopard 评论中描述了这一点。您可能还想查看 采用《QTKit 应用程序编程指南》中的 QuickTime X 进行播放部分

However, when compiled 64-bit, CountComponents returns only 85 components (none of which are the QuickTime codecs I'm looking for).

QuickTime codecs that use the QuickTime C API are 32-bit only, and Apple have not ported that API to 64-bit. Note that, application-wise, you can use QTKit, the new Objective-C API. QTKit tries to use QuickTime X to play a movie; if it can’t because there’s no suitable QuickTime X codec available, it falls back to QuickTime 7, which in turn is able to use old QuickTime components. This is transparent for developers that use QTKit.

Is it possible that in a 64-bit app, Component Manager is only listing the 64-bit components?

Yes, that’s correct. Note that it is not possible to mix 32-bit and 64-bit code in the same process, so it makes sense that Component Manager would limit queries to the components that could be loaded onto the process: 32-bit components for a 32-bit process, 64-bit components for a 64-bit process.

In which case, perhaps this functionality could be built into a 32-bit shared library, and called from my 64-bit app?

As described above, you won’t be able to load a 32-bit dynamic library onto a 64-bit process. What you can do is to create a separate 32-bit helper executable and use it to obtain a list of 32-bit components. You can share the source code that list components amongst your main application and the helper executable, but they must be separate executables.

In fact, you can see this in action if you use QuickTime X to play a movie that requires a 32-bit QuickTime component: a 32-bit QTKitServer process is spawned in order to decode the movie using a QuickTime component and send the results back to 64-bit QuickTime X. John Siracusa describes this in his Snow Leopard Review. You may also want to take a look at the Adopting QuickTime X for Playback section in QTKit Application Programming Guide.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文