[FORMATTING] Use a consistent indentation (TABs) for all parts of sysdm.cpl

No code changes

svn path=/trunk/; revision=27785
This commit is contained in:
Colin Finck 2007-07-23 10:26:55 +00:00
parent b17938545b
commit e2cb9802d4
10 changed files with 1489 additions and 1500 deletions

View file

@ -15,72 +15,71 @@ static TCHAR BugLink[] = _T("http://www.reactos.org/bugzilla");
/* Property page dialog callback */ /* Property page dialog callback */
INT_PTR CALLBACK INT_PTR CALLBACK
AdvancedPageProc(HWND hwndDlg, AdvancedPageProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDC_PERFOR: case IDC_PERFOR:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_VIRTMEM), MAKEINTRESOURCE(IDD_VIRTMEM),
hwndDlg, hwndDlg,
(DLGPROC)VirtMemDlgProc); (DLGPROC)VirtMemDlgProc);
} }
break; break;
case IDC_USERPROFILE: case IDC_USERPROFILE:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_USERPROFILE), MAKEINTRESOURCE(IDD_USERPROFILE),
hwndDlg, hwndDlg,
(DLGPROC)UserProfileDlgProc); (DLGPROC)UserProfileDlgProc);
} }
break; break;
case IDC_STAREC: case IDC_STAREC:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_STARTUPRECOVERY), MAKEINTRESOURCE(IDD_STARTUPRECOVERY),
hwndDlg, hwndDlg,
(DLGPROC)StartRecDlgProc); (DLGPROC)StartRecDlgProc);
} }
break; break;
case IDC_ENVVAR: case IDC_ENVVAR:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_ENVIRONMENT_VARIABLES), MAKEINTRESOURCE(IDD_ENVIRONMENT_VARIABLES),
hwndDlg, hwndDlg,
(DLGPROC)EnvironmentDlgProc); (DLGPROC)EnvironmentDlgProc);
} }
break; break;
case IDC_ERRORREPORT: case IDC_ERRORREPORT:
{ {
ShellExecute(NULL, ShellExecute(NULL,
_T("open"), _T("open"),
BugLink, BugLink,
NULL, NULL,
NULL, NULL,
SW_SHOWNORMAL); SW_SHOWNORMAL);
} }
break; break;
}
}
} break;
} }
break; return FALSE;
}
return FALSE;
} }

File diff suppressed because it is too large Load diff

View file

