进程与线程(三)进线程的优先级操作

 //无聊下,贴完这个看R3下线程同步了
1 int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) 
  2 { 
  3     _tsetlocale(LC_ALL,_T("chs") ); 
  4     ::system("title ReturnsMe的win32api测试程序");  
  5 
  6     //改变优先级,先判断是否是normal 
  7     if (GetPriorityClass(GetCurrentProcess()) == NORMAL_PRIORITY_CLASS) 
  8     { 
  9         //判断进程优先级是否可变 
 10         BOOL bDisablePriorityBoost; 
 11         GetProcessPriorityBoost(GetCurrentProcess(),&bDisablePriorityBoost); 
 12         if (bDisablePriorityBoost == FALSE) 
 13         { 
 14             //可变,变成idle级 
 15             wprintf(_T("normal,change it to idle \n")); 
 16             SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS); 
 17         } 
 18 
 19     } 
 20     else 
 21         wprintf(_T("not normal,exit \n")); 
 22 
 23     system("pause"); 
 24 
 25     return 0; 
 26 }


你可能感兴趣的:(win32sdk)