KeQueryMaximumProcessorCount function (wdm.h)

The KeQueryMaximumProcessorCount routine returns the maximum number of processors.


ULONG KeQueryMaximumProcessorCount();

Return value

KeQueryMaximumProcessorCount returns the maximum number of processors as a ULONG value.


The value returned by the KeQueryMaximumProcessorCount routine does not change at runtime.

If your code uses an array of buffers, one buffer for each processor, you must decide whether to have a statically sized array based on KeQueryMaximumProcessorCount or a dynamically sized array based on KeQueryActiveProcessorCount.

To optimize based on the number of processors, you need a resizable structure for Windows Server 2008. In this case, use KeQueryActiveProcessorCount.

If you are not optimizing and if the data structures that result from using maximum processor count are relatively small, a resizable structure is not necessary. In this case, use KeQueryMaximumProcessorCount to determine size for a static array.

Windows 7 and later versions of Windows support processor groups. Drivers that are designed to handle information about processor groups should use the KeQueryMaximumProcessorCountEx routine, which specifies a processor group, instead of KeQueryMaximumProcessorCount, which does not. However, the implementation of KeQueryMaximumProcessorCount in Windows 7 and later versions of Windows provides compatibility for drivers that were written for earlier versions of Windows, which do not support processor groups. In this implementation, KeQueryMaximumProcessorCount returns the maximum number of logical processors that can be in group 0.


Requirement Value
Minimum supported client Available in Windows Vista and later versions of Windows.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL Any level

See also