@ -14,60 +14,60 @@
typedef struct _IMGINFO typedef struct _IMGINFO
{ {
HBITMAP hBitmap; HBITMAP hBitmap;
INT cxSource; INT cxSource;
INT cySource; INT cySource;
} IMGINFO, *PIMGINFO; } IMGINFO, *PIMGINFO;
void void
ShowLastWin32Error(HWND hWndOwner) ShowLastWin32Error(HWND hWndOwner)
{ {
LPTSTR lpMsg; LPTSTR lpMsg;
DWORD LastError; DWORD LastError;
LastError = GetLastError(); LastError = GetLastError();
if((LastError == 0) || if((LastError == 0) ||
!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | !FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_FROM_SYSTEM,
NULL, NULL,
LastError, LastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsg, (LPTSTR)&lpMsg,
0, 0,
NULL)) NULL))
{ {
return; return;
} }
MessageBox(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR); MessageBox(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
LocalFree((LPVOID)lpMsg); LocalFree((LPVOID)lpMsg);
} }
static VOID static VOID
InitImageInfo(PIMGINFO ImgInfo) InitImageInfo(PIMGINFO ImgInfo)
{ {
BITMAP bitmap; BITMAP bitmap;
ZeroMemory(ImgInfo, sizeof(*ImgInfo)); ZeroMemory(ImgInfo, sizeof(*ImgInfo));
ImgInfo->hBitmap = LoadImage(hApplet, ImgInfo->hBitmap = LoadImage(hApplet,
MAKEINTRESOURCE(IDB_ROSBMP), MAKEINTRESOURCE(IDB_ROSBMP),
IMAGE_BITMAP, IMAGE_BITMAP,
0, 0,
0, 0,
LR_DEFAULTCOLOR); LR_DEFAULTCOLOR);
if (ImgInfo->hBitmap != NULL) if (ImgInfo->hBitmap != NULL)
{ {
GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap); GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
ImgInfo->cxSource = bitmap.bmWidth; ImgInfo->cxSource = bitmap.bmWidth;
ImgInfo->cySource = bitmap.bmHeight; ImgInfo->cySource = bitmap.bmHeight;
} }
} }
@ -77,38 +77,38 @@ SetRegTextData(HWND hwnd,
LPTSTR Value, LPTSTR Value,
UINT uID) UINT uID)
{ {
LPTSTR lpBuf = NULL; LPTSTR lpBuf = NULL;
DWORD BufSize = 0; DWORD BufSize = 0;
DWORD Type; DWORD Type;
if (RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
Value, Value,
NULL, NULL,
&Type, &Type,
NULL, NULL,
&BufSize) == ERROR_SUCCESS) &BufSize) == ERROR_SUCCESS)
{ {
lpBuf = HeapAlloc(GetProcessHeap(), lpBuf = HeapAlloc(GetProcessHeap(),
0, 0,
BufSize); BufSize);
if (!lpBuf) return; if (!lpBuf) return;
if (RegQueryValueEx(hKey, if (RegQueryValueEx(hKey,
Value, Value,
NULL, NULL,
&Type, &Type,
(PBYTE)lpBuf, (PBYTE)lpBuf,
&BufSize) == ERROR_SUCCESS) &BufSize) == ERROR_SUCCESS)
{ {
SetDlgItemText(hwnd, SetDlgItemText(hwnd,
uID, uID,
lpBuf); lpBuf);
} }
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
lpBuf); lpBuf);
} }
} }
static INT static INT
@ -207,145 +207,145 @@ SetProcSpeed(HWND hwnd,
UINT uID) UINT uID)
{ {
TCHAR szBuf[64]; TCHAR szBuf[64];
DWORD BufSize = sizeof(DWORD); DWORD BufSize = sizeof(DWORD);
DWORD Type = REG_SZ; DWORD Type = REG_SZ;
PROCESSOR_POWER_INFORMATION ppi; PROCESSOR_POWER_INFORMATION ppi;
ZeroMemory(&ppi, ZeroMemory(&ppi,
sizeof(ppi)); sizeof(ppi));
if ((CallNtPowerInformation(ProcessorInformation, if ((CallNtPowerInformation(ProcessorInformation,
NULL, NULL,
0, 0,
(PVOID)&ppi, (PVOID)&ppi,
sizeof(ppi)) == STATUS_SUCCESS && sizeof(ppi)) == STATUS_SUCCESS &&
ppi.CurrentMhz != 0) || ppi.CurrentMhz != 0) ||
RegQueryValueEx(hKey, RegQueryValueEx(hKey,
Value, Value,
NULL, NULL,
&Type, &Type,
(PBYTE)&ppi.CurrentMhz, (PBYTE)&ppi.CurrentMhz,
&BufSize) == ERROR_SUCCESS) &BufSize) == ERROR_SUCCESS)
{ {
if (ppi.CurrentMhz < 1000) if (ppi.CurrentMhz < 1000)
{ {
_stprintf(szBuf, _T("%lu MHz"), ppi.CurrentMhz); _stprintf(szBuf, _T("%lu MHz"), ppi.CurrentMhz);
} }
else else
{ {
double flt = ppi.CurrentMhz / 1000.0; double flt = ppi.CurrentMhz / 1000.0;
_stprintf(szBuf, _T("%.2f GHz"), flt); _stprintf(szBuf, _T("%.2f GHz"), flt);
} }
SetDlgItemText(hwnd, SetDlgItemText(hwnd,
uID, uID,
szBuf); szBuf);
} }
} }
static VOID static VOID
GetSystemInformation(HWND hwnd) GetSystemInformation(HWND hwnd)
{ {
HKEY hKey; HKEY hKey;
TCHAR ProcKey[] = _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0"); TCHAR ProcKey[] = _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
MEMORYSTATUSEX MemStat; MEMORYSTATUSEX MemStat;
TCHAR Buf[32]; TCHAR Buf[32];
INT Ret = 0; INT Ret = 0;
INT CurMachineLine = IDC_MACHINELINE1; INT CurMachineLine = IDC_MACHINELINE1;
/* Get Processor information * /* Get Processor information *
* although undocumented, this information is being pulled * although undocumented, this information is being pulled
* directly out of the registry instead of via setupapi as it * directly out of the registry instead of via setupapi as it
* contains all the info we need, and should remain static * contains all the info we need, and should remain static
*/ */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
ProcKey, ProcKey,
0, 0,
KEY_READ, KEY_READ,
&hKey) == ERROR_SUCCESS) &hKey) == ERROR_SUCCESS)
{ {
SetRegTextData(hwnd, SetRegTextData(hwnd,
hKey, hKey,
_T("VendorIdentifier"), _T("VendorIdentifier"),
CurMachineLine); CurMachineLine);
CurMachineLine++; CurMachineLine++;
Ret = SetProcNameString(hwnd, Ret = SetProcNameString(hwnd,
hKey, hKey,
_T("ProcessorNameString"), _T("ProcessorNameString"),
CurMachineLine, CurMachineLine,
CurMachineLine+1); CurMachineLine+1);
CurMachineLine += Ret; CurMachineLine += Ret;
SetProcSpeed(hwnd, SetProcSpeed(hwnd,
hKey, hKey,
_T("~MHz"), _T("~MHz"),
CurMachineLine); CurMachineLine);
CurMachineLine++; CurMachineLine++;
} }
/* Get total physical RAM */ /* Get total physical RAM */
MemStat.dwLength = sizeof(MemStat); MemStat.dwLength = sizeof(MemStat);
if (GlobalMemoryStatusEx(&MemStat)) if (GlobalMemoryStatusEx(&MemStat))
{ {
TCHAR szStr[32]; TCHAR szStr[32];
double dTotalPhys; double dTotalPhys;
UINT i = 0; UINT i = 0;
static const UINT uStrId[] = { static const UINT uStrId[] = {
IDS_MEGABYTE, IDS_MEGABYTE,
IDS_GIGABYTE, IDS_GIGABYTE,
IDS_TERABYTE, IDS_TERABYTE,
IDS_PETABYTE IDS_PETABYTE
}; };
if (MemStat.ullTotalPhys > 1024 * 1024 * 1024) if (MemStat.ullTotalPhys > 1024 * 1024 * 1024)
{ {
/* We're dealing with GBs or more */ /* We're dealing with GBs or more */
MemStat.ullTotalPhys /= 1024 * 1024; MemStat.ullTotalPhys /= 1024 * 1024;
i++; i++;
if (MemStat.ullTotalPhys > 1024 * 1024) if (MemStat.ullTotalPhys > 1024 * 1024)
{ {
/* We're dealing with TBs or more */ /* We're dealing with TBs or more */
MemStat.ullTotalPhys /= 1024; MemStat.ullTotalPhys /= 1024;
i++; i++;
if (MemStat.ullTotalPhys > 1024 * 1024) if (MemStat.ullTotalPhys > 1024 * 1024)
{ {
/* We're dealing with PBs or more */ /* We're dealing with PBs or more */
MemStat.ullTotalPhys /= 1024; MemStat.ullTotalPhys /= 1024;
i++; i++;
dTotalPhys = (double)MemStat.ullTotalPhys / 1024; dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
} }
else else
dTotalPhys = (double)MemStat.ullTotalPhys / 1024; dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
} }
else else
dTotalPhys = (double)MemStat.ullTotalPhys / 1024; dTotalPhys = (double)MemStat.ullTotalPhys / 1024;
} }
else else
{ {
/* We're daling with MBs */ /* We're daling with MBs */
dTotalPhys = (double)MemStat.ullTotalPhys / 1024 / 1024; dTotalPhys = (double)MemStat.ullTotalPhys / 1024 / 1024;
} }
if (LoadString(hApplet, uStrId[i], szStr, sizeof(szStr) / sizeof(szStr[0]))) if (LoadString(hApplet, uStrId[i], szStr, sizeof(szStr) / sizeof(szStr[0])))
{ {
Ret = _stprintf(Buf, _T("%.2f %s"), dTotalPhys, szStr); Ret = _stprintf(Buf, _T("%.2f %s"), dTotalPhys, szStr);
} }
} }
if (Ret) if (Ret)
{ {
SetDlgItemText(hwnd, SetDlgItemText(hwnd,
CurMachineLine, CurMachineLine,
Buf); Buf);
} }
} }
@ -356,89 +356,84 @@ GeneralPageProc(HWND hwndDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
static IMGINFO ImgInfo; static IMGINFO ImgInfo;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(wParam);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
InitImageInfo(&ImgInfo); InitImageInfo(&ImgInfo);
GetSystemInformation(hwndDlg); GetSystemInformation(hwndDlg);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
if (LOWORD(wParam) == IDC_LICENCE) if (LOWORD(wParam) == IDC_LICENCE)
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_LICENCE), MAKEINTRESOURCE(IDD_LICENCE),
hwndDlg, hwndDlg,
LicenceDlgProc); LicenceDlgProc);
return TRUE; return TRUE;
} }
} }
break; break;
case WM_DRAWITEM: case WM_DRAWITEM:
{ {
LPDRAWITEMSTRUCT lpDrawItem; LPDRAWITEMSTRUCT lpDrawItem;
lpDrawItem = (LPDRAWITEMSTRUCT) lParam; lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
if(lpDrawItem->CtlID == IDC_ROSIMG) if(lpDrawItem->CtlID == IDC_ROSIMG)
{ {
HDC hdcMem; HDC hdcMem;
LONG left; LONG left;
/* position image in centre of dialog */ /* position image in centre of dialog */
left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2; left = (lpDrawItem->rcItem.right - ImgInfo.cxSource) / 2;
hdcMem = CreateCompatibleDC(lpDrawItem->hDC); hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL) if (hdcMem != NULL)
{ {
SelectObject(hdcMem, ImgInfo.hBitmap); SelectObject(hdcMem, ImgInfo.hBitmap);
BitBlt(lpDrawItem->hDC, BitBlt(lpDrawItem->hDC,
left, left,
lpDrawItem->rcItem.top, lpDrawItem->rcItem.top,
lpDrawItem->rcItem.right - lpDrawItem->rcItem.left, lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top, lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
hdcMem, hdcMem,
0, 0,
0, 0,
SRCCOPY); SRCCOPY);
DeleteDC(hdcMem); DeleteDC(hdcMem);
} }
} }
return TRUE; return TRUE;
} }
case WM_NOTIFY: case WM_NOTIFY:
{ {
NMHDR *nmhdr = (NMHDR *)lParam; NMHDR *nmhdr = (NMHDR *)lParam;
if (nmhdr->idFrom == IDC_ROSHOMEPAGE_LINK && nmhdr->code == NM_CLICK) if (nmhdr->idFrom == IDC_ROSHOMEPAGE_LINK && nmhdr->code == NM_CLICK)
{ {
PNMLINK nml = (PNMLINK)nmhdr; PNMLINK nml = (PNMLINK)nmhdr;
ShellExecuteW(hwndDlg, ShellExecuteW(hwndDlg,
L"open", L"open",
nml->item.szUrl, nml->item.szUrl,
NULL, NULL,
NULL, NULL,
SW_SHOWNORMAL); SW_SHOWNORMAL);
} }
break; break;
} }
} }
return FALSE; return FALSE;
} }

