⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch4_14.cs

📁 《c#技术内幕代码》
💻 CS
字号:
using System;
using System.Runtime.InteropServices;


class CH4_14
{
   [System.Runtime.InteropServices.StructLayoutAttribute (LayoutKind.Sequential, CharSet=CharSet.Auto)]
   public struct _SYSTEM_INFO
   { 
      public int dwOemID; 
      public int dwPageSize;
      public int lpMinimumApplicationAddress; 
      public int lpMaximumApplicationAddress; 
      public int dwActiveProcessorMask; 
      public int dwNumberOfProcessors;
      public int dwProcessorType;
      public int dwAllocationGranularity;
      public short wProcessorLevel;
      public short wProcessorRevision;
   }

   [sysimport(dll="Kernel32.dll")]
      unsafe private static extern void GetSystemInfo([marshal(UnmanagedType.LPVoid)]uint* bufptr);
   
   public static unsafe void Main()
   {
       try
       {
          _SYSTEM_INFO si = new _SYSTEM_INFO();
          GetSystemInfo( (uint *)&si );
          Console.WriteLine("Processor Type = {0}", si.dwProcessorType );
          Console.WriteLine("Number of Processors = {0}", si.dwNumberOfProcessors );
          Console.WriteLine("Processor Level = {0}", si.wProcessorLevel );
          Console.WriteLine("Processor Revision = {0}", si.wProcessorRevision );
       }
       catch ( Exception e )
       {
          Console.WriteLine("Exception Caught! {0}", e );
       }
   }
   
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -