¡¡¡¡½éÉÜ
¡¡¡¡API(Application Programming Interface)£¬ÎÒÏë´ó¼Ò²»»áİÉú£¬ËüÊÇÎÒÃÇWindows±à³ÌµÄ³£¿Í£¬ËäÈ»»ùÓÚ.Netƽ̨µÄC#ÓÐÁËÇ¿´óµÄÀà¿â£¬µ«ÊÇ£¬ÎÒÃÇ»¹ÊDz»ÄÜ·ñÈÏAPIÔÚWindows±à³ÌÖеÄÖØÒªÐÔ¡£´ó¶àÊýµÄ±à³ÌÓïÑÔ¶¼Ö§³ÖAPI±à³Ì£¬¶ø.Netƽ̨ÖеÄMFC£¨Microsoft Foundation Class Library£©¹¹¼Ü±¾Éí¾Í·â×°Á˴󲿷ֵÄAPI¡£
¡¡¡¡×öΪ³ÌÐòÔ±£¬ÎÒÃÇÐèÒªÁ˽âAPI´Ó×ÖÃæÉÏÁ˽â±ãÊDZà³Ì½Ó¿Ú£¬Òò´Ë£¬×öΪ¿ª·¢Õߣ¬ÐèÒªÁ˽âµÄÖ»ÊÇAPIµÄʹÓ÷½·¨¡£
¡¡¡¡API¸ù¾Ý²Ù×÷ϵͳ¡¢´¦ÀíÆ÷¼°¹¦ÄÜÐԵIJ»Í¬¶øÓµÓкܶ಻ͬµÄÀàÐÍ¡£ ¡¡¡¡²Ù×÷ÏµÍ³ÌØÓõÄAPI:
¡¡¡¡Ã¿ÖÖ²Ù×÷ϵͳ¶¼ÓÐÐí¶àͨÓõÄAPIÒÔ¼°Ò»Ð©ÌØÓõÄAPI£¬ÕâÐ©ÌØÓõÄAPIÖ»ÄÜÔÚµ±Ç°²Ù×÷ϵͳÖÐÖ´ÐС£
¡¡¡¡ÀýÈ磺
¡¡¡¡Windows NT Ö§³Ö MS-DOS, Win16, Win32, POSIX (Portable Operating System Interface), OS/2 console API; ¶ø Windows 95 Ö§³Ö MS-DOS, Win16 ÒÔ¼° Win32 APIs.
¡¡¡¡Win16 & Win32 API:
¡¡¡¡Win16ÊÇΪʮÁùλ´¦ÀíÆ÷¿ª·¢µÄ£¬ÔçÆÚµÄ²Ù×÷ϵͳ¾ùÖ§³Ö¡£
¡¡¡¡Win32ÔòÊÇΪ32λ´¦ÀíÆ÷¿ª·¢¡£Ëü¿ÉÒÆÖ²ÐÔÇ¿£¬±»´ó²¿·ÖµÄ´¦ÀíÆ÷ËùÖ§³Ö¡£
¡¡¡¡Win32 APIÔÚ¿âÃûºóÓÐÒ»¸ö¡±32¡±ºó׺¡£±ÈÈçKERNEL32£¬USER32µÈ¡£
¡¡¡¡ËùÓÐAPIÔÚÏÂÃæ3¸ö¿âÖеÃÒÔÔËÐУº
¡¡¡¡Kernel
¡¡¡¡User
¡¡¡¡GDI
¡¡¡¡1. KERNEL
¡¡¡¡ËûµÄ¿âÃûΪ KERNEL32.DLL, ËûÖ÷ÒªÓÃÓÚ²úÉúÓë²Ù×÷ϵͳ֮¼äµÄ¹ØÁª£º
¡¡¡¡³ÌÐò¼ÓÔØ
¡¡¡¡ÉÏÏÂÎÄÑ¡Ôñ.
¡¡¡¡ÎļþÊäÈëÊä³ö.
¡¡¡¡ÄÚ´æ¹ÜÀí.
¡¡¡¡ÀýÈ磺 GlobalMemoryStatus º¯Êý¾Í°üÀ¨µ±Ç°ÎïÀíÄÚ´æ¼°ÐéÄâÄÚ´æµÄʹÓÃÐÅÏ¢¡£
¡¡¡¡2. USER
¡¡¡¡Õâ¸öÀà¿âÔÚWin32ÖÐÃû½Ð USER32.DLL¡£
¡¡¡¡ËüÔÊÐí¹ÜÀíÈ«²¿µÄÓû§½Ó¿Ú£¬±ÈÈ磺
¡¡¡¡´°¿Ú
¡¡¡¡²Ëµ¥
¡¡¡¡¶Ô»°¿ò
¡¡¡¡Í¼±êµÈ.,
¡¡¡¡ÀýÈ磺 DrawIcon º¯Êý½«ÔÚÖ¸¶¨µÄÉ豸¹ØÁªÉÏ¡°»¡±³öͼ±ê»òÕßÊó±ê¡£
¡¡¡¡3. GDI (Graphical Device Interface)
¡¡¡¡ËüÔÚWin32ÖеĿâÃûΪ£ºGDI32.dll£¬ËüÊÇͼÐÎÊä³ö¿â¡£Ê¹ÓÃGDI Windows¡°»¡±³ö´°¿Ú¡¢²Ëµ¥ÒÔ¼°¶Ô»°¿òµÈ£º
¡¡¡¡ËüÄÜ´´½¨Í¼ÐÎÊä³ö.
¡¡¡¡ËüÒ²Äܱ£´æÍ¼ÐÎÎļþ.
¡¡¡¡ÀýÈ磺 CreateBitmap º¯Êý¾ÍÄÜͨ¹ýÖ¸¶¨µÄ³¤¡¢¿í¡¢ÑÕÉ«´´½¨Ò»¸öλͼ¡£
¡¡¡¡C# ÖвÙ×÷API:
¡¡¡¡×÷Ϊ³õѧÕßÀ´Ëµ£¬ÔÚC#ÖÐʹÓÃAPIÈ·ÊÇÒ»¼þÁîÈËÍ·ÌÛµÄÎÊÌâ¡£ÔÚʹÓÃAPIÖ®¼äÄã±ØÐëÖªµÀÈçºÎÔÚC#ÖÐʹÓýṹ¡¢ÀàÐÍת»»¡¢°²È«/²»°²È«´úÂ룬¿É¿Ø/²»¿É¿Ø´úÂëµÈÐí¶à֪ʶ¡£
¡¡¡¡Ò»ÇдӼòµ¥¿ªÊ¼£¬¸´ÔӵĴó¼Òһʱ²»ÄܽÓÊÜ¡£ÎÒÃǾʹÓʵÏÖÒ»¸ö¼òµ¥µÄMessageBox¿ªÊ¼¡£Ê×ÏÈ´ò¿ªVS.Net £¬´´½¨Ò»¸öеÄC#¹¤³Ì£¬²¢Ìí¼ÓÒ»¸öButton°´Å¥¡£µ±Õâ¸ö°´Å¥±»µã»÷£¬ÔòÏÔʾһ¸öMessageBox¶Ô»°¿ò¡£
¡¡¡¡¼´È»ÎÒÃÇÐèÒªÒýÓÃÍâÀ´¿â£¬ËùÒÔ±ØÐëµ¼ÈëÒ»¸öNamespace£º
¡¡¡¡using System.Runtime.InteropServices;
¡¡¡¡½Ó×ÅÌí¼ÓÏÂÃæµÄ´úÂëÀ´ÉùÃ÷Ò»¸öAPI£º
¡¡¡¡[DllImport("User32.dll")]
¡¡¡¡public static extern int MessageBox(int h, string m, string c, int type);
¡¡¡¡´Ë´¦DllImportÊôÐÔ±»ÓÃÀ´´Ó²»¿É¿Ø´úÂëÖе÷ÓÃÒ»·½·¨¡£¡±User32.dll¡±ÔòÉ趨ÁËÀà¿âÃû¡£DllImportÊôÐÔÖ¸¶¨dllµÄλÖã¬Õâ¸ödllÖаüÀ¨µ÷ÓõÄÍⲿ·½·¨¡£StaticÐÞÊηûÔòÉùÃ÷Ò»¸ö¾²Ì¬ÔªËØ£¬¶øÕâ¸öÔªËØÊôÓÚÀàÐͱ¾Éí¶ø²»ÊÇÉÏÃæÖ¸¶¨µÄ¶ÔÏó¡£externÔò±íʾÕâ¸ö·½·¨½«ÔÚ¹¤³ÌÍⲿִÐУ¬Ê¹ÓÃDllImportµ¼ÈëµÄ·½·¨±ØÐëʹÓÃexternÐÞÊηû¡£
¡¡¡¡MessageBox ÔòÊǺ¯ÊýÃû£¬ÓµÓÐ4¸ö²ÎÊý£¬Æä·µ»ØÖµÎªÊý×Ö¡£
¡¡¡¡´ó¶àÊýµÄAPI¶¼ÄÜ´«µÝ²¢·µ»ØÖµ¡£
¡¡¡¡ÌíÖÐClickµã»÷ʼþ´úÂë:
¡¡¡¡protected void button1_Click(object sender, System.EventArgs e)
¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡MessageBox (0,"API Message Box","API Demo",0);
¡¡¡¡}
¡¡¡¡±àÒë²¢ÔËÐÐÕâ¸ö³ÌÐò£¬µ±Äãµã»÷°´Å¥ºó£¬Ä㽫»á¿´µ½¶Ô»°¿ò£¬Õâ±ãÊÇÄãʹÓõÄAPIº¯Êý¡£
¡¡¡¡Ê¹ÓýṹÌå
¡¡¡¡²Ù×÷´øÓнṹÌåµÄAPI±ÈʹÓüòµ¥µÄAPIÒª¸´ÔӵĶࡣµ«ÊÇÒ»µ©ÄãÕÆÎÕÁËAPIµÄ¹ý³Ì£¬ÄǸöÕû¸öAPIÊÀ½ç½«ÔÚÄãµÄÕÆÎÕÖ®ÖС£
¡¡¡¡ÏÂÃæµÄÀý×ÓÖÐÎÒÃǽ«Ê¹ÓÃGetSystemInfo API À´»ñÈ¡Õû¸öϵͳµÄÐÅÏ¢¡£
¡¡¡¡µÚÒ»²½»¹ÊÇ´ò¿ªC#½¨Á¢Ò»¸öForm¹¤³Ì£¬Í¬ÑùµÄÌíÖÐÒ»¸öButton°´Å¥£¬ÔÚ´úÂë´°ÖÐÊäÈëÏÂÃæµÄ´úÂ룬µ¼ÈëNamespace£º
¡¡¡¡using System.Runtime.InteropServices;
¡¡¡¡ÉùÃ÷Ò»¸ö½á¹¹Ì壬Ëü½«×öΪGetSystemInfoµÄÒ»¸ö²ÎÊý£º
¡¡¡¡[StructLayout(LayoutKind.Sequential)]
¡¡¡¡public struct SYSTEM_INFO {
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwOemId;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwPageSize;
¡¡¡¡¡¡¡¡¡¡¡¡public uint lpMinimumApplicationAddress;
¡¡¡¡¡¡¡¡¡¡¡¡public uint lpMaximumApplicationAddress;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwActiveProcessorMask;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwNumberOfProcessors;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorType;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwAllocationGranularity;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorLevel;
¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorRevision;
¡¡¡¡}
¡¡¡¡ÉùÃ÷APIº¯Êý:
¡¡¡¡[DllImport("kernel32")]
¡¡¡¡static extern void GetSystemInfo(ref SYSTEM_INFO pSI);
¡¡¡¡Ìí¼ÓÏÂÃæµÄ´úÂëÖÁ°´Å¥µÄµã»÷ʼþ´¦ÀíÖУº
¡¡¡¡Ê×ÏÈ´´½¨Ò»¸öSYSTEM_INFO½á¹¹Ì壬²¢½«Æä´«µÝ¸øGetSystemInfoº¯Êý¡£
¡¡¡¡protected void button1_Click (object sender, System.EventArgs e)
¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡try
¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SYSTEM_INFO pSI = new SYSTEM_INFO();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetSystemInfo(ref pSI);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡Ò»µ©Äã½ÓÊÕµ½·µ»ØµÄ½á¹¹Ì壬ÄÇô¾Í¿ÉÒÔÒÔ·µ»ØµÄ²ÎÊýÀ´Ö´ÐвÙ×÷ÁË¡£
¡¡¡¡e.g.listBox1.InsertItem (0,pSI.dwActiveProcessorMask.ToString());:
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//
¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡catch(Exception er)
¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MessageBox.Show (er.Message);
¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡}
µ÷ÓÃAPIÈ«²¿´úÂë
¡¡¡¡//Created By Ajit Mungale
¡¡¡¡//³ÌÐò²¹³ä ·Éµ¶
¡¡¡¡namespace UsingAPI
¡¡¡¡{
¡¡¡¡using System;
¡¡¡¡using System.Drawing;
¡¡¡¡using System.Collections;
¡¡¡¡using System.ComponentModel;
¡¡¡¡using System.WinForms;
¡¡¡¡using System.Data;
¡¡¡¡using System.Runtime.InteropServices;
¡¡¡¡//Struct ÊÕ¼¯ÏµÍ³ÐÅÏ¢
¡¡¡¡[StructLayout(LayoutKind.Sequential)]
¡¡¡¡public struct SYSTEM_INFO {
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwOemId;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwPageSize;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint lpMinimumApplicationAddress;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint lpMaximumApplicationAddress;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwActiveProcessorMask;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwNumberOfProcessors;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorType;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwAllocationGranularity;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorLevel;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwProcessorRevision;
¡¡¡¡¡¡¡¡}
¡¡¡¡//struct ÊÕ¼¯ÄÚ´æÇé¿ö
¡¡¡¡[StructLayout(LayoutKind.Sequential)]
¡¡¡¡public struct MEMORYSTATUS
¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwLength;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwMemoryLoad;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwTotalPhys;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwAvailPhys;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwTotalPageFile;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwAvailPageFile;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwTotalVirtual;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡public uint dwAvailVirtual;
¡¡¡¡}
¡¡¡¡public class Form1 : System.WinForms.Form
¡¡¡¡{
¡¡¡¡¡¡¡¡private System.ComponentModel.Container components;
¡¡¡¡¡¡¡¡private System.WinForms.MenuItem menuAbout;
¡¡¡¡¡¡¡¡private System.WinForms.MainMenu mainMenu1;
¡¡¡¡¡¡¡¡private System.WinForms.ListBox listBox1;
¡¡¡¡¡¡¡¡private System.WinForms.Button button1;
¡¡¡¡//»ñȡϵͳÐÅÏ¢
¡¡¡¡¡¡¡¡[DllImport("kernel32")]
¡¡¡¡¡¡¡¡static extern void GetSystemInfo(ref SYSTEM_INFO pSI);
¡¡¡¡¡¡¡¡//»ñÈ¡ÄÚ´æÐÅÏ¢
¡¡¡¡¡¡¡¡[DllImport("kernel32")]
¡¡¡¡¡¡¡¡static extern void GlobalMemoryStatus(ref MEMORYSTATUS buf);
¡¡¡¡¡¡¡¡//´¦ÀíÆ÷ÀàÐÍ
¡¡¡¡¡¡¡¡public const int PROCESSOR_INTEL_386 = 386;
¡¡¡¡¡¡¡¡public const int PROCESSOR_INTEL_486 = 486;
¡¡¡¡¡¡¡¡public const int PROCESSOR_INTEL_PENTIUM = 586;
¡¡¡¡¡¡¡¡public const int PROCESSOR_MIPS_R4000 = 4000;
¡¡¡¡¡¡¡¡public const int PROCESSOR_ALPHA_21064 = 21064;
¡¡¡¡¡¡¡¡public Form1()
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡InitializeComponent();
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡public override void Dispose()
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡base.Dispose();
¡¡¡¡¡¡¡¡¡¡¡¡components.Dispose();
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡private void InitializeComponent()
¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.components = new System.ComponentModel.Container ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.mainMenu1 = new System.WinForms.MainMenu ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.button1 = new System.WinForms.Button ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.listBox1 = new System.WinForms.ListBox ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.menuAbout = new System.WinForms.MenuItem ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡mainMenu1.MenuItems.All = new System.WinForms.MenuItem[1] {this.menuAbout};
¡¡¡¡¡¡¡¡¡¡¡¡¡¡button1.Location = new System.Drawing.Point (148, 168);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡button1.Size = new System.Drawing.Size (112, 32);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡button1.TabIndex = 0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡button1.Text = "&Get Info";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡button1.Click += new System.EventHandler (this.button1_Click);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.Location = new System.Drawing.Point (20, 8);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.Size = new System.Drawing.Size (368, 147);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.TabIndex = 1;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡menuAbout.Text = "&About";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡menuAbout.Index = 0;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡menuAbout.Click += new System.EventHandler (this.menuAbout_Click);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.Text = "System Information - Using API";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.MaximizeBox = false;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.MinimizeBox = false;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.Menu = this.mainMenu1;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.ClientSize = new System.Drawing.Size (408, 213);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.Controls.Add (this.listBox1);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡this.Controls.Add (this.button1);
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡protected void menuAbout_Click (object sender, System.EventArgs e)
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡Form abt=new about() ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡abt.ShowDialog();
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡protected void button1_Click (object sender, System.EventArgs e)
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡try
¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SYSTEM_INFO pSI = new SYSTEM_INFO();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GetSystemInfo(ref pSI);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡string CPUType;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡switch (pSI.dwProcessorType)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡case PROCESSOR_INTEL_386 :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType= "Intel 386";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡break;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡case PROCESSOR_INTEL_486 :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType = "Intel 486" ;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡break;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡case PROCESSOR_INTEL_PENTIUM :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType = "Intel Pentium";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡break;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡case PROCESSOR_MIPS_R4000 :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType = "MIPS R4000";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡break;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡case PROCESSOR_ALPHA_21064 :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType = "DEC Alpha 21064";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡break;
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡default :
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CPUType = "(unknown)";
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (0,"Active Processor Mask :"+pSI.dwActiveProcessorMask.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (1,"Allocation Granularity :"+pSI.dwAllocationGranularity.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (2,"Number Of Processors :"+pSI.dwNumberOfProcessors.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (3,"OEM ID :"+pSI.dwOemId.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (4,"Page Size:"+pSI.dwPageSize.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (5,"Processor Level Value:"+pSI.dwProcessorLevel.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (6,"Processor Revision:"+ pSI.dwProcessorRevision.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (7,"CPU type:"+CPUType);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (8,"Maximum Application Address: "+pSI.lpMaximumApplicationAddress.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem (9,"Minimum Application Address:" +pSI.lpMinimumApplicationAddress.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡/************** ´Ó GlobalMemoryStatus »ñÈ¡·µ»ØÖµ****************/
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MEMORYSTATUS memSt = new MEMORYSTATUS ();
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡GlobalMemoryStatus (ref memSt);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(10,"Available Page File :"+ (memSt.dwAvailPageFile/1024).ToString ());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(11,"Available Physical Memory : " + (memSt.dwAvailPhys/1024).ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(12,"Available Virtual Memory:" + (memSt.dwAvailVirtual/1024).ToString ());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(13,"Size of structur :" + memSt.dwLength.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(14,"Memory In Use :"+ memSt.dwMemoryLoad.ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(15,"Total Page Size :"+ (memSt.dwTotalPageFile/1024).ToString ());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(16,"Total Physical Memory :" + (memSt.dwTotalPhys/1024).ToString());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡listBox1.InsertItem(17,"Total Virtual Memory :" + (memSt.dwTotalVirtual/1024).ToString ());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡catch(Exception er)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MessageBox.Show (er.Message);
¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡public static void Main(string[] args)
¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡try
¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Application.Run(new Form1());
¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡¡¡¡¡¡¡¡¡catch(Exception er)
¡¡¡¡¡¡¡¡¡¡¡¡¡¡{
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MessageBox.Show (er.Message );
¡¡¡¡¡¡¡¡¡¡¡¡¡¡}
¡¡¡¡¡¡}
¡¡¡¡}
}