title: Get application icon from ProcessSerialNumber
body: <p>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 <a href="http://developer.apple.com/mac/library/documentation/Carbon/Reference/Process_Manager/Reference/reference.html" rel="nofollow noreferrer">Process Manager</a> API. I have determined that any process that does not have the <code>modeBackgroundOnly</code> flag set in the <code>processMode</code> (as retrieved from <code>GetProcessInformation()</code>) is a "foreground" application, and shows up in the task switcher window.</p>
  
  <p>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.</p>