使exe优先级低

时间:2009-09-02 03:41:53

标签: c++ executable

如何将.exe作为低优先级运行?我知道我可以去任务管理器,并手动更改优先级设置,但有一种方法可以从.exe文件启动.bat,并带有一个命令,使.exe运行于给定的优先级(在这种情况下是低)? .exe是我用C ++编写的程序;我可以在C ++代码中设置优先级吗?

我正在运行windows xp。

4 个答案:

答案 0 :(得分: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

答案 1 :(得分:4)

要自愿降低您的流程优先级,请使用SetPriorityClass。另请参阅完整的discussion of process and thread priorities

答案 2 :(得分:0)

有关 bobbymcr 发布的START命令的详细信息,请访问以下链接:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/start.mspx?mfr=true

http://forums.whirlpool.net.au/archive/875182

或者您可以运行 cmd.exe ,然后输入: START /?

它将显示有关 START 命令的所有信息。

此致

答案 3 :(得分:0)

您可以在c ++代码中使用此功能

BOOL WINAPI SetPriorityClass( In HANDLE hProcess, In DWORD dwPriorityClass);

hProcess是您的进程的处理程序,可以通过GetCurrentProcess()获取。

表示低优先级设置dwPriorityClass = REALTIME_PRIORITY_CLASS