User666
User666

Reputation: 131

Access struct in union

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

In the structure above how do I access/change MaxRate? I get ControlFlags like so:

JOBOBJECT_CPU_RATE_CONTROL_INFORMATION cpu;
cpu.ControlFlags = JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP;

Upvotes: 1

Views: 123

Answers (1)

Igor Tandetnik
Igor Tandetnik

Reputation: 52611

In my copy of winnt.h header, the struct is defined as follows:

typedef struct _JOBOBJECT_CPU_RATE_CONTROL_INFORMATION {
    DWORD ControlFlags;
    union {
        DWORD CpuRate;
        DWORD Weight;
    };
} JOBOBJECT_CPU_RATE_CONTROL_INFORMATION, *PJOBOBJECT_CPU_RATE_CONTROL_INFORMATION;

There is indeed no MinRate or MaxRate. My guess is, they might have been added in some later version of the SDK (I only have VC2013 handy at the moment).

Look into getting a fresher copy of the SDK. Meanwhile, LOWORD(CpuRate) and HIWORD(CpuRate) should do.

Upvotes: 4

Related Questions