Xref: utzoo comp.sys.mac.system:7043 comp.sys.mac.programmer:25610 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!alexr@apple.com From: alexr@apple.com (Alexander M. Rosenberg) Newsgroups: comp.sys.mac.system,comp.sys.mac.programmer Subject: Re: Bringing Finder frontmost after Startup Items run Message-ID: <13900@goofy.Apple.COM> Date: 6 Jun 91 16:50:59 GMT References: <0B01FFFB.hfj14n@outpost.UUCP> Sender: usenet@Apple.COM Organization: Hackers Anonymous Lines: 63 In article <0B01FFFB.hfj14n@outpost.UUCP>, peirce@outpost.UUCP (Michael Peirce) writes: > > PROGRAM FinderFirst; > > USES > Processes; > > FUNCTION GetFinderSerial : ProcessSerialNumber; > VAR > process : ProcessSerialNumber; > infoRec : ProcessInfoRec; > BEGIN {GetFinderSerial} > > WITH process DO BEGIN > highLongOfPSN := 0; > lowLongOfPSN := kNoProcess; > END; > This is interesting. Most Process Manager manipulation code I've seen sets both longs to kNoProcess (which happens to be 0 anyway). > WITH infoRec DO BEGIN > processInfoLength := SIZEOF(ProcessInfoRec); > processName := NIL; > processAppSpec := NIL; > END; > > WHILE (GetNextProcess(process) = noErr) DO BEGIN > IF GetProcessInformation(process,infoRec) = noErr > THEN BEGIN > IF (infoRec.processType = LONGINT('FNDR')) AND > (infoRec.processSignature = 'MACS') > THEN BEGIN > GetFinderSerial := process; > Exit(GetFinderSerial); > END; > END; > END; > You can also safely compare against the name being "Finder". It doesn't get localized. Too many things alreayd depend on the name "Finder" so localizing it was given up on. > END; {GetFinderSerial} > > BEGIN {MAIN} > > IF SetFrontProcess(GetFinderSerial) <> noErr > THEN BEGIN > SysBeep(5); > END; > > END. {MAIN} > --------------------------------------------------------------------------- - Alexander M. Rosenberg - INTERNET: alexr@apple.com - Yoyodyne - - 330 1/2 Waverley St. - UUCP:ucbvax!apple!alexr - Propulsion - - Palo Alto, CA 94301 - - Systems - - (415) 329-8463 - Nobody is my employer so - :-) - - (408) 974-3110 - nobody cares what I say. - -