HardwareInfoDlg.cpp
上传用户:xsxdsb
上传日期:2009-12-14
资源大小:672k
文件大小:2k
- // HardwareInfoDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "HardwareInfoDemo.h"
- #include "HardwareInfoDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CHardwareInfoDlg dialog
- CHardwareInfoDlg::CHardwareInfoDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CHardwareInfoDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CHardwareInfoDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CHardwareInfoDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CHardwareInfoDlg)
- DDX_Control(pDX, IDC_STATIC_MEMORY, m_Memory);
- DDX_Control(pDX, IDC_STATIC_CPUTYPE, m_CpuType);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CHardwareInfoDlg, CDialog)
- //{{AFX_MSG_MAP(CHardwareInfoDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CHardwareInfoDlg message handlers
- BOOL CHardwareInfoDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- CString DisplayString;
- SYSTEM_INFO SystemInfo;
-
- //检测CPU的类型
- ::GetSystemInfo(&SystemInfo); //WinAPI函数,用以取得系统信息
- if(SystemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
- {
- switch (SystemInfo.wProcessorLevel)
- {
- //本程序只演示取得Intel系列CPU的方法
- // ……
- //省略对386及486机器的检测
- case 5:
- DisplayString = "Pentium";
- break;
- case 6:
- DisplayString = "Pentium (II/Pro)";
- break;
- }
- }
- m_CpuType.SetWindowText(DisplayString); //变量m_CpuType是一个CStatic框
- //检测内存状态
- MEMORYSTATUS MemoryStatus; //内存的现行状态结构
- MemoryStatus.dwLength = sizeof(MEMORYSTATUS); //填充结构的大小
- ::GlobalMemoryStatus(&MemoryStatus); //取得内存的状态
- char buffer[20];
- wsprintf(buffer,"%d bytes",MemoryStatus.dwTotalPhys);//dwTotalPhys指示物理内存字节
- m_Memory.SetWindowText(buffer); //变量m_Memory是一个CStatic框
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }