I am looking for a way to get the application icon from a window id in cocoa. Do you have any pointer for this?
+3
A:
First, use CGWindowListCreateDescriptionFromArray()
to get the PID of the owning process (kCGWindowOwnerPID
). If this is 10.6, you can then use +[NSRunningApplication runningApplicationWithProcessIdentifier:]
to get the application object and then use -icon
.
Before 10.6, you need to use GetProcessForPID()
to switch to a PSN, use GetProcessBundleLocation()
to get the location of the bundle, switch the FSRef into a path string, and then use -[NSWorkspace iconForFile:]
to get the icon.
Rob Napier
2010-07-25 15:49:41
very well detailled. Thanks!
AP
2010-07-25 18:12:14