You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

unitsettc.pas 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. { Copyright (C) 2005 Bas Steendijk and Peter Green
  2. For conditions of distribution and use, see copyright notice in zlib_license.txt
  3. which is included in the package
  4. ----------------------------------------------------------------------------- }
  5. unit Unitsettc;
  6. interface
  7. procedure settc;
  8. procedure unsettc;
  9. implementation
  10. uses
  11. windows,
  12. sysutils;
  13. var
  14. classpriority,threadpriority:integer;
  15. refcount:integer=0;
  16. procedure settc;
  17. var
  18. hprocess,hthread:integer;
  19. begin
  20. if (refcount = 0) then begin
  21. hProcess := GetCurrentProcess;
  22. hThread := GetCurrentThread;
  23. ClassPriority := GetPriorityClass(hProcess);
  24. ThreadPriority := GetThreadPriority(hThread);
  25. SetPriorityClass(hProcess, REALTIME_PRIORITY_CLASS);
  26. SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
  27. end;
  28. inc(refcount);
  29. end;
  30. procedure unsettc;
  31. var
  32. hprocess,hthread:integer;
  33. begin
  34. dec(refcount);
  35. if (refcount < 0) then refcount := 0;
  36. if (refcount = 0) then begin
  37. hProcess := GetCurrentProcess;
  38. hThread := GetCurrentThread;
  39. SetPriorityClass(hProcess, ClassPriority);
  40. SetThreadPriority(hThread, ThreadPriority);
  41. end;
  42. end;
  43. end.