home *** CD-ROM | disk | FTP | other *** search
Wrap
#ifndef _PROCESSMAP_ #include "CPProcessMap.h" #endif class CPInfo { private: char* buffName; FSSpec buffFSS; ProcessInfoRec theInfo; public: CPInfo(){buffName = new char[32];theInfo.processInfoLength=sizeof(ProcessInfoRec);theInfo.processName=(StringPtr)buffName;theInfo.processAppSpec=&buffFSS;}; ~CPInfo(){delete buffName;}; OSErr GetPInfo(ProcessSerialNumber& thePSN); void QueryInfo(CMyProcess& theProcess); }; OSErr CPInfo::GetPInfo(ProcessSerialNumber& thePSN) { return ::GetProcessInformation(&thePSN, &theInfo); } void CPInfo::QueryInfo(CMyProcess& theProcess) { BlockMoveData(theInfo.processName, theProcess.pName, theInfo.processName[0]+1); theProcess.lStartAddress = (long)theInfo.processLocation; theProcess.lEndAddress = theProcess.lStartAddress + theInfo.processSize; theProcess.thePSN = theInfo.processNumber; } Boolean CPProcessMap::RefreshProcessMap(void) { ProcessSerialNumber thePSN; short sCount; Boolean fDirty=false; if ( ::TickCount() - lLastTick < 60 ) return fDirty; CMyProcess theProcess; CPInfo theInfo; lLastTick = ::TickCount(); sCount = 0; thePSN.highLongOfPSN = 0; thePSN.lowLongOfPSN = kNoProcess; while ( noErr == ::GetNextProcess(&thePSN) && sNumOfProcess < MAX_PROCESS ) { if ( noErr == theInfo.GetPInfo(thePSN) ) { theInfo.QueryInfo(theProcess); if ( false == aProcesses[sCount].IsSameOne(theProcess) ){fDirty = true;aProcesses[sCount]=theProcess;} sCount ++; } } if ( sNumOfProcess != sCount ){fDirty=true;sNumOfProcess=sCount;} return fDirty; }