* Sync up to trunk HEAD (r62975).
[reactos.git] / dll / cpl / sysdm / virtmem.c
1 /*
2 * PROJECT: ReactOS system properties, control panel applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/sysdm/virtual.c
5 * PURPOSE: Virtual memory control dialog
6 * COPYRIGHT: Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
7 *
8 */
9
10 #include "precomp.h"
11
12 static BOOL OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem);
13 static LPCTSTR lpKey = _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Memory Management");
14
15 static BOOL
16 ReadPageFileSettings(PVIRTMEM pVirtMem)
17 {
18 HKEY hkey = NULL;
19 DWORD dwType;
20 DWORD dwDataSize;
21 BOOL bRet = FALSE;
22
23 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
24 lpKey,
25 0,
26 NULL,
27 REG_OPTION_NON_VOLATILE,
28 KEY_QUERY_VALUE,
29 NULL,
30 &hkey,
31 NULL) == ERROR_SUCCESS)
32 {
33 if (RegQueryValueEx(hkey,
34 _T("PagingFiles"),
35 NULL,
36 &dwType,
37 NULL,
38 &dwDataSize) == ERROR_SUCCESS)
39 {
40 pVirtMem->szPagingFiles = (LPTSTR)HeapAlloc(GetProcessHeap(),
41 0,
42 dwDataSize);
43 if (pVirtMem->szPagingFiles != NULL)
44 {
45 ZeroMemory(pVirtMem->szPagingFiles,
46 dwDataSize);
47 if (RegQueryValueEx(hkey,
48 _T("PagingFiles"),
49 NULL,
50 &dwType,
51 (PBYTE)pVirtMem->szPagingFiles,
52 &dwDataSize) == ERROR_SUCCESS)
53 {
54 bRet = TRUE;
55 }
56 }
57 }
58 }
59
60 if (!bRet)
61 ShowLastWin32Error(pVirtMem->hSelf);
62
63 if (hkey != NULL)
64 RegCloseKey(hkey);
65
66 return bRet;
67 }
68
69
70 static VOID
71 GetPageFileSizes(LPTSTR lpPageFiles,
72 LPINT lpInitialSize,
73 LPINT lpMaximumSize)
74 {
75 INT i = 0;
76
77 *lpInitialSize = -1;
78 *lpMaximumSize = -1;
79
80 while (*lpPageFiles != _T('\0'))
81 {
82 if (*lpPageFiles == _T(' '))
83 {
84 lpPageFiles++;
85
86 switch (i)
87 {
88 case 0:
89 *lpInitialSize = (INT)_ttoi(lpPageFiles);
90 i = 1;
91 break;
92
93 case 1:
94 *lpMaximumSize = (INT)_ttoi(lpPageFiles);
95 return;
96 }
97 }
98
99 lpPageFiles++;
100 }
101 }
102
103
104 static VOID
105 ParseMemSettings(PVIRTMEM pVirtMem)
106 {
107 TCHAR szDrives[1024]; // All drives
108 LPTSTR DrivePtr = szDrives;
109 TCHAR szDrive[3]; // Single drive
110 TCHAR szVolume[MAX_PATH + 1];
111 INT MinSize;
112 INT MaxSize;
113 INT DriveLen;
114 INT PgCnt = 0;
115 INT Len;
116
117 DriveLen = GetLogicalDriveStrings(1023,
118 szDrives);
119
120 while (DriveLen != 0)
121 {
122 Len = lstrlen(DrivePtr) + 1;
123 DriveLen -= Len;
124
125 DrivePtr = _tcsupr(DrivePtr);
126
127 /* Copy the 'X:' portion */
128 lstrcpyn(szDrive, DrivePtr, sizeof(szDrive) / sizeof(TCHAR));
129
130 if (GetDriveType(DrivePtr) == DRIVE_FIXED)
131 {
132 MinSize = -1;
133 MaxSize = -1;
134
135 /* Does drive match the one in the registry ? */
136 if (!_tcsncmp(pVirtMem->szPagingFiles, szDrive, 2))
137 {
138 GetPageFileSizes(pVirtMem->szPagingFiles,
139 &MinSize,
140 &MaxSize);
141 }
142
143 pVirtMem->Pagefile[PgCnt].OldMinSize = MinSize;
144 pVirtMem->Pagefile[PgCnt].OldMaxSize = MaxSize;
145 pVirtMem->Pagefile[PgCnt].NewMinSize = MinSize;
146 pVirtMem->Pagefile[PgCnt].NewMaxSize = MaxSize;
147 pVirtMem->Pagefile[PgCnt].bUsed = TRUE;
148 lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive);
149
150
151 /* Get the volume label if there is one */
152 if (GetVolumeInformation(DrivePtr,
153 szVolume,
154 MAX_PATH + 1,
155 NULL,
156 NULL,
157 NULL,
158 NULL,
159 0))
160 {
161 pVirtMem->Pagefile[PgCnt].pszVolume = HeapAlloc(GetProcessHeap(),
162 0,
163 (_tcslen(szVolume) + 1) * sizeof(TCHAR));
164 if (pVirtMem->Pagefile[PgCnt].pszVolume != NULL)
165 _tcscpy(pVirtMem->Pagefile[PgCnt].pszVolume, szVolume);
166 }
167
168 PgCnt++;
169 }
170
171 DrivePtr += Len;
172 }
173
174 pVirtMem->Count = PgCnt;
175 }
176
177
178 static VOID
179 WritePageFileSettings(PVIRTMEM pVirtMem)
180 {
181 HKEY hk = NULL;
182 TCHAR szPagingFiles[2048];
183 TCHAR szText[256];
184 INT i, nPos = 0;
185 BOOL bErr = TRUE;
186
187 for (i = 0; i < pVirtMem->Count; ++i)
188 {
189 if (pVirtMem->Pagefile[i].bUsed &&
190 pVirtMem->Pagefile[i].NewMinSize != -1 &&
191 pVirtMem->Pagefile[i].NewMaxSize != -1)
192 {
193 _stprintf(szText,
194 _T("%s\\pagefile.sys %i %i"),
195 pVirtMem->Pagefile[i].szDrive,
196 pVirtMem->Pagefile[i].NewMinSize,
197 pVirtMem->Pagefile[i].NewMaxSize);
198
199 /* Add it to our overall registry string */
200 lstrcpy(szPagingFiles + nPos, szText);
201
202 /* Record the position where the next string will start */
203 nPos += (INT)lstrlen(szText) + 1;
204
205 /* Add another NULL for REG_MULTI_SZ */
206 szPagingFiles[nPos] = _T('\0');
207 nPos++;
208 }
209 }
210
211 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
212 lpKey,
213 0,
214 NULL,
215 REG_OPTION_NON_VOLATILE,
216 KEY_WRITE,
217 NULL,
218 &hk,
219 NULL) == ERROR_SUCCESS)
220 {
221 if (RegSetValueEx(hk,
222 _T("PagingFiles"),
223 0,
224 REG_MULTI_SZ,
225 (LPBYTE) szPagingFiles,
226 (DWORD) nPos * sizeof(TCHAR)) == ERROR_SUCCESS)
227 {
228 bErr = FALSE;
229 }
230
231 RegCloseKey(hk);
232 }
233
234 if (bErr == FALSE)
235 {
236 /* Delete obsolete paging files on the next boot */
237 for (i = 0; i < 26; i++)
238 {
239 if (pVirtMem->Pagefile[i].OldMinSize != -1 &&
240 pVirtMem->Pagefile[i].NewMinSize == -1)
241 {
242 _stprintf(szText,
243 _T("%s\\pagefile.sys"),
244 pVirtMem->Pagefile[i].szDrive);
245
246 MoveFileEx(szText, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
247 }
248 }
249 }
250
251 if (bErr)
252 ShowLastWin32Error(pVirtMem->hSelf);
253
254 }
255
256
257 static VOID
258 SetListBoxColumns(HWND hwndListBox)
259 {
260 RECT rect = {0, 0, 103, 0};
261 MapDialogRect(hwndListBox, &rect);
262
263 SendMessage(hwndListBox, LB_SETTABSTOPS, (WPARAM)1, (LPARAM)&rect.right);
264 }
265
266
267 static VOID
268 OnNoPagingFile(PVIRTMEM pVirtMem)
269 {
270 /* Disable the page file custom size boxes */
271 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
272 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
273 }
274
275
276 static VOID
277 OnSysManSize(PVIRTMEM pVirtMem)
278 {
279 /* Disable the page file custom size boxes */
280 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
281 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
282 }
283
284
285 static VOID
286 OnCustom(PVIRTMEM pVirtMem)
287 {
288 /* Enable the page file custom size boxes */
289 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
290 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
291 }
292
293
294 static VOID
295 InitPagefileList(PVIRTMEM pVirtMem)
296 {
297 TCHAR szDisplayString[256];
298 TCHAR szSize[64];
299 INT Index;
300 INT i;
301
302 for (i = 0; i < 26; i++)
303 {
304 if (pVirtMem->Pagefile[i].bUsed)
305 {
306 if ((pVirtMem->Pagefile[i].NewMinSize == -1) &&
307 (pVirtMem->Pagefile[i].NewMaxSize == -1))
308 {
309 LoadString(hApplet,
310 IDS_PAGEFILE_NONE,
311 szSize,
312 sizeof(szSize) / sizeof(szSize[0]));
313 }
314 else if ((pVirtMem->Pagefile[i].NewMinSize == 0) &&
315 (pVirtMem->Pagefile[i].NewMaxSize == 0))
316 {
317 LoadString(hApplet,
318 IDS_PAGEFILE_SYSTEM,
319 szSize,
320 sizeof(szSize) / sizeof(szSize[0]));
321 }
322 else
323 {
324 _stprintf(szSize, _T("%d - %d"),
325 pVirtMem->Pagefile[i].NewMinSize,
326 pVirtMem->Pagefile[i].NewMaxSize);
327 }
328
329 _stprintf(szDisplayString,
330 _T("%s [%s]\t%s"),
331 pVirtMem->Pagefile[i].szDrive,
332 pVirtMem->Pagefile[i].pszVolume ? pVirtMem->Pagefile[i].pszVolume : _T(""),
333 szSize);
334
335 Index = SendMessage(pVirtMem->hListBox, LB_ADDSTRING, (WPARAM)0, (LPARAM)szDisplayString);
336 SendMessage(pVirtMem->hListBox, LB_SETITEMDATA, Index, i);
337 }
338 }
339
340 SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)0, (LPARAM)0);
341
342 OnSelChange(pVirtMem->hSelf, pVirtMem);
343 }
344
345
346 static VOID
347 UpdatePagefileEntry(PVIRTMEM pVirtMem,
348 INT ListIndex,
349 INT DriveIndex)
350 {
351 TCHAR szDisplayString[256];
352 TCHAR szSize[64];
353
354 if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == -1) &&
355 (pVirtMem->Pagefile[DriveIndex].NewMaxSize == -1))
356 {
357 LoadString(hApplet,
358 IDS_PAGEFILE_NONE,
359 szSize,
360 sizeof(szSize) / sizeof(szSize[0]));
361 }
362 else if ((pVirtMem->Pagefile[DriveIndex].NewMinSize == 0) &&
363 (pVirtMem->Pagefile[DriveIndex].NewMaxSize == 0))
364 {
365 LoadString(hApplet,
366 IDS_PAGEFILE_SYSTEM,
367 szSize,
368 sizeof(szSize) / sizeof(szSize[0]));
369 }
370 else
371 {
372 _stprintf(szSize,
373 _T("%d - %d"),
374 pVirtMem->Pagefile[DriveIndex].NewMinSize,
375 pVirtMem->Pagefile[DriveIndex].NewMaxSize);
376 }
377
378 _stprintf(szDisplayString,
379 _T("%s [%s]\t%s"),
380 pVirtMem->Pagefile[DriveIndex].szDrive,
381 pVirtMem->Pagefile[DriveIndex].pszVolume ? pVirtMem->Pagefile[DriveIndex].pszVolume : L"",
382 szSize);
383
384 SendMessage(pVirtMem->hListBox, LB_DELETESTRING, (WPARAM)ListIndex, 0);
385 SendMessage(pVirtMem->hListBox, LB_INSERTSTRING, (WPARAM)ListIndex, (LPARAM)szDisplayString);
386 SendMessage(pVirtMem->hListBox, LB_SETCURSEL, (WPARAM)ListIndex, 0);
387 }
388
389
390 static VOID
391 OnSet(PVIRTMEM pVirtMem)
392 {
393 INT Index;
394 UINT MinSize = -1;
395 UINT MaxSize = -1;
396 BOOL bTranslated;
397 INT DriveIndex = 0;
398
399 Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
400 IDC_PAGEFILELIST,
401 LB_GETCURSEL,
402 0,
403 0);
404 if (Index >= 0 && Index < pVirtMem->Count)
405 {
406 DriveIndex = SendDlgItemMessage(pVirtMem->hSelf,
407 IDC_PAGEFILELIST,
408 LB_GETITEMDATA,
409 0,
410 0);
411
412 /* Check if custom settings are checked */
413 if (IsDlgButtonChecked(pVirtMem->hSelf,
414 IDC_CUSTOM) == BST_CHECKED)
415 {
416 MinSize = GetDlgItemInt(pVirtMem->hSelf,
417 IDC_INITIALSIZE,
418 &bTranslated,
419 FALSE);
420 if (!bTranslated)
421 {
422 ResourceMessageBox(hApplet,
423 NULL,
424 MB_ICONWARNING | MB_OK,
425 IDS_MESSAGEBOXTITLE,
426 IDS_WARNINITIALSIZE);
427 return;
428 }
429
430 MaxSize = GetDlgItemInt(pVirtMem->hSelf,
431 IDC_MAXSIZE,
432 &bTranslated,
433 FALSE);
434 if (!bTranslated)
435 {
436 ResourceMessageBox(hApplet,
437 NULL,
438 MB_ICONWARNING | MB_OK,
439 IDS_MESSAGEBOXTITLE,
440 IDS_WARNMAXIMUMSIZE);
441 return;
442 }
443
444 /* Check the valid range of the minimum size */
445 if (MinSize < 2 ||
446 MinSize > pVirtMem->Pagefile[DriveIndex].FreeSize)
447 {
448 ResourceMessageBox(hApplet,
449 NULL,
450 MB_ICONWARNING | MB_OK,
451 IDS_MESSAGEBOXTITLE,
452 IDS_WARNINITIALRANGE);
453 return;
454 }
455
456 /* Check the valid range of the maximum size */
457 if (MaxSize < MinSize ||
458 MaxSize > pVirtMem->Pagefile[DriveIndex].FreeSize)
459 {
460 ResourceMessageBox(hApplet,
461 NULL,
462 MB_ICONWARNING | MB_OK,
463 IDS_MESSAGEBOXTITLE,
464 IDS_WARNMAXIMUMRANGE);
465 return;
466 }
467
468 pVirtMem->Pagefile[DriveIndex].NewMinSize = MinSize;
469 pVirtMem->Pagefile[DriveIndex].NewMaxSize = MaxSize;
470 pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
471 }
472 else if (IsDlgButtonChecked(pVirtMem->hSelf,
473 IDC_NOPAGEFILE) == BST_CHECKED)
474 {
475 /* No pagefile */
476 pVirtMem->Pagefile[DriveIndex].NewMinSize = -1;
477 pVirtMem->Pagefile[DriveIndex].NewMaxSize = -1;
478 pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
479 }
480 else
481 {
482 /* System managed size*/
483 pVirtMem->Pagefile[DriveIndex].NewMinSize = 0;
484 pVirtMem->Pagefile[DriveIndex].NewMaxSize = 0;
485 pVirtMem->Pagefile[DriveIndex].bUsed = TRUE;
486 }
487
488 /* Set the modified flag if min or max size has changed */
489 if ((pVirtMem->Pagefile[DriveIndex].OldMinSize != pVirtMem->Pagefile[DriveIndex].NewMinSize) ||
490 (pVirtMem->Pagefile[DriveIndex].OldMaxSize != pVirtMem->Pagefile[DriveIndex].NewMaxSize))
491 pVirtMem->bModified = TRUE;
492
493 UpdatePagefileEntry(pVirtMem, Index, DriveIndex);
494 }
495 }
496
497
498 static BOOL
499 OnSelChange(HWND hwndDlg, PVIRTMEM pVirtMem)
500 {
501 TCHAR szBuffer[64];
502 MEMORYSTATUSEX MemoryStatus;
503 ULARGE_INTEGER FreeDiskSpace;
504 UINT /*i,*/ FreeMemMb /*, PageFileSizeMb*/;
505 INT Index;
506
507 Index = (INT)SendDlgItemMessage(hwndDlg,
508 IDC_PAGEFILELIST,
509 LB_GETCURSEL,
510 0,
511 0);
512 if (Index >= 0 && Index < pVirtMem->Count)
513 {
514 /* Set drive letter */
515 SetDlgItemText(hwndDlg, IDC_DRIVE,
516 pVirtMem->Pagefile[Index].szDrive);
517
518 /* Set available disk space */
519 if (GetDiskFreeSpaceEx(pVirtMem->Pagefile[Index].szDrive,
520 NULL, NULL, &FreeDiskSpace))
521 {
522 pVirtMem->Pagefile[Index].FreeSize = (UINT)(FreeDiskSpace.QuadPart / (1024 * 1024));
523 _stprintf(szBuffer, _T("%u MB"), pVirtMem->Pagefile[Index].FreeSize);
524 SetDlgItemText(hwndDlg, IDC_SPACEAVAIL, szBuffer);
525 }
526
527 if (pVirtMem->Pagefile[Index].NewMinSize == -1 &&
528 pVirtMem->Pagefile[Index].NewMaxSize == -1)
529 {
530 /* No pagefile */
531
532 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
533 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
534
535 CheckDlgButton(pVirtMem->hSelf, IDC_NOPAGEFILE, BST_CHECKED);
536 }
537 else if (pVirtMem->Pagefile[Index].NewMinSize == 0 &&
538 pVirtMem->Pagefile[Index].NewMaxSize == 0)
539 {
540 /* System managed size*/
541
542 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
543 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
544
545 CheckDlgButton(pVirtMem->hSelf, IDC_SYSMANSIZE, BST_CHECKED);
546 }
547 else
548 {
549 /* Custom size */
550
551 /* Enable and fill the custom values */
552 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
553 EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
554
555 SetDlgItemInt(pVirtMem->hSelf,
556 IDC_INITIALSIZE,
557 pVirtMem->Pagefile[Index].NewMinSize,
558 FALSE);
559
560 SetDlgItemInt(pVirtMem->hSelf,
561 IDC_MAXSIZE,
562 pVirtMem->Pagefile[Index].NewMaxSize,
563 FALSE);
564
565 CheckDlgButton(pVirtMem->hSelf,
566 IDC_CUSTOM,
567 BST_CHECKED);
568 }
569
570 /* Set minimum pagefile size */
571 SetDlgItemText(hwndDlg, IDC_MINIMUM, _T("2 MB"));
572
573 /* Set recommended pagefile size */
574 MemoryStatus.dwLength = sizeof(MEMORYSTATUSEX);
575 if (GlobalMemoryStatusEx(&MemoryStatus))
576 {
577 FreeMemMb = (UINT)(MemoryStatus.ullTotalPhys / (1024 * 1024));
578 _stprintf(szBuffer, _T("%u MB"), FreeMemMb + (FreeMemMb / 2));
579 SetDlgItemText(hwndDlg, IDC_RECOMMENDED, szBuffer);
580 }
581
582 /* Set current pagefile size */
583 #if 0
584 PageFileSizeMb = 0;
585 for (i = 0; i < 26; i++)
586 {
587 PageFileSizeMb += pVirtMem->Pagefile[i].InitialSize;
588 }
589 _stprintf(szBuffer, _T("%u MB"), PageFileSizeMb);
590 SetDlgItemText(hwndDlg, IDC_CURRENT, szBuffer);
591 #endif
592 }
593
594 return TRUE;
595 }
596
597
598 static VOID
599 OnOk(PVIRTMEM pVirtMem)
600 {
601 if (pVirtMem->bModified == TRUE)
602 {
603 ResourceMessageBox(hApplet,
604 NULL,
605 MB_ICONINFORMATION | MB_OK,
606 IDS_MESSAGEBOXTITLE,
607 IDS_INFOREBOOT);
608
609 WritePageFileSettings(pVirtMem);
610 }
611 }
612
613
614 static VOID
615 OnInitDialog(HWND hwnd, PVIRTMEM pVirtMem)
616 {
617 INT i;
618
619 pVirtMem->hSelf = hwnd;
620 pVirtMem->hListBox = GetDlgItem(hwnd, IDC_PAGEFILELIST);
621 pVirtMem->bModified = FALSE;
622
623 SetListBoxColumns(pVirtMem->hListBox);
624
625 for (i = 0; i < 26; i++)
626 {
627 pVirtMem->Pagefile[i].bUsed = FALSE;
628 pVirtMem->Pagefile[i].OldMinSize = -1;
629 pVirtMem->Pagefile[i].OldMaxSize = -1;
630 pVirtMem->Pagefile[i].NewMinSize = -1;
631 pVirtMem->Pagefile[i].NewMaxSize = -1;
632 }
633
634 /* Load the pagefile systems from the reg */
635 ReadPageFileSettings(pVirtMem);
636
637 /* Parse our settings and set up dialog */
638 ParseMemSettings(pVirtMem);
639
640 InitPagefileList(pVirtMem);
641 }
642
643
644 static VOID
645 OnDestroy(PVIRTMEM pVirtMem)
646 {
647 INT i;
648
649 for (i = 0; i < 26; i++)
650 {
651 if (pVirtMem->Pagefile[i].pszVolume != NULL)
652 HeapFree(GetProcessHeap(), 0, pVirtMem->Pagefile[i].pszVolume);
653 }
654
655 if (pVirtMem->szPagingFiles)
656 HeapFree(GetProcessHeap(), 0, pVirtMem->szPagingFiles);
657
658 HeapFree(GetProcessHeap(), 0, pVirtMem);
659 }
660
661
662 INT_PTR CALLBACK
663 VirtMemDlgProc(HWND hwndDlg,
664 UINT uMsg,
665 WPARAM wParam,
666 LPARAM lParam)
667 {
668 PVIRTMEM pVirtMem;
669
670 UNREFERENCED_PARAMETER(lParam);
671
672 pVirtMem = (PVIRTMEM)GetWindowLongPtr(hwndDlg, DWLP_USER);
673
674 switch (uMsg)
675 {
676 case WM_INITDIALOG:
677 pVirtMem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(VIRTMEM));
678 if (pVirtMem == NULL)
679 {
680 EndDialog(hwndDlg, 0);
681 return FALSE;
682 }
683
684 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pVirtMem);
685
686 OnInitDialog(hwndDlg, pVirtMem);
687 break;
688
689 case WM_DESTROY:
690 OnDestroy(pVirtMem);
691 break;
692
693 case WM_COMMAND:
694 switch (LOWORD(wParam))
695 {
696 case IDCANCEL:
697 EndDialog(hwndDlg, 0);
698 return TRUE;
699
700 case IDOK:
701 OnOk(pVirtMem);
702 EndDialog(hwndDlg, pVirtMem->bModified);
703 return TRUE;
704
705 case IDC_NOPAGEFILE:
706 OnNoPagingFile(pVirtMem);
707 return TRUE;
708
709 case IDC_SYSMANSIZE:
710 OnSysManSize(pVirtMem);
711 return TRUE;
712
713 case IDC_CUSTOM:
714 OnCustom(pVirtMem);
715 return TRUE;
716
717 case IDC_SET:
718 OnSet(pVirtMem);
719 return TRUE;
720
721 case IDC_PAGEFILELIST:
722 switch (HIWORD(wParam))
723 {
724 case LBN_SELCHANGE:
725 OnSelChange(hwndDlg, pVirtMem);
726 return TRUE;
727 }
728 break;
729 }
730 break;
731 }
732
733 return FALSE;
734 }