📄 virtmem.c
字号:
OnSysManSize(PVIRTMEM pVirtMem)
{
/* Disable the page file custom size boxes */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
}
static VOID
OnCustom(PVIRTMEM pVirtMem)
{
/* Enable the page file custom size boxes */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
}
static VOID
OnSet(PVIRTMEM pVirtMem)
{
INT Index;
pVirtMem->bSave = TRUE;
Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
IDC_PAGEFILELIST,
LB_GETCURSEL,
0,
0);
if(Index < pVirtMem->Count)
{
TCHAR szText[255];
/* check if custom settings are checked */
if(SendDlgItemMessage(pVirtMem->hSelf,
IDC_CUSTOM,
BM_GETCHECK,
0,
0) == BST_CHECKED)
{
SendDlgItemMessage(pVirtMem->hSelf,
IDC_INITIALSIZE,
WM_GETTEXT,
254,
(LPARAM)szText);
pVirtMem->Pagefile[Index].InitialValue = _ttoi(szText);
SendDlgItemMessage(pVirtMem->hSelf,
IDC_MAXSIZE,
WM_GETTEXT,
254,
(LPARAM)szText);
pVirtMem->Pagefile[Index].MaxValue = _ttoi(szText);
}
else
{
/* set sizes to 0 */
pVirtMem->Pagefile[Index].InitialValue = pVirtMem->Pagefile[Index].MaxValue = 0;
// check to see if this drive is used for a paging file
if (SendDlgItemMessage(pVirtMem->hSelf,
IDC_NOPAGEFILE,
BM_GETCHECK,
0,
0) == BST_UNCHECKED)
{
pVirtMem->Pagefile[Index].bUsed = TRUE;
}
else
{
pVirtMem->Pagefile[Index].bUsed = FALSE;
}
}
}
}
static BOOL
OnSelChange(PVIRTMEM pVirtMem,
LPNMLISTVIEW pnmv)
{
TCHAR szCustVals[255];
INT Index;
UNREFERENCED_PARAMETER(pnmv);
Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
IDC_PAGEFILELIST,
LB_GETCURSEL,
0,
0);
if(Index < pVirtMem->Count)
{
if(pVirtMem->Pagefile[Index].InitialValue != 0 &&
pVirtMem->Pagefile[Index].MaxValue != 0)
{
/* enable and fill the custom values */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
_itot(pVirtMem->Pagefile[Index].InitialValue , szCustVals, 10);
SendDlgItemMessage(pVirtMem->hSelf,
IDC_INITIALSIZE,
WM_SETTEXT,
0,
(LPARAM)szCustVals);
_itot(pVirtMem->Pagefile[Index].MaxValue, szCustVals, 10);
SendDlgItemMessage(pVirtMem->hSelf,
IDC_MAXSIZE,
WM_SETTEXT,
0,
(LPARAM)szCustVals);
SendDlgItemMessage(pVirtMem->hSelf,
IDC_CUSTOM,
BM_SETCHECK,
1,
0);
}
else
{
/* It's not a custom value */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
/* is it system managed */
if(pVirtMem->Pagefile[Index].bUsed)
{
SendDlgItemMessage(pVirtMem->hSelf,
IDC_SYSMANSIZE,
BM_SETCHECK,
1,
0);
}
else
{
SendDlgItemMessage(pVirtMem->hSelf,
IDC_NOPAGEFILE,
BM_SETCHECK,
1,
0);
}
}
}
return TRUE;
}
static VOID
OnOk(PVIRTMEM pVirtMem)
{
if(pVirtMem->bSave == TRUE)
{
WritePageFileSettings(pVirtMem);
}
if (pVirtMem->szPagingFiles)
HeapFree(GetProcessHeap(),
0,
pVirtMem->szPagingFiles);
HeapFree(GetProcessHeap(),
0,
pVirtMem);
}
static VOID
OnCancel(PVIRTMEM pVirtMem)
{
if (pVirtMem->szPagingFiles)
HeapFree(GetProcessHeap(),
0,
pVirtMem->szPagingFiles);
HeapFree(GetProcessHeap(),
0,
pVirtMem);
}
static PVIRTMEM
OnInitDialog(HWND hwnd)
{
PVIRTMEM pVirtMem = (PVIRTMEM)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(VIRTMEM));
if (pVirtMem == NULL)
{
EndDialog(hwnd, 0);
}
pVirtMem->hSelf = hwnd;
pVirtMem->hListView = GetDlgItem(hwnd, IDC_PAGEFILELIST);
pVirtMem->bSave = FALSE;
SetListViewColumns(pVirtMem->hListView);
/* Load the pagefile systems from the reg */
if (ReadPageFileSettings(pVirtMem))
{
/* Parse our settings and set up dialog */
ParseMemSettings(pVirtMem);
}
return pVirtMem;
}
INT_PTR CALLBACK
VirtMemDlgProc(HWND hwndDlg,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
/* there can only be one instance of this dialog */
static PVIRTMEM pVirtMem = NULL;
UNREFERENCED_PARAMETER(lParam);
switch (uMsg)
{
case WM_INITDIALOG:
pVirtMem = OnInitDialog(hwndDlg);
break;
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDCANCEL:
OnCancel(pVirtMem);
EndDialog(hwndDlg, 0);
return TRUE;
case IDOK:
OnOk(pVirtMem);
EndDialog(hwndDlg, 0);
return TRUE;
case IDC_NOPAGEFILE:
OnNoPagingFile(pVirtMem);
return TRUE;
case IDC_SYSMANSIZE:
OnSysManSize(pVirtMem);
return TRUE;
case IDC_CUSTOM:
OnCustom(pVirtMem);
return TRUE;
case IDC_SET:
OnSet(pVirtMem);
return TRUE;
}
}
break;
case WM_NOTIFY:
{
LPNMHDR pnmhdr = (LPNMHDR)lParam;
switch (pnmhdr->code)
{
case LVN_ITEMCHANGED:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
OnSelChange(pVirtMem, pnmv);
}
}
}
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -