Edit AllPages

Here are some useful private APIs for manipulating the Menu Extras currently in the menu bar:

typedef struct _OpaqueMenuExtra OpaqueMenuExtra; OSStatus CoreMenuExtraGetMenuExtra(CFStringRef identifier, OpaqueMenuExtra **menuExtraOut); OSStatus CoreMenuExtraAddMenuExtra(CFURLRef path, SInt32 position, void *_0, void *_1, void *_2, void *_3); OSStatus CoreMenuExtraRemoveMenuExtra(OpaqueMenuExtra *menuExtraIn, void *_0);

I’m curious to know where these declarations come from. –boredzo

It would appear to be from these mailing list posts:

� ElliottCable:

Update: I had to modify the signatures to shut up some compiler warnings; I updated the above signatures to the ones that worked for me.

Note carefully! CoreMenuExtraGetMenuExtra() does take a metapointer to an _OpaqueMenuExtra, whereas CoreMenuExtraRemoveMenuExtra() takes a simple pointer: you must indirect one extra time for CoreMenuExtraGetMenuExtra(), as in the following example code (extracted from MacUIM: )

void *extra; if ((CoreMenuExtraGetMenuExtra((CFStringRef)extraID, &extra) == 0) && extra) CoreMenuExtraRemoveMenuExtra(extra, 0);