请问,如何设置一个进程运行的优先权(即特权 privilege)?

解决方案 »

  1.   

    哦,是使用
    SetPriorityClass()来设置进程的优先级
      

  2.   

    reference to MSDN:
    OpenProcessToken
    AdjustTokenPrivileges
      

  3.   

    Platform SDK: DLLs, Processes, and Threads 
    Process Security and Access Rights
    Windows NT/Windows 2000 security enables you to control access to process objects. For more information about security, see Access-Control Model.You can specify a security descriptor for a process when you call the CreateProcess, CreateProcessAsUser, or CreateProcessWithLogonW function. To retrieve a process's security descriptor, call the GetSecurityInfo function. To change a process's security descriptor, call the SetSecurityInfo function. notice to the last sentence ,it says that you can call "GetSecurityInfo" function to figure out your problem.
      

  4.   

    oho.....sorry .I typed wrong ..should be 'SetSecurityInfo'
      

  5.   

    HANDLE hProcess = GetCurrentProcess();
    // Get the priority class for your process,commonly ,this value is 32(#define NORMAL_PRIORITY_CLASS       0x00000020)
    DWORD dwPriorityClass = GetPriorityClass(hProcess);
    // Set the high priority class for the specified process 
    SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS);