From 808a50cfd5b22c3503854d0d71075caec07c53cd Mon Sep 17 00:00:00 2001 From: beware Date: Sun, 30 Mar 2008 00:45:46 +0000 Subject: [PATCH] git-svn-id: file:///svnroot/lcore/trunk@5 b1de8a11-f9be-4011-bde0-cc7ace90066a --- unitsettc.pas | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 unitsettc.pas diff --git a/unitsettc.pas b/unitsettc.pas new file mode 100644 index 0000000..7dc1229 --- /dev/null +++ b/unitsettc.pas @@ -0,0 +1,53 @@ +{ Copyright (C) 2005 Bas Steendijk and Peter Green + For conditions of distribution and use, see copyright notice in zlib_license.txt + which is included in the package + ----------------------------------------------------------------------------- } + +unit Unitsettc; + +interface + +procedure settc; +procedure unsettc; + +implementation + +uses + windows, + sysutils; + +var + classpriority,threadpriority:integer; + refcount:integer=0; + +procedure settc; +var + hprocess,hthread:integer; +begin + if (refcount = 0) then begin + hProcess := GetCurrentProcess; + hThread := GetCurrentThread; + ClassPriority := GetPriorityClass(hProcess); + ThreadPriority := GetThreadPriority(hThread); + SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS); + SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); + end; + inc(refcount); +end; + +procedure unsettc; +var + hprocess,hthread:integer; +begin + dec(refcount); + if (refcount < 0) then refcount := 0; + if (refcount = 0) then begin + hProcess := GetCurrentProcess; + hThread := GetCurrentThread; + SetPriorityClass(hProcess, ClassPriority); + SetThreadPriority(hThread, ThreadPriority); + end; +end; + +end. + -- 2.30.2