View file

@ -12,77 +12,76 @@
/* Property page dialog callback */ /* Property page dialog callback */
static INT_PTR CALLBACK static INT_PTR CALLBACK
RenameProfDlgProc(HWND hwndDlg, RenameProfDlgProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(hwndDlg); UNREFERENCED_PARAMETER(hwndDlg);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0); MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{ {
EndDialog(hwndDlg, EndDialog(hwndDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
} }
} }
break; break;
} }
return FALSE; return FALSE;
} }
/* Property page dialog callback */ /* Property page dialog callback */
INT_PTR CALLBACK INT_PTR CALLBACK
HardProfDlgProc(HWND hwndDlg, HardProfDlgProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(hwndDlg); UNREFERENCED_PARAMETER(hwndDlg);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0); MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDC_HRDPROFRENAME: case IDC_HRDPROFRENAME:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_RENAMEPROFILE), MAKEINTRESOURCE(IDD_RENAMEPROFILE),
hwndDlg, hwndDlg,
(DLGPROC)RenameProfDlgProc); (DLGPROC)RenameProfDlgProc);
} }
case IDOK: case IDOK:
case IDCANCEL: case IDCANCEL:
{ {
EndDialog(hwndDlg, EndDialog(hwndDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
} }
} }
}
} break;
break; }
} return FALSE;
return FALSE;
} }

View file

@ -16,72 +16,71 @@ BOOL LaunchDeviceManager(HWND hWndParent)
{ {
/* hack for ROS to start our devmgmt until we have mmc */ /* hack for ROS to start our devmgmt until we have mmc */
#ifdef __REACTOS__ #ifdef __REACTOS__
return ((INT)ShellExecuteW(NULL, L"open", L"devmgmt.exe", NULL, NULL, SW_SHOWNORMAL) > 32); return ((INT)ShellExecuteW(NULL, L"open", L"devmgmt.exe", NULL, NULL, SW_SHOWNORMAL) > 32);
#else #else
HMODULE hDll; HMODULE hDll;
PDEVMGREXEC DevMgrExec; PDEVMGREXEC DevMgrExec;
BOOL Ret; BOOL Ret;
hDll = LoadLibrary(_TEXT("devmgr.dll")); hDll = LoadLibrary(_TEXT("devmgr.dll"));
if(!hDll) if(!hDll)
return FALSE; return FALSE;
DevMgrExec = (PDEVMGREXEC)GetProcAddress(hDll, "DeviceManager_ExecuteW"); DevMgrExec = (PDEVMGREXEC)GetProcAddress(hDll, "DeviceManager_ExecuteW");
if(!DevMgrExec) if(!DevMgrExec)
{ {
FreeLibrary(hDll); FreeLibrary(hDll);
return FALSE; return FALSE;
} }
/* run the Device Manager */ /* run the Device Manager */
Ret = DevMgrExec(hWndParent, hApplet, NULL /* ??? */, SW_SHOW); Ret = DevMgrExec(hWndParent, hApplet, NULL /* ??? */, SW_SHOW);
FreeLibrary(hDll); FreeLibrary(hDll);
return Ret; return Ret;
#endif /* __REACTOS__ */ #endif /* __REACTOS__ */
} }
/* Property page dialog callback */ /* Property page dialog callback */
INT_PTR CALLBACK INT_PTR CALLBACK
HardwarePageProc(HWND hwndDlg, HardwarePageProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
switch(LOWORD(wParam)) switch(LOWORD(wParam))
{ {
case IDC_HARDWARE_DEVICE_MANAGER: case IDC_HARDWARE_DEVICE_MANAGER:
{ {
if(!LaunchDeviceManager(hwndDlg)) if(!LaunchDeviceManager(hwndDlg))
{ {
/* FIXME */ /* FIXME */
} }
return TRUE; return TRUE;
} }
case IDC_HARDWARE_PROFILE: case IDC_HARDWARE_PROFILE:
{ {
DialogBox(hApplet, DialogBox(hApplet,
MAKEINTRESOURCE(IDD_HARDWAREPROFILES), MAKEINTRESOURCE(IDD_HARDWAREPROFILES),
hwndDlg, hwndDlg,
(DLGPROC)HardProfDlgProc); (DLGPROC)HardProfDlgProc);
return TRUE; return TRUE;
} }
} }
} }
break; break;
} }
return FALSE; return FALSE;
} }

View file

@ -12,70 +12,70 @@
INT_PTR CALLBACK INT_PTR CALLBACK
LicenceDlgProc(HWND hDlg, LicenceDlgProc(HWND hDlg,
UINT message, UINT message,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
HRSRC hResInfo; HRSRC hResInfo;
HGLOBAL hResMem; HGLOBAL hResMem;
WCHAR *LicenseText; WCHAR *LicenseText;
static HICON hIcon; static HICON hIcon;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch (message) switch (message)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
hIcon = LoadImage(hApplet, hIcon = LoadImage(hApplet,
MAKEINTRESOURCE(IDI_CPLSYSTEM), MAKEINTRESOURCE(IDI_CPLSYSTEM),
IMAGE_ICON, IMAGE_ICON,
16, 16,
16, 16,
0); 0);
SendMessage(hDlg, SendMessage(hDlg,
WM_SETICON, WM_SETICON,
ICON_SMALL, ICON_SMALL,
(LPARAM)hIcon); (LPARAM)hIcon);
/* load license from resource */ /* load license from resource */
if(!(hResInfo = FindResource(hApplet, if(!(hResInfo = FindResource(hApplet,
MAKEINTRESOURCE(RC_LICENSE), MAKEINTRESOURCE(RC_LICENSE),
MAKEINTRESOURCE(RTDATA))) || MAKEINTRESOURCE(RTDATA))) ||
!(hResMem = LoadResource(hApplet, hResInfo)) || !(hResMem = LoadResource(hApplet, hResInfo)) ||
!(LicenseText = LockResource(hResMem))) !(LicenseText = LockResource(hResMem)))
{ {
ShowLastWin32Error(hDlg); ShowLastWin32Error(hDlg);
break; break;
} }
/* insert the license into the edit control (unicode!) */ /* insert the license into the edit control (unicode!) */
SetDlgItemText(hDlg, SetDlgItemText(hDlg,
IDC_LICENCEEDIT, IDC_LICENCEEDIT,
LicenseText); LicenseText);
SendDlgItemMessage(hDlg, SendDlgItemMessage(hDlg,
IDC_LICENCEEDIT, IDC_LICENCEEDIT,
EM_SETSEL, EM_SETSEL,
-1, -1,
0); 0);
return TRUE; return TRUE;
} }
case WM_COMMAND: case WM_COMMAND:
{ {
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{ {
DestroyIcon(hIcon); DestroyIcon(hIcon);
EndDialog(hDlg, EndDialog(hDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
} }
} }
break; break;
} }
return FALSE; return FALSE;
} }

