I am looking for a way to get the application icon from a window id in cocoa. Do you have any pointer for this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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, useGetProcessBundleLocation()to get the location of the bundle, switch the FSRef into a path string, and then use-[NSWorkspace iconForFile:]to get the icon.