SDK12-1,帮忙看个书上程序,
#include <windows.h>
#include <iostream.h>int main()
{
  SYSTEM_INFO si;
  DWORD dwProc;  GetSystemInfo(&si);
  cout<<"Number of available process:"<<si.dwNumberOfProcessors<<endl;
  for(dwProc = 0; dwProc < si.dwNumberOfProcessors; ++dwProc)
  {
  //发送处理器数目并确定处理器是否是活动的
  //即检测处理器能否接受线程
  cout<<"Processor "<<dwProc;
  if((si.dwActiveProcessorMask&(1<<dwProc)) != 0)//
     cout<<" is active."<<endl;
  else
  cout<<" is inactive."<<endl;
  }
  
  return 0;
}输出:
Number of available process:1
Processor 0 is active.
Press any key to continue
请问,si.dwActiveProcessorMask啥意思?
1<<dwProc这个在这里又是啥意思??

解决方案 »

  1.   

    1<<dwProc :把1左移 dwProc那么多位,这里还是1
    dwActiveProcessorMask这个值中,如果第n位为1那么第n个处理器就是活动状态,可以使用
      

  2.   

    1 .看MSDN SYSTEM_INFO  的结构是什么就知道什么意思了,具体不说了,说了也怕说错
    2。1<<dwProc这个在这里又是啥意思??
    ------  移位操作`
      

  3.   

    MSDN上解释:
    dwActiveProcessorMask 
    Specifies a mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31. Bit 0 is processor 0; bit 31 is processor 31. 这话啥意思?
      

  4.   

    dwActiveProcessorMask是一个DWORD变量,有32位(bit),0-31