View file

@ -29,9 +29,9 @@ void SetTimeout(HWND hwndDlg, int Timeout)
/* Property page dialog callback */ /* Property page dialog callback */
INT_PTR CALLBACK INT_PTR CALLBACK
StartRecDlgProc(HWND hwndDlg, StartRecDlgProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
TCHAR *szSystemDrive; TCHAR *szSystemDrive;
TCHAR szDefaultOS[MAX_PATH]; TCHAR szDefaultOS[MAX_PATH];
@ -40,7 +40,7 @@ StartRecDlgProc(HWND hwndDlg,
int iTimeout; int iTimeout;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
@ -89,7 +89,7 @@ FailGetSysDrive:
HeapFree(GetProcessHeap(), 0, szSystemDrive); HeapFree(GetProcessHeap(), 0, szSystemDrive);
} }
} }
SetDlgItemText(hwndDlg, IDC_STRRECDUMPFILE, _T("%SystemRoot%\\MiniDump")); SetDlgItemText(hwndDlg, IDC_STRRECDUMPFILE, _T("%SystemRoot%\\MiniDump"));
/* load settings from freeldr.ini */ /* load settings from freeldr.ini */
@ -143,6 +143,6 @@ FailGetSysDrive:
} }
} }
break; break;
} }
return FALSE; return FALSE;
} }

View file

@ -15,7 +15,7 @@ HINSTANCE hApplet = 0;
/* Applets */ /* Applets */
APPLET Applets[NUM_APPLETS] = APPLET Applets[NUM_APPLETS] =
{ {
{IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet} {IDI_CPLSYSTEM, IDS_CPLSYSTEMNAME, IDS_CPLSYSTEMDESCRIPTION, SystemApplet}
}; };
#define MAX_SYSTEM_PAGES 32 #define MAX_SYSTEM_PAGES 32
@ -23,39 +23,39 @@ APPLET Applets[NUM_APPLETS] =
static BOOL CALLBACK static BOOL CALLBACK
PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam) PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
{ {
PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam; PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES) if (ppsh != NULL && ppsh->nPages < MAX_SYSTEM_PAGES)
{ {
ppsh->phpage[ppsh->nPages++] = hpage; ppsh->phpage[ppsh->nPages++] = hpage;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
static BOOL static BOOL
InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc) InitPropSheetPage(PROPSHEETHEADER *ppsh, WORD idDlg, DLGPROC DlgProc)
{ {
HPROPSHEETPAGE hPage; HPROPSHEETPAGE hPage;
PROPSHEETPAGE psp; PROPSHEETPAGE psp;
if (ppsh->nPages < MAX_SYSTEM_PAGES) if (ppsh->nPages < MAX_SYSTEM_PAGES)
{ {
ZeroMemory(&psp, sizeof(psp)); ZeroMemory(&psp, sizeof(psp));
psp.dwSize = sizeof(psp); psp.dwSize = sizeof(psp);
psp.dwFlags = PSP_DEFAULT; psp.dwFlags = PSP_DEFAULT;
psp.hInstance = hApplet; psp.hInstance = hApplet;
psp.pszTemplate = MAKEINTRESOURCE(idDlg); psp.pszTemplate = MAKEINTRESOURCE(idDlg);
psp.pfnDlgProc = DlgProc; psp.pfnDlgProc = DlgProc;
hPage = CreatePropertySheetPage(&psp); hPage = CreatePropertySheetPage(&psp);
if (hPage != NULL) if (hPage != NULL)
{ {
return PropSheetAddPage(hPage, (LPARAM)ppsh); return PropSheetAddPage(hPage, (LPARAM)ppsh);
} }
} }
return FALSE; return FALSE;
} }
typedef HPROPSHEETPAGE (WINAPI *PCreateNetIDPropertyPage)(VOID); typedef HPROPSHEETPAGE (WINAPI *PCreateNetIDPropertyPage)(VOID);
@ -63,87 +63,87 @@ typedef HPROPSHEETPAGE (WINAPI *PCreateNetIDPropertyPage)(VOID);
static HMODULE static HMODULE
AddNetIdPage(PROPSHEETHEADER *ppsh) AddNetIdPage(PROPSHEETHEADER *ppsh)
{ {
HPROPSHEETPAGE hPage; HPROPSHEETPAGE hPage;
HMODULE hMod; HMODULE hMod;
PCreateNetIDPropertyPage pCreateNetIdPage; PCreateNetIDPropertyPage pCreateNetIdPage;
hMod = LoadLibrary(TEXT("netid.dll")); hMod = LoadLibrary(TEXT("netid.dll"));
if (hMod != NULL) if (hMod != NULL)
{ {
pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod, pCreateNetIdPage = (PCreateNetIDPropertyPage)GetProcAddress(hMod,
"CreateNetIDPropertyPage"); "CreateNetIDPropertyPage");
if (pCreateNetIdPage != NULL) if (pCreateNetIdPage != NULL)
{ {
hPage = pCreateNetIdPage(); hPage = pCreateNetIdPage();
if (hPage == NULL) if (hPage == NULL)
goto Fail; goto Fail;
if (!PropSheetAddPage(hPage, (LPARAM)ppsh)) if (!PropSheetAddPage(hPage, (LPARAM)ppsh))
{ {
DestroyPropertySheetPage(hPage); DestroyPropertySheetPage(hPage);
goto Fail; goto Fail;
} }
} }
else else
{ {
Fail: Fail:
FreeLibrary(hMod); FreeLibrary(hMod);
hMod = NULL; hMod = NULL;
} }
} }
return hMod; return hMod;
} }
/* First Applet */ /* First Applet */
LONG CALLBACK LONG CALLBACK
SystemApplet(VOID) SystemApplet(VOID)
{ {
HPROPSHEETPAGE hpsp[MAX_SYSTEM_PAGES]; HPROPSHEETPAGE hpsp[MAX_SYSTEM_PAGES];
PROPSHEETHEADER psh; PROPSHEETHEADER psh;
HMODULE hNetIdDll; HMODULE hNetIdDll;
HPSXA hpsxa = NULL; HPSXA hpsxa = NULL;
LONG Ret; LONG Ret;
static INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), ICC_LINK_CLASS}; static INITCOMMONCONTROLSEX icc = {sizeof(INITCOMMONCONTROLSEX), ICC_LINK_CLASS};
if (!InitCommonControlsEx(&icc)) if (!InitCommonControlsEx(&icc))
return 0; return 0;
ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPTITLE; psh.dwFlags = PSH_PROPTITLE;
psh.hwndParent = NULL; psh.hwndParent = NULL;
psh.hInstance = hApplet; psh.hInstance = hApplet;
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM)); psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDI_CPLSYSTEM));
psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME); psh.pszCaption = MAKEINTRESOURCE(IDS_CPLSYSTEMNAME);
psh.nPages = 0; psh.nPages = 0;
psh.nStartPage = 0; psh.nStartPage = 0;
psh.phpage = hpsp; psh.phpage = hpsp;
psh.pfnCallback = NULL; psh.pfnCallback = NULL;
InitPropSheetPage(&psh, IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc); InitPropSheetPage(&psh, IDD_PROPPAGEGENERAL, (DLGPROC) GeneralPageProc);
hNetIdDll = AddNetIdPage(&psh); hNetIdDll = AddNetIdPage(&psh);
InitPropSheetPage(&psh, IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc); InitPropSheetPage(&psh, IDD_PROPPAGEHARDWARE, (DLGPROC) HardwarePageProc);
InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc); InitPropSheetPage(&psh, IDD_PROPPAGEADVANCED, (DLGPROC) AdvancedPageProc);
/* Load additional pages provided by shell extensions */ /* Load additional pages provided by shell extensions */
hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\System"), MAX_SYSTEM_PAGES - psh.nPages); hpsxa = SHCreatePropSheetExtArray(HKEY_LOCAL_MACHINE, REGSTR_PATH_CONTROLSFOLDER TEXT("\\System"), MAX_SYSTEM_PAGES - psh.nPages);
if (hpsxa != NULL) if (hpsxa != NULL)
{ {
SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh); SHAddFromPropSheetExtArray(hpsxa, PropSheetAddPage, (LPARAM)&psh);
} }
Ret = (LONG)(PropertySheet(&psh) != -1); Ret = (LONG)(PropertySheet(&psh) != -1);
if (hpsxa != NULL) if (hpsxa != NULL)
{ {
SHDestroyPropSheetExtArray(hpsxa); SHDestroyPropSheetExtArray(hpsxa);
} }
if (hNetIdDll != NULL) if (hNetIdDll != NULL)
FreeLibrary(hNetIdDll); FreeLibrary(hNetIdDll);
return Ret; return Ret;
} }
/* Control Panel Callback */ /* Control Panel Callback */
@ -154,35 +154,35 @@ CPlApplet(
LPARAM lParam1, LPARAM lParam1,
LPARAM lParam2) LPARAM lParam2)
{ {
int i = (int)lParam1; int i = (int)lParam1;
UNREFERENCED_PARAMETER(hwndCPl); UNREFERENCED_PARAMETER(hwndCPl);
switch(uMsg) switch(uMsg)
{ {
case CPL_INIT: case CPL_INIT:
{ {
return TRUE; return TRUE;
} }
case CPL_GETCOUNT: case CPL_GETCOUNT:
{ {
return NUM_APPLETS; return NUM_APPLETS;
} }
case CPL_INQUIRE: case CPL_INQUIRE:
{ {
CPLINFO *CPlInfo = (CPLINFO*)lParam2; CPLINFO *CPlInfo = (CPLINFO*)lParam2;
CPlInfo->lData = 0; CPlInfo->lData = 0;
CPlInfo->idIcon = Applets[i].idIcon; CPlInfo->idIcon = Applets[i].idIcon;
CPlInfo->idName = Applets[i].idName; CPlInfo->idName = Applets[i].idName;
CPlInfo->idInfo = Applets[i].idDescription; CPlInfo->idInfo = Applets[i].idDescription;
break; break;
} }
case CPL_DBLCLK: case CPL_DBLCLK:
{ {
Applets[i].AppletProc(); Applets[i].AppletProc();
break; break;
} }
} }
return FALSE; return FALSE;
} }
@ -192,14 +192,13 @@ DllMain(
DWORD dwReason, DWORD dwReason,
LPVOID lpvReserved) LPVOID lpvReserved)
{ {
UNREFERENCED_PARAMETER(lpvReserved); UNREFERENCED_PARAMETER(lpvReserved);
switch(dwReason) switch(dwReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
hApplet = hinstDLL; hApplet = hinstDLL;
break; break;
} }
return TRUE; return TRUE;
} }

