--- /dev/null
+{ Copyright (C) 2005 Bas Steendijk and Peter Green\r
+ For conditions of distribution and use, see copyright notice in zlib_license.txt\r
+ which is included in the package\r
+ ----------------------------------------------------------------------------- }\r
+\r
+unit Unitsettc;\r
+\r
+interface\r
+\r
+procedure settc;\r
+procedure unsettc;\r
+\r
+implementation\r
+\r
+uses\r
+ windows,\r
+ sysutils;\r
+\r
+var\r
+ classpriority,threadpriority:integer;\r
+ refcount:integer=0;\r
+\r
+procedure settc;\r
+var\r
+ hprocess,hthread:integer;\r
+begin\r
+ if (refcount = 0) then begin\r
+ hProcess := GetCurrentProcess;\r
+ hThread := GetCurrentThread;\r
+ ClassPriority := GetPriorityClass(hProcess);\r
+ ThreadPriority := GetThreadPriority(hThread);\r
+ SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS);\r
+ SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);\r
+ end;\r
+ inc(refcount);\r
+end;\r
+\r
+procedure unsettc;\r
+var\r
+ hprocess,hthread:integer;\r
+begin\r
+ dec(refcount);\r
+ if (refcount < 0) then refcount := 0;\r
+ if (refcount = 0) then begin\r
+ hProcess := GetCurrentProcess;\r
+ hThread := GetCurrentThread;\r
+ SetPriorityClass(hProcess, ClassPriority);\r
+ SetThreadPriority(hThread, ThreadPriority);\r
+ end;\r
+end;\r
+\r
+end.\r
+\r