2009-09-02 95 views
1

如何將.exe作爲低優先級運行?我知道我可以去任務管理器,並手動更改那裏的優先級設置,但有沒有辦法可以從.bat文件啓動.exe,並使命令使.exe以給定優先級運行(在這種情況下爲低)? .exe是我用C++編寫的程序;我可以在C++代碼中設置優先級嗎?使exe優先級低

我正在運行windows xp。

回答

7

在一個批處理文件,你可以使用start命令:

Starts a separate window to run a specified program or command. 

START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] 
     [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] 
     [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program] 
     [parameters] 

[ . . . ] 

    LOW   Start application in the IDLE priority class 
    NORMAL  Start application in the NORMAL priority class 
    HIGH  Start application in the HIGH priority class 
    REALTIME Start application in the REALTIME priority class 
    ABOVENORMAL Start application in the ABOVENORMAL priority class 
    BELOWNORMAL Start application in the BELOWNORMAL priority class 
+0

非常感謝你! – 2009-09-02 12:41:02

0

,你可以在你的C++代碼

BOOL WINAPI SetPriorityClass的頂部使用此功能( HANDLE hProcess, DWORD dwPriorityClass);

hProcess是您的進程的處理程序,它可以通過GetCurrentProcess()獲取。

低優先級集dwPriorityClass = REALTIME_PRIORITY_CLASS