On 22.03.2009, at 17:27, Pierce Freeman wrote:
 The problem that I see if that every application's icon
name is different and I haven't found a way to read that application's icon
location or will just return a NSImage that is the icon.

Sure you can retrieve NSImages for application icons. Look at NSWorkspace's iconForFile: method and similar ones. Now, changing them, that's a different matter. This used to be able with Carbon's Icon Services APIs, though. There you were able to override an icon with one you provided, e.g. to animate the progress bar on a downloaded file icon. Might want to look into those. Last time I did that was on OS 9 though, so no guarantee whether that's still system- wide these days.

I am wondering if there is some way to change another applications icon
programmatically.


What are you trying to do that you need to do this? Are you trying to change the dock icons of running applications, or what? For that, it might be a better idea to use Accessibility APIs or AppleScript (or maybe even CGWindow APIs work?) to determine the rectangle of the requisite dock tile, and then show your own, transparent window on top?

Have you considered the repercussions of your changes on the developers of the other applications? Consider that, not only would you break any code signing on those apps, and any other checksums they may be using to make sure patches or incremental updates work, you could also trigger other sorts of tamper alerts, or through a bug damage the application whose icon you wanted to change.

Trouble is, the user might not notice until they next launch that other app. And the people who would then have to deal with what your app caused are likely the ones who developed your 'victim' app. After all, many users won't understand that just changing an icon can damage an application, not to mention that some might have forgotten they used your application to change the icon.

We used to get lots of bug reports from people who had used third- party tools to strip Intel code from their universal binary applications to save disk space. They'd done that a while ago, and when they used the migration assistant to move their apps to their new Intel Mac months later, some of them refused to work, and many of them were dog-slow because of issues with Rosetta they wouldn't even have had if they had just run the intel-native code we put in there.

I'm not saying you shouldn't do that, but I just thought I'd make you aware of the backlash that applications that patch others in whatever way can cause. Talk to the guys from Unsanity if you want to know how even people who did a very good job of writing a robust patching engine got hissed at, I'm sure they have a few stories to tell...

Oh, one more thing: If you really just want to change the icon, you may want to look into how Finder applies custom icons to folders. You'd still have to authenticate, but at least you'd be doing a modification that the user can do using the Finder, so it's something application developers can expect. I believe how it's basically done is creating a file with the name "Icon\r" (\r is 0x0D, i.e. a return character, not a newline as in \n or 0x0A) at the top level of the application package, next to the "Contents" folder, and set the kHasCustomIcon flag on the folder. The "Icon\r"-file contains an 'icns' resource with ID -16455 containing the contents of a .icns file.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to