View file

@ -13,48 +13,48 @@
/* Property page dialog callback */ /* Property page dialog callback */
INT_PTR CALLBACK INT_PTR CALLBACK
UserProfileDlgProc(HWND hwndDlg, UserProfileDlgProc(HWND hwndDlg,
UINT uMsg, UINT uMsg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam); UNREFERENCED_PARAMETER(wParam);
UNREFERENCED_PARAMETER(hwndDlg); UNREFERENCED_PARAMETER(hwndDlg);
switch(uMsg) switch(uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
{ {
MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0); MessageBox(hwndDlg, _T("Dialog not yet implemented!"), NULL, 0);
} }
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL)) if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{ {
EndDialog(hwndDlg, EndDialog(hwndDlg,
LOWORD(wParam)); LOWORD(wParam));
return TRUE; return TRUE;
} }
} }
break; break;
case WM_NOTIFY: case WM_NOTIFY:
{ {
NMHDR *nmhdr = (NMHDR *)lParam; NMHDR *nmhdr = (NMHDR *)lParam;
if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK) if (nmhdr->idFrom == IDC_USERACCOUNT_LINK && nmhdr->code == NM_CLICK)
{ {
ShellExecute(hwndDlg, ShellExecute(hwndDlg,
TEXT("open"), TEXT("open"),
TEXT("rundll32.exe"), TEXT("rundll32.exe"),
TEXT("shell32.dll, Control_RunDLL nusrmgr.cpl"), TEXT("shell32.dll, Control_RunDLL nusrmgr.cpl"),
NULL, NULL,
SW_SHOWNORMAL); SW_SHOWNORMAL);
} }
break; break;
} }
} }
return FALSE; return FALSE;
} }

View file

