typedef struct _JOBOBJECT_CPU_RATE_CONTROL_INFORMATION {
DWORD ControlFlags;
union {
DWORD CpuRate;
DWORD Weight;
struct {
WORD MinRate;
WORD MaxRate;
};
};
} JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, *PJOBOBJECT_CPU_RATE_CONTROL_INFORMATION;
https://msdn.microsoft.com/en-us/library/windows/desktop/hh448384.aspx
在上面的结构中,如何访问/更改MaxRate?我这样得到ControlFlags:
JOBOBJECT_CPU_RATE_CONTROL_INFORMATION cpu;
cpu.ControlFlags = JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP;
答案 0 :(得分:4)
在我的winnt.h
标题副本中,结构定义如下:
typedef struct _JOBOBJECT_CPU_RATE_CONTROL_INFORMATION {
DWORD ControlFlags;
union {
DWORD CpuRate;
DWORD Weight;
};
} JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, *PJOBOBJECT_CPU_RATE_CONTROL_INFORMATION;
确实没有MinRate
或MaxRate
。我的猜测是,它们可能已经在SDK的某个更高版本中添加了(我目前只有VC2013方便)。
了解获取SDK的更新版本。同时,LOWORD(CpuRate)
和HIWORD(CpuRate)
应该这样做。