4

More or less everything is in the title, I am looking for a way to get from a cocoa application, pid_t of the running dock.app.

Thanks in advance for your help.

Chetan
  • 46,743
  • 31
  • 106
  • 145
AP.
  • 5,205
  • 7
  • 50
  • 94
  • 1
    What do you mean? sorry Englsh is not my native language. – AP. Jun 27 '10 at 16:57
  • 3
    @AP he means "Why do you need to know?". Usually you need the `pid_t` of an app in order to manipulate the process, and manipulating the Dock is usually not a Good Idea™. – Dave DeLong Jun 27 '10 at 17:06

1 Answers1

5

If you are running Mac OS X 10.6, then you can give a try to the runningApplications method of NSWorkspace:

NSArray *appList = [[NSWorkspace sharedWorkspace] runningApplications];

It will return an array of NSRunningApplication. Look up for Dock.app and use the processIdentifier property.

You can also take a look at the AppList sample application.

Laurent Etiemble
  • 27,111
  • 5
  • 56
  • 81
  • 6
    +1, except that it'd be smarter to look for an `NSRunningApplication` with the `com.apple.dock` bundle identifier, rather than `Dock.app` – Dave DeLong Jun 27 '10 at 16:16