From: beware Date: Sun, 30 Mar 2008 00:45:46 +0000 (+0000) Subject: git-svn-id: file:///svnroot/lcore/trunk@5 b1de8a11-f9be-4011-bde0-cc7ace90066a X-Git-Url: http://www.lcore.org/git/lcore.git/commitdiff_plain/808a50cfd5b22c3503854d0d71075caec07c53cd?ds=sidebyside;hp=486d5bd497cb900dbab14be07271c47dc1969645 git-svn-id: file:///svnroot/lcore/trunk@5 b1de8a11-f9be-4011-bde0-cc7ace90066a --- 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. +