@ -14,351 +14,350 @@ static LPCTSTR lpKey = _T("SYSTEM\\CurrentControlSet\\Control\\Session Manager\\
static BOOL static BOOL
ReadPageFileSettings(PVIRTMEM pVirtMem) ReadPageFileSettings(PVIRTMEM pVirtMem)
{ {
HKEY hkey = NULL; HKEY hkey = NULL;
DWORD dwType; DWORD dwType;
DWORD dwDataSize; DWORD dwDataSize;
BOOL bRet = FALSE; BOOL bRet = FALSE;
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
lpKey, lpKey,
0, 0,
NULL, NULL,
REG_OPTION_NON_VOLATILE, REG_OPTION_NON_VOLATILE,
KEY_QUERY_VALUE, KEY_QUERY_VALUE,
NULL, NULL,
&hkey, &hkey,
NULL) == ERROR_SUCCESS) NULL) == ERROR_SUCCESS)
{ {
if(RegQueryValueEx(hkey, if(RegQueryValueEx(hkey,
_T("PagingFiles"), _T("PagingFiles"),
NULL, NULL,
&dwType, &dwType,
NULL, NULL,
&dwDataSize) == ERROR_SUCCESS) &dwDataSize) == ERROR_SUCCESS)
{ {
pVirtMem->szPagingFiles = (LPTSTR)HeapAlloc(GetProcessHeap(), pVirtMem->szPagingFiles = (LPTSTR)HeapAlloc(GetProcessHeap(),
0, 0,
dwDataSize); dwDataSize);
if (pVirtMem->szPagingFiles != NULL) if (pVirtMem->szPagingFiles != NULL)
{ {
ZeroMemory(pVirtMem->szPagingFiles, ZeroMemory(pVirtMem->szPagingFiles,
dwDataSize); dwDataSize);
if(RegQueryValueEx(hkey, if(RegQueryValueEx(hkey,
_T("PagingFiles"), _T("PagingFiles"),
NULL, NULL,
&dwType, &dwType,
(PBYTE)pVirtMem->szPagingFiles, (PBYTE)pVirtMem->szPagingFiles,
&dwDataSize) == ERROR_SUCCESS) &dwDataSize) == ERROR_SUCCESS)
{ {
bRet = TRUE; bRet = TRUE;
} }
} }
}
}
} if (!bRet)
} ShowLastWin32Error(pVirtMem->hSelf);
if (!bRet) if (hkey != NULL)
ShowLastWin32Error(pVirtMem->hSelf); RegCloseKey(hkey);
if (hkey != NULL) return bRet;
RegCloseKey(hkey);
return bRet;
} }
static INT static INT
GetPageFileSizes(LPTSTR lpPageFiles) GetPageFileSizes(LPTSTR lpPageFiles)
{ {
while (*lpPageFiles != _T('\0')) while (*lpPageFiles != _T('\0'))
{ {
if (*lpPageFiles == _T(' ')) if (*lpPageFiles == _T(' '))
{ {
lpPageFiles++; lpPageFiles++;
return (INT)_ttoi(lpPageFiles); return (INT)_ttoi(lpPageFiles);
} }
lpPageFiles++; lpPageFiles++;
} }
return -1; return -1;
} }
static VOID static VOID
ParseMemSettings(PVIRTMEM pVirtMem) ParseMemSettings(PVIRTMEM pVirtMem)
{ {
TCHAR szDrives[1024]; // all drives TCHAR szDrives[1024]; // all drives
LPTSTR DrivePtr = szDrives; LPTSTR DrivePtr = szDrives;
TCHAR szDrive[MAX_PATH]; // single drive TCHAR szDrive[MAX_PATH]; // single drive
TCHAR szVolume[MAX_PATH]; TCHAR szVolume[MAX_PATH];
INT InitialSize = 0; INT InitialSize = 0;
INT MaxSize = 0; INT MaxSize = 0;
INT DriveLen; INT DriveLen;
INT PgCnt = 0; INT PgCnt = 0;
DriveLen = GetLogicalDriveStrings(1023, DriveLen = GetLogicalDriveStrings(1023,
szDrives); szDrives);
while (DriveLen != 0) while (DriveLen != 0)
{ {
LVITEM Item; LVITEM Item;
INT Len; INT Len;
Len = lstrlen(DrivePtr) + 1; Len = lstrlen(DrivePtr) + 1;
DriveLen -= Len; DriveLen -= Len;
DrivePtr = _tcsupr(DrivePtr); DrivePtr = _tcsupr(DrivePtr);
/* copy the 'X:' portion */ /* copy the 'X:' portion */
lstrcpyn(szDrive, DrivePtr, 3); lstrcpyn(szDrive, DrivePtr, 3);
if(GetDriveType(DrivePtr) == DRIVE_FIXED) if(GetDriveType(DrivePtr) == DRIVE_FIXED)
{ {
/* does drive match the one in the registry ? */ /* does drive match the one in the registry ? */
if(!_tcsncmp(pVirtMem->szPagingFiles, szDrive, 2)) if(!_tcsncmp(pVirtMem->szPagingFiles, szDrive, 2))
{ {
/* FIXME: we only check the first available pagefile in the reg */ /* FIXME: we only check the first available pagefile in the reg */
InitialSize = GetPageFileSizes(pVirtMem->szPagingFiles); InitialSize = GetPageFileSizes(pVirtMem->szPagingFiles);
MaxSize = GetPageFileSizes(pVirtMem->szPagingFiles); MaxSize = GetPageFileSizes(pVirtMem->szPagingFiles);
pVirtMem->Pagefile[PgCnt].InitialValue = InitialSize; pVirtMem->Pagefile[PgCnt].InitialValue = InitialSize;
pVirtMem->Pagefile[PgCnt].MaxValue = MaxSize; pVirtMem->Pagefile[PgCnt].MaxValue = MaxSize;
pVirtMem->Pagefile[PgCnt].bUsed = TRUE; pVirtMem->Pagefile[PgCnt].bUsed = TRUE;
lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive); lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive);
} }
else else
{ {
pVirtMem->Pagefile[PgCnt].InitialValue = 0; pVirtMem->Pagefile[PgCnt].InitialValue = 0;
pVirtMem->Pagefile[PgCnt].MaxValue = 0; pVirtMem->Pagefile[PgCnt].MaxValue = 0;
pVirtMem->Pagefile[PgCnt].bUsed = FALSE; pVirtMem->Pagefile[PgCnt].bUsed = FALSE;
lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive); lstrcpy(pVirtMem->Pagefile[PgCnt].szDrive, szDrive);
} }
/* fill out the listview */ /* fill out the listview */
ZeroMemory(&Item, sizeof(Item)); ZeroMemory(&Item, sizeof(Item));
Item.mask = LVIF_TEXT; Item.mask = LVIF_TEXT;
Item.iItem = ListView_GetItemCount(pVirtMem->hListView); Item.iItem = ListView_GetItemCount(pVirtMem->hListView);
Item.pszText = szDrive; Item.pszText = szDrive;
(void)ListView_InsertItem(pVirtMem->hListView, &Item); (void)ListView_InsertItem(pVirtMem->hListView, &Item);
/* set a volume label if there is one */ /* set a volume label if there is one */
if (GetVolumeInformation(DrivePtr, if (GetVolumeInformation(DrivePtr,
szVolume, szVolume,
255, 255,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
0)) 0))
{ {
if (szVolume[0] != _T('\0')) if (szVolume[0] != _T('\0'))
{ {
TCHAR szVol[MAX_PATH + 2]; TCHAR szVol[MAX_PATH + 2];
_stprintf(szVol, _T("[%s]"), szVolume); _stprintf(szVol, _T("[%s]"), szVolume);
Item.iSubItem = 1; Item.iSubItem = 1;
Item.pszText = szVol; Item.pszText = szVol;
(void)ListView_InsertItem(pVirtMem->hListView, &Item); (void)ListView_InsertItem(pVirtMem->hListView, &Item);
} }
} }
if ((InitialSize != 0) || (MaxSize != 0)) if ((InitialSize != 0) || (MaxSize != 0))
{ {
TCHAR szSize[64]; TCHAR szSize[64];
_stprintf(szSize, _T("%i - %i"), InitialSize, MaxSize); _stprintf(szSize, _T("%i - %i"), InitialSize, MaxSize);
Item.iSubItem = 2; Item.iSubItem = 2;
Item.pszText = szSize; Item.pszText = szSize;
(void)ListView_InsertItem(pVirtMem->hListView, &Item); (void)ListView_InsertItem(pVirtMem->hListView, &Item);
} }
PgCnt++; PgCnt++;
} }
DrivePtr += Len; DrivePtr += Len;
} }
pVirtMem->Count = PgCnt; pVirtMem->Count = PgCnt;
} }
static VOID static VOID
WritePageFileSettings(PVIRTMEM pVirtMem) WritePageFileSettings(PVIRTMEM pVirtMem)
{ {
HKEY hk = NULL; HKEY hk = NULL;
TCHAR szPagingFiles[2048]; TCHAR szPagingFiles[2048];
INT i; INT i;
INT nPos = 0; INT nPos = 0;
BOOL bErr = TRUE; BOOL bErr = TRUE;
for(i = 0; i < pVirtMem->Count; ++i) for(i = 0; i < pVirtMem->Count; ++i)
{ {
if(pVirtMem->Pagefile[i].bUsed) if(pVirtMem->Pagefile[i].bUsed)
{ {
TCHAR szText[256]; TCHAR szText[256];
_stprintf(szText, _T("%s\\pagefile.sys %i %i"), _stprintf(szText, _T("%s\\pagefile.sys %i %i"),
pVirtMem->Pagefile[i].szDrive, pVirtMem->Pagefile[i].szDrive,
pVirtMem->Pagefile[i].InitialValue, pVirtMem->Pagefile[i].InitialValue,
pVirtMem->Pagefile[i].MaxValue); pVirtMem->Pagefile[i].MaxValue);
/* Add it to our overall registry string */ /* Add it to our overall registry string */
lstrcat(szPagingFiles + nPos, szText); lstrcat(szPagingFiles + nPos, szText);
/* Record the position where the next string will start */ /* Record the position where the next string will start */
nPos += (INT)lstrlen(szText) + 1; nPos += (INT)lstrlen(szText) + 1;
/* add another NULL for REG_MULTI_SZ */ /* add another NULL for REG_MULTI_SZ */
szPagingFiles[nPos] = _T('\0'); szPagingFiles[nPos] = _T('\0');
nPos++; nPos++;
} }
} }
if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,
lpKey, lpKey,
0, 0,
NULL, NULL,
REG_OPTION_NON_VOLATILE, REG_OPTION_NON_VOLATILE,
KEY_WRITE, KEY_WRITE,
NULL, NULL,
&hk, &hk,
NULL) == ERROR_SUCCESS) NULL) == ERROR_SUCCESS)
{ {
if (RegSetValueEx(hk, if (RegSetValueEx(hk,
_T("PagingFiles"), _T("PagingFiles"),
0, 0,
REG_MULTI_SZ, REG_MULTI_SZ,
(LPBYTE) szPagingFiles, (LPBYTE) szPagingFiles,
(DWORD) nPos * sizeof(TCHAR))) (DWORD) nPos * sizeof(TCHAR)))
{ {
bErr = FALSE; bErr = FALSE;
} }
RegCloseKey(hk); RegCloseKey(hk);
} }
if (bErr) if (bErr)
ShowLastWin32Error(pVirtMem->hSelf); ShowLastWin32Error(pVirtMem->hSelf);
} }
static VOID static VOID
SetListViewColumns(HWND hwndListView) SetListViewColumns(HWND hwndListView)
{ {
RECT rect; RECT rect;
LV_COLUMN lvc; LV_COLUMN lvc;
GetClientRect(hwndListView, &rect); GetClientRect(hwndListView, &rect);
(void)ListView_SetExtendedListViewStyle(hwndListView, (void)ListView_SetExtendedListViewStyle(hwndListView,
LVS_EX_FULLROWSELECT); LVS_EX_FULLROWSELECT);
ZeroMemory(&lvc, sizeof(lvc)); ZeroMemory(&lvc, sizeof(lvc));
lvc.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT; lvc.mask = LVCF_SUBITEM | LVCF_WIDTH | LVCF_FMT;
lvc.fmt = LVCFMT_LEFT; lvc.fmt = LVCFMT_LEFT;
lvc.cx = (INT)((rect.right - rect.left) * 0.1); lvc.cx = (INT)((rect.right - rect.left) * 0.1);
lvc.iSubItem = 0; lvc.iSubItem = 0;
(void)ListView_InsertColumn(hwndListView, 0, &lvc); (void)ListView_InsertColumn(hwndListView, 0, &lvc);
lvc.cx = (INT)((rect.right - rect.left) * 0.3); lvc.cx = (INT)((rect.right - rect.left) * 0.3);
lvc.iSubItem = 1; lvc.iSubItem = 1;
(void)ListView_InsertColumn(hwndListView, 1, &lvc); (void)ListView_InsertColumn(hwndListView, 1, &lvc);
lvc.cx = (INT)((rect.right - rect.left) * 0.6); lvc.cx = (INT)((rect.right - rect.left) * 0.6);
lvc.iSubItem = 2; lvc.iSubItem = 2;
(void)ListView_InsertColumn(hwndListView, 2, &lvc); (void)ListView_InsertColumn(hwndListView, 2, &lvc);
} }
static VOID static VOID
OnNoPagingFile(PVIRTMEM pVirtMem) OnNoPagingFile(PVIRTMEM pVirtMem)
{ {
/* Disable the page file custom size boxes */ /* Disable the page file custom size boxes */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
} }
static VOID static VOID
OnSysManSize(PVIRTMEM pVirtMem) OnSysManSize(PVIRTMEM pVirtMem)
{ {
/* Disable the page file custom size boxes */ /* Disable the page file custom size boxes */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
} }
static VOID static VOID
OnCustom(PVIRTMEM pVirtMem) OnCustom(PVIRTMEM pVirtMem)
{ {
/* Enable the page file custom size boxes */ /* Enable the page file custom size boxes */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
} }
static VOID static VOID
OnSet(PVIRTMEM pVirtMem) OnSet(PVIRTMEM pVirtMem)
{ {
INT Index; INT Index;
pVirtMem->bSave = TRUE; pVirtMem->bSave = TRUE;
Index = (INT)SendDlgItemMessage(pVirtMem->hSelf, Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
IDC_PAGEFILELIST, IDC_PAGEFILELIST,
LB_GETCURSEL, LB_GETCURSEL,
0, 0,
0); 0);
if(Index < pVirtMem->Count) if(Index < pVirtMem->Count)
{ {
TCHAR szText[255]; TCHAR szText[255];
/* check if custom settings are checked */ /* check if custom settings are checked */
if(SendDlgItemMessage(pVirtMem->hSelf, if(SendDlgItemMessage(pVirtMem->hSelf,
IDC_CUSTOM, IDC_CUSTOM,
BM_GETCHECK, BM_GETCHECK,
0, 0,
0) == BST_CHECKED) 0) == BST_CHECKED)
{ {
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_INITIALSIZE, IDC_INITIALSIZE,
WM_GETTEXT, WM_GETTEXT,
254, 254,
(LPARAM)szText); (LPARAM)szText);
pVirtMem->Pagefile[Index].InitialValue = _ttoi(szText); pVirtMem->Pagefile[Index].InitialValue = _ttoi(szText);
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_MAXSIZE, IDC_MAXSIZE,
WM_GETTEXT, WM_GETTEXT,
254, 254,
(LPARAM)szText); (LPARAM)szText);
pVirtMem->Pagefile[Index].MaxValue = _ttoi(szText); pVirtMem->Pagefile[Index].MaxValue = _ttoi(szText);
} }
else else
{ {
/* set sizes to 0 */ /* set sizes to 0 */
pVirtMem->Pagefile[Index].InitialValue = pVirtMem->Pagefile[Index].MaxValue = 0; pVirtMem->Pagefile[Index].InitialValue = pVirtMem->Pagefile[Index].MaxValue = 0;
// check to see if this drive is used for a paging file // check to see if this drive is used for a paging file
if (SendDlgItemMessage(pVirtMem->hSelf, if (SendDlgItemMessage(pVirtMem->hSelf,
IDC_NOPAGEFILE, IDC_NOPAGEFILE,
BM_GETCHECK, BM_GETCHECK,
0, 0,
0) == BST_UNCHECKED) 0) == BST_UNCHECKED)
{ {
pVirtMem->Pagefile[Index].bUsed = TRUE; pVirtMem->Pagefile[Index].bUsed = TRUE;
} }
else else
{ {
pVirtMem->Pagefile[Index].bUsed = FALSE; pVirtMem->Pagefile[Index].bUsed = FALSE;
} }
} }
} }
} }
@ -366,135 +365,135 @@ static BOOL
OnSelChange(PVIRTMEM pVirtMem, OnSelChange(PVIRTMEM pVirtMem,
LPNMLISTVIEW pnmv) LPNMLISTVIEW pnmv)
{ {
TCHAR szCustVals[255]; TCHAR szCustVals[255];
INT Index; INT Index;
UNREFERENCED_PARAMETER(pnmv); UNREFERENCED_PARAMETER(pnmv);
Index = (INT)SendDlgItemMessage(pVirtMem->hSelf, Index = (INT)SendDlgItemMessage(pVirtMem->hSelf,
IDC_PAGEFILELIST, IDC_PAGEFILELIST,
LB_GETCURSEL, LB_GETCURSEL,
0, 0,
0); 0);
if(Index < pVirtMem->Count) if(Index < pVirtMem->Count)
{ {
if(pVirtMem->Pagefile[Index].InitialValue != 0 && if(pVirtMem->Pagefile[Index].InitialValue != 0 &&
pVirtMem->Pagefile[Index].MaxValue != 0) pVirtMem->Pagefile[Index].MaxValue != 0)
{ {
/* enable and fill the custom values */ /* enable and fill the custom values */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), TRUE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), TRUE);
_itot(pVirtMem->Pagefile[Index].InitialValue , szCustVals, 10); _itot(pVirtMem->Pagefile[Index].InitialValue , szCustVals, 10);
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_INITIALSIZE, IDC_INITIALSIZE,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)szCustVals); (LPARAM)szCustVals);
_itot(pVirtMem->Pagefile[Index].MaxValue, szCustVals, 10); _itot(pVirtMem->Pagefile[Index].MaxValue, szCustVals, 10);
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_MAXSIZE, IDC_MAXSIZE,
WM_SETTEXT, WM_SETTEXT,
0, 0,
(LPARAM)szCustVals); (LPARAM)szCustVals);
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_CUSTOM, IDC_CUSTOM,
BM_SETCHECK, BM_SETCHECK,
1, 1,
0); 0);
} }
else else
{ {
/* It's not a custom value */ /* It's not a custom value */
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_MAXSIZE), FALSE);
EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE); EnableWindow(GetDlgItem(pVirtMem->hSelf, IDC_INITIALSIZE), FALSE);
/* is it system managed */ /* is it system managed */
if(pVirtMem->Pagefile[Index].bUsed) if(pVirtMem->Pagefile[Index].bUsed)
{ {
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_SYSMANSIZE, IDC_SYSMANSIZE,
BM_SETCHECK, BM_SETCHECK,
1, 1,
0); 0);
} }
else else
{ {
SendDlgItemMessage(pVirtMem->hSelf, SendDlgItemMessage(pVirtMem->hSelf,
IDC_NOPAGEFILE, IDC_NOPAGEFILE,
BM_SETCHECK, BM_SETCHECK,
1, 1,
0); 0);
} }
} }
} }
return TRUE; return TRUE;
} }
static VOID static VOID
OnOk(PVIRTMEM pVirtMem) OnOk(PVIRTMEM pVirtMem)
{ {
if(pVirtMem->bSave == TRUE) if(pVirtMem->bSave == TRUE)
{ {
WritePageFileSettings(pVirtMem); WritePageFileSettings(pVirtMem);
} }
if (pVirtMem->szPagingFiles) if (pVirtMem->szPagingFiles)
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
pVirtMem->szPagingFiles); pVirtMem->szPagingFiles);
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
pVirtMem); pVirtMem);
} }
static VOID static VOID
OnCancel(PVIRTMEM pVirtMem) OnCancel(PVIRTMEM pVirtMem)
{ {
if (pVirtMem->szPagingFiles) if (pVirtMem->szPagingFiles)
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
pVirtMem->szPagingFiles); pVirtMem->szPagingFiles);
HeapFree(GetProcessHeap(), HeapFree(GetProcessHeap(),
0, 0,
pVirtMem); pVirtMem);
} }
static PVIRTMEM static PVIRTMEM
OnInitDialog(HWND hwnd) OnInitDialog(HWND hwnd)
{ {
PVIRTMEM pVirtMem = (PVIRTMEM)HeapAlloc(GetProcessHeap(), PVIRTMEM pVirtMem = (PVIRTMEM)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
sizeof(VIRTMEM)); sizeof(VIRTMEM));
if (pVirtMem == NULL) if (pVirtMem == NULL)
{ {
EndDialog(hwnd, 0); EndDialog(hwnd, 0);
} }
pVirtMem->hSelf = hwnd; pVirtMem->hSelf = hwnd;
pVirtMem->hListView = GetDlgItem(hwnd, IDC_PAGEFILELIST); pVirtMem->hListView = GetDlgItem(hwnd, IDC_PAGEFILELIST);
pVirtMem->bSave = FALSE; pVirtMem->bSave = FALSE;
SetListViewColumns(pVirtMem->hListView); SetListViewColumns(pVirtMem->hListView);
/* Load the pagefile systems from the reg */ /* Load the pagefile systems from the reg */
if (ReadPageFileSettings(pVirtMem)) if (ReadPageFileSettings(pVirtMem))
{ {
/* Parse our settings and set up dialog */ /* Parse our settings and set up dialog */
ParseMemSettings(pVirtMem); ParseMemSettings(pVirtMem);
} }
return pVirtMem; return pVirtMem;
} }
@ -504,67 +503,66 @@ VirtMemDlgProc(HWND hwndDlg,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
/* there can only be one instance of this dialog */ /* there can only be one instance of this dialog */
static PVIRTMEM pVirtMem = NULL; static PVIRTMEM pVirtMem = NULL;
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch (uMsg) switch (uMsg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
pVirtMem = OnInitDialog(hwndDlg); pVirtMem = OnInitDialog(hwndDlg);
break; break;
case WM_COMMAND: case WM_COMMAND:
{ {
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDCANCEL: case IDCANCEL:
OnCancel(pVirtMem); OnCancel(pVirtMem);
EndDialog(hwndDlg, 0); EndDialog(hwndDlg, 0);
return TRUE; return TRUE;
case IDOK: case IDOK:
OnOk(pVirtMem); OnOk(pVirtMem);
EndDialog(hwndDlg, 0); EndDialog(hwndDlg, 0);
return TRUE; return TRUE;
case IDC_NOPAGEFILE: case IDC_NOPAGEFILE:
OnNoPagingFile(pVirtMem); OnNoPagingFile(pVirtMem);
return TRUE; return TRUE;
case IDC_SYSMANSIZE: case IDC_SYSMANSIZE:
OnSysManSize(pVirtMem); OnSysManSize(pVirtMem);
return TRUE; return TRUE;
case IDC_CUSTOM: case IDC_CUSTOM:
OnCustom(pVirtMem); OnCustom(pVirtMem);
return TRUE; return TRUE;
case IDC_SET: case IDC_SET:
OnSet(pVirtMem); OnSet(pVirtMem);
return TRUE; return TRUE;
} }
} }
break; break;
case WM_NOTIFY: case WM_NOTIFY:
{ {
LPNMHDR pnmhdr = (LPNMHDR)lParam; LPNMHDR pnmhdr = (LPNMHDR)lParam;
switch (pnmhdr->code) switch (pnmhdr->code)
{ {
case LVN_ITEMCHANGED: case LVN_ITEMCHANGED:
{ {
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam; LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
OnSelChange(pVirtMem, pnmv); OnSelChange(pVirtMem, pnmv);
}
}
}
break;
}
} return FALSE;
}
}
break;
}
return FALSE;
} }