- return number;
-}
-
-- (void)applicationLaunched:(NSNotification *)note
-{
- NSDictionary *info = [note userInfo];
-
- if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
- iTunesPSN.highLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue];
- iTunesPSN.lowLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidLaunchNotification" object:nil];
- }
-}
-
-- (void)applicationTerminated:(NSNotification *)note
-{
- NSDictionary *info = [note userInfo];
-
- if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
- iTunesPSN.highLongOfPSN = kNoProcess;
- [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidTerminateNotification" object:nil];
+ return number;*/
+ ProcessSerialNumber number;
+ number.highLongOfPSN = kNoProcess;
+ number.lowLongOfPSN = 0;
+
+ while ( (GetNextProcess(&number) == noErr) )
+ {
+ CFStringRef name;
+ if ( (CopyProcessName(&number, &name) == noErr) )
+ {
+ if ([(NSString *)name isEqualToString:@"iTunes"])
+ {
+ return number;
+ }
+ [(NSString *)name release];
+ }