.net - Why I need to use Public Structure _PROCESSOR_INFO_UNION? -
for need use public structure "_processor_info_union"? without "dwnumberofprocessors" returns 15 instead of real number of processors, when used it's returns 4
imports system.runtime.interopservices public class form1 <dllimport("kernel32.dll")> _ public shared sub getsysteminfo(<marshalas(unmanagedtype.struct)> byref lpsysteminfo system_info) end sub <structlayout(layoutkind.sequential)> _ public structure system_info friend uprocessorinfo _processor_info_union public dwpagesize uinteger public lpminimumapplicationaddress intptr public lpmaximumapplicationaddress intptr public dwactiveprocessormask intptr public dwnumberofprocessors uinteger public dwprocessortype uinteger public dwallocationgranularity uinteger public dwprocessorlevel ushort public dwprocessorrevision ushort end structure <structlayout(layoutkind.explicit)> _ public structure _processor_info_union '<fieldoffset(0)> _ 'friend dwoemid uinteger '<fieldoffset(0)> _ 'friend wprocessorarchitecture ushort '<fieldoffset(2)> _ 'friend wreserved ushort end structure private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim infos new system_info getsysteminfo(infos) textbox2.text = (infos.dwnumberofprocessors) end sub end class
the modern processors can have virtual
cores, , there fore actual number of physical processors found on machine have use such syntax.
i've asked similar question time ago such situation c# code, , there got great answer how invoke it:
Comments
Post a Comment