processortypedlg.cpp
来自「windows ce开发技巧与实例光盘代码」· C++ 代码 · 共 122 行
CPP
122 行
// ProcessorTypeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ProcessorType.h"
#include "ProcessorTypeDlg.h"
#include <winioctl.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CProcessorTypeDlg dialog
CProcessorTypeDlg::CProcessorTypeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CProcessorTypeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProcessorTypeDlg)
m_strMessage = _T("");
m_strConclusion = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProcessorTypeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProcessorTypeDlg)
DDX_Text(pDX, IDC_STATIC_MESSAGE, m_strMessage);
DDX_Text(pDX, IDC_STATIC_CONCLUSION, m_strConclusion);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProcessorTypeDlg, CDialog)
//{{AFX_MSG_MAP(CProcessorTypeDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProcessorTypeDlg message handlers
#ifdef __cplusplus
extern "C" {
#endif
BOOL KernelIoControl(DWORD dwIoControlCode, LPVOID lpInBuf, DWORD nInBufSize, LPVOID lpOutBuf, DWORD nOutBufSize, LPDWORD lpBytesReturned);
#ifdef __cplusplus
}
#endif
#define IOCTL_PROCESSOR_INFORMATION CTL_CODE(FILE_DEVICE_HAL, 25, METHOD_BUFFERED, FILE_ANY_ACCESS)
// Used by IOCTL_PROCESSOR_INFORMATION
typedef struct _PROCESSOR_INFO {
WORD wVersion;
WCHAR szProcessCore[40];
WORD wCoreRevision;
WCHAR szProcessorName[40];
WORD wProcessorRevision;
WCHAR szCatalogNumber[100];
WCHAR szVendor[100];
DWORD dwInstructionSet;
DWORD dwClockSpeed;
} PROCESSOR_INFO;
typedef PROCESSOR_INFO *PPROCESSOR_INFO;
BOOL CProcessorTypeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
PROCESSOR_INFO pi;
DWORD dwBytesReturned;
DWORD dwSize = sizeof(PROCESSOR_INFO);
BOOL bResult = KernelIoControl(IOCTL_PROCESSOR_INFORMATION, NULL, 0, &pi, sizeof(PROCESSOR_INFO), &dwBytesReturned);
if (bResult)
{
CString strProcessorInfo;
strProcessorInfo.Format(_T(" Version: %d\n Processor Core: %s\n Core revision: %d\n Processor Name: %s\n Processor revision: %d\n Catalog number : %s\n Vendor: %s\n Instruction set: %d\n Clock speed: %d"),
pi.wVersion,
pi.szProcessCore,
pi.wCoreRevision,
pi.szProcessorName,
pi.wProcessorRevision,
pi.szCatalogNumber,
pi.szVendor,
pi.dwInstructionSet,
pi.dwClockSpeed);
m_strMessage = strProcessorInfo;
if (_tcsstr(pi.szProcessorName, _T("PXA")) > 0)
m_strConclusion = _T("This is definitely XScale processor");
else
m_strConclusion = _T("This is not XScale processor");
}
else
{
m_strMessage = _T("Your device does not support PROCESSOR_INFORMATION query. \nSorry");
m_strConclusion = _T("You might be running it on Pocket PC emulator");
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?