从ProcessSerialNumber获取应用程序图标 [英] Get application icon from ProcessSerialNumber

查看:624
本文介绍了从ProcessSerialNumber获取应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得在我的Mac上运行的所有前台应用程序的应用程序图标。我已经使用对所有应用程序进行迭代Process Manager API。我确定任何没有 modeBackgroundOnly 标志设置在 processMode (从 GetProcessInformation())是一个前台应用程序,并显示在任务切换器窗口中。

I would like to get the application icon for all foreground applications running on my Mac. I'm already iterating over all applications using the Process Manager API. I have determined that any process that does not have the modeBackgroundOnly flag set in the processMode (as retrieved from GetProcessInformation()) is a "foreground" application, and shows up in the task switcher window.

API,它给我一个包含进程的应用程序图标的CImageRef(或类似的)。

All I need is an API that gives me a CImageRef (or similar) that contains the application icon for a process. I'm free to use either carbon or cocoa APIs.

推荐答案

在Mac OS X 10.6或更高版本上,您可以问正在运行的应用程序的图标

On Mac OS X 10.6 or later, you can ask a running application for its icon.

在早期版本的Mac OS X上,您必须通过查看应用程序的捆绑包。将PSN传递到 GetProcessBundleLocation 函数来获取包的位置为 FSRef ,然后传递给 GetIconRefFromFileInfo 函数

On earlier versions of Mac OS X, you'll have to get it by looking at the application's bundle. Pass the PSN to the GetProcessBundleLocation function to get the bundle's location as an FSRef, then pass that to the GetIconRefFromFileInfo function.

这篇关于从ProcessSerialNumber获取应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