diff --git a/PInvoke/Kernel32/SystemTopologyApi.cs b/PInvoke/Kernel32/SystemTopologyApi.cs index f84b8d02..9dc76e48 100644 --- a/PInvoke/Kernel32/SystemTopologyApi.cs +++ b/PInvoke/Kernel32/SystemTopologyApi.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; +using Vanara.Extensions; namespace Vanara.PInvoke { @@ -69,6 +71,29 @@ namespace Vanara.PInvoke /// This member is reserved. private ushort Reserved3; + + /// Gets or sets the affinitized processors in the field as their indexed values. + /// The affinitized processors. + public IEnumerable AffinitizedProcessors + { + get + { + var v = Mask.ToUInt64(); + for (uint i = 0; i < UIntPtr.Size * 8; i++) + { + if ((v & 0x1UL) == 1) + yield return i; + v = v >> 1; + } + } + set + { + var v = 0UL; + foreach (var i in value) + v |= 1UL << (int)i; + Mask = (UIntPtr)v; + } + } } } } \ No newline at end of file