peirce@outpost.UUCP (Michael Peirce) (06/06/91)
In article <18154@venera.isi.edu>, jas@ISI.EDU (Jeff Sullivan) writes: > In article <1991Jun4.155851.23146@mmm.serc.3m.com> pejacoby@mmm.serc.3m.com (Paul E. Jacoby) writes: > > >In article <0B01FFFB.gwbpcl@outpost.UUCP> peirce@outpost.UUCP (Michael Peirce) writes: > >> > >>In article <1991May30.142809.10293@umiami.ir.miami.edu>, dweisman@umiami.ir.miami.edu (Ordinary Man) writes: > >>> There's a real cheap way to get the finder to the front without any > >>> inits or other apps running. Just put an alias to your hard drive in the > >> > >>Sounds like a better way than a special app. So maybe I won't post > >>my little hack (harumph, my first System 7 specific App is worthless :-) > >>-- michael > > Right. > > >And Michael, why don't you release your hack anyway? We can ALWAYS use > >more neato utilities for 7.0! > >-- > > Why in hell would you want to promote the spread of hacks into the > system when you can already do what the hack does? Just spreads > possible incompatibilities. Who's talking about spreading possible incompatibilies to the system? The process manager is fully documented in Inside Macintosh Volume VI. Everything you need to know to write this "hack" is there. No trap patching or other "bad things". I was using the term HACK to mean a quick and elegant little program that gets the job done. This is the good connotation of this word, not the bad. Sort of like describing myself as a hacker. I don't mean I break into systems and steal national security secrets, but rather I enjoy playing around with the system and exploring its secrets - helping me do a better job for my clients and myself. -- michael P.S. Here's the WHOLE program that does this, simply compile in into an Application (or an MPW tool, that works too for easy testing). It works as is, but it doesn't have any UI and this might confuse people who run across it not knowing what it's for. If someone wants to run with this, please give some sort of UI. Thanks. PROGRAM FinderFirst; USES Processes; FUNCTION GetFinderSerial : ProcessSerialNumber; VAR process : ProcessSerialNumber; infoRec : ProcessInfoRec; BEGIN {GetFinderSerial} WITH process DO BEGIN highLongOfPSN := 0; lowLongOfPSN := kNoProcess; END; 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; END; {GetFinderSerial} BEGIN {MAIN} IF SetFrontProcess(GetFinderSerial) <> noErr THEN BEGIN SysBeep(5); END; END. {MAIN} -- Michael Peirce -- outpost!peirce@claris.com -- Peirce Software -- Suite 301, 719 Hibiscus Place -- Macintosh Programming -- San Jose, California 95117 -- & Consulting -- (408) 244-6554, AppleLink: PEIRCE
alexr@apple.com (Alexander M. Rosenberg) (06/06/91)
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. - -