If you are using Mac OS X 10.6, you can try the runningApplications NSWorkspace method:
NSArray *appList = [[NSWorkspace sharedWorkspace] runningApplications];
It will return an NSRunningApplication array. Find Dock.app and use the processIdentifier property.
You can also see an example AppList application.
source share