📄 testmemorydivisiondlg.cpp
字号:
// TestMemoryDivisionDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TestMemoryDivision.h"
#include "TestMemoryDivisionDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestMemoryDivisionDlg dialog
CTestMemoryDivisionDlg::CTestMemoryDivisionDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestMemoryDivisionDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestMemoryDivisionDlg)
m_nStorage = 0;
m_nRam = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestMemoryDivisionDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestMemoryDivisionDlg)
DDX_Control(pDX, IDC_MEM_SLIDER, m_memSlider);
DDX_Text(pDX, IDC_STORAGE, m_nStorage);
DDX_Text(pDX, IDC_RAM, m_nRam);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestMemoryDivisionDlg, CDialog)
//{{AFX_MSG_MAP(CTestMemoryDivisionDlg)
ON_BN_CLICKED(IDC_SET, OnSet)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestMemoryDivisionDlg message handlers
typedef BOOL (__stdcall *GetSystemMemoryDivisionProc)(LPDWORD,LPDWORD,LPDWORD);
typedef DWORD (__stdcall *SetSystemMemoryDivisionProc)(DWORD);
BOOL CTestMemoryDivisionDlg::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
ReadMemoryDivision();
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestMemoryDivisionDlg::OnSet()
{
int nStoragePages = m_memSlider.GetPos();
HINSTANCE hCoreDll = LoadLibrary(_T("coredll.dll"));
SetSystemMemoryDivisionProc procSet =
(SetSystemMemoryDivisionProc)GetProcAddress(hCoreDll, _T("SetSystemMemoryDivision"));
DWORD dwResult = procSet(nStoragePages);
::FreeLibrary(hCoreDll);
switch (dwResult) {
case 0:
AfxMessageBox(_T("Memory division is changed."));
break;
case 1:
AfxMessageBox(_T("The device must be rebooted before memory division changes will be accepted."));
break;
case 2:
AfxMessageBox(_T("The device must be reboted after the previous changes."));
break;
case 3:
AfxMessageBox(_T("Memory division changes are failed."));
break;
}
ReadMemoryDivision();
}
void CTestMemoryDivisionDlg::ReadMemoryDivision()
{
HINSTANCE hCoreDll = LoadLibrary(_T("coredll.dll"));
GetSystemMemoryDivisionProc procGet =
(GetSystemMemoryDivisionProc)GetProcAddress(hCoreDll, _T("GetSystemMemoryDivision"));
DWORD dwStoragePages;
DWORD dwRamPages;
DWORD dwPageSize;
BOOL bResult = procGet(&dwStoragePages, &dwRamPages, &dwPageSize);
m_nStorage = dwStoragePages*dwPageSize/1024;
m_nRam = dwRamPages*dwPageSize/1024;
m_memSlider.SetRange(0, dwStoragePages+dwRamPages);
m_memSlider.SetPos(dwStoragePages);
UpdateData(FALSE);
::FreeLibrary(hCoreDll);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -