GetProcessGroupAffinity function (processtopologyapi.h)

Retrieves the processor group affinity of the specified process.

Syntax

BOOL GetProcessGroupAffinity(
  [in]      HANDLE  hProcess,
  [in, out] PUSHORT GroupCount,
  [out]     PUSHORT GroupArray
);

Parameters

[in] hProcess

A handle to the process.

This handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.

[in, out] GroupCount

On input, specifies the number of elements in GroupArray array. On output, specifies the number of processor groups written to the array. If the array is too small, the function fails with ERROR_INSUFFICIENT_BUFFER and sets the GroupCount parameter to the number of elements required.

[out] GroupArray

An array of processor group numbers. A group number is included in the array if a thread in the process is assigned to a processor in the group.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, use GetLastError.

If the error value is ERROR_INSUFFICIENT_BUFFER, the GroupCount parameter contains the required buffer size in number of elements.

Remarks

Starting with Windows 11 and Windows Server 2022, on a system with more than 64 processors, process and thread affinities span all processors in the system, across all processor groups, by default.

To compile an application that uses this function, set _WIN32_WINNT >= 0x0601. For more information, see Using the Windows Headers.

Requirements

Requirement Value
Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header processtopologyapi.h (include Windows.h on Windows Server 2008 Windows Server 2008 R2)
Library Kernel32.lib
DLL Kernel32.dll

See also

GetThreadGroupAffinity

Processor Groups