Mac OS X – Cocoa – putting application into background/foreground

BOOL removeFromDock = true;
if (removeFromDock == true) {
  ProcessSerialNumber psn = { 0, kCurrentProcess };
  TransformProcessType(&psn, kProcessTransformToUIElementApplication);
} else {
  ProcessSerialNumber psn = { 0, kCurrentProcess };
  TransformProcessType(&psn, kProcessTransformToForegroundApplication);
}

source: link