getMemorySize=function(exefile){//讀取進程中程序使用內存大小 import process GetProcessMemoryInfo = ::Psapi.api("GetProcessMemoryInfo","int(pointer hProcess,struct& ppsmemCounters,int cb)") PROCESS_MEMORY_COUNTERS= class{ int cb; int PageFaultCount; int PeakWorkingSetSize; //物理內存的最大值 int WorkingSetSize; //物理內存的大小 int QuotaPeakPagedPoolUsage; int QuotaPagedPoolUsage; int QuotaPeakNonPagedPoolUsage; int QuotaNonPagedPoolUsage; int PagefileUsage; //虛擬內存大小 int PeakPagefileUsage; //虛擬內存的最大值 } mem=PROCESS_MEMORY_COUNTERS() for processEntry in process.each(exefile) { prc=process(processEntry.th32ProcessID) try{ GetProcessMemoryInfo(prc.handle,mem,raw.sizeof(mem)) io.print(processEntry.szExeFile + " 內存使用:",mem.WorkingSetSize/1024 ++ "K") } } } io.open() getMemorySize(".*.exe")