const Frequency = 5000;//每隔五秒鐘整理一次內存,速度很快的 :) var TimerID: Integer; InProc: Boolean;
procedure SaveMemory; begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin //整理內存 SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF); end; end;
//定時器要執行的回調函數 procedure HearBeatProc(Wnd: HWnd; Msg, Event, dwTime: Integer); stdcall; begin if (InProc = False) then begin InProc := True; try SaveMemory; finally InProc := False; end; end; end;