Priority.inl 761 B

12345678910111213141516171819202122232425
  1. class CSetPriority {
  2. public:
  3. DWORD sp_dwProcessOld;
  4. int sp_iThreadOld;
  5. HANDLE sp_hThread;
  6. HANDLE sp_hProcess;
  7. CSetPriority(DWORD dwProcess, int iThread)
  8. {
  9. sp_hProcess = GetCurrentProcess();
  10. sp_hThread = GetCurrentThread();
  11. sp_dwProcessOld = GetPriorityClass(sp_hProcess);
  12. sp_iThreadOld = GetThreadPriority(sp_hThread);
  13. BOOL bSuccessProcess = SetPriorityClass(sp_hProcess, dwProcess);
  14. BOOL bSuccessThread = SetThreadPriority(sp_hThread, iThread);
  15. ASSERT(bSuccessProcess && bSuccessThread);
  16. }
  17. ~CSetPriority(void)
  18. {
  19. BOOL bSuccessProcess = SetPriorityClass(sp_hProcess, sp_dwProcessOld);
  20. BOOL bSuccessThread = SetThreadPriority(sp_hThread, sp_iThreadOld);
  21. ASSERT(bSuccessProcess && bSuccessThread);
  22. }
  23. };