2012-05-31 34 views

回答

3

的WINAPI有一個名爲CreateProcess()功能,允許優先級的規格:

 
dwCreationFlags [in] 

    The flags that control the priority class and the creation of the process. 
For a list of values, see Process Creation Flags. 

    This parameter also controls the new process's priority class, which 
is used to determine the scheduling priorities of the process's threads. 
For a list of values, see GetPriorityClass. If none of the priority class 
flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS 
unless the priority class of the creating process is IDLE_PRIORITY_CLASS 
or BELOW_NORMAL_PRIORITY_CLASS. In this case, the child process receives 
the default priority class of the calling process. 
2

您可以在應用程序的主線程中使用SetThreadPriority函數()

1

我認爲這是一個更完整的答案:

三個不同的選項(這些不是步驟):

  • 期間CreateProcess,指定進程優先級CLASS(單個線程優先級從進程優先級派生)。
  • 啓動應用程序後,使用SetPriorityClass。這可以讓您隨意更改優先級CLASS。
  • 通過SetThreadPriority更改單個線程優先級。這些按照「基礎」優先級CLASS進行升降。

有關更多信息,請參見MSDN。

相關問題