2 * PROJECT: ReactOS System Control Panel Applet
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/sysdm/general.c
5 * PURPOSE: General System Information
6 * COPYRIGHT: Copyright Thomas Weidenmueller <w3seek@reactos.org>
7 * Copyright 2006 Ged Murphy <gedmurphy@gmail.com>
14 typedef struct _IMGINFO
23 ShowLastWin32Error(HWND hWndOwner
)
28 LastError
= GetLastError();
30 if((LastError
== 0) ||
31 !FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
32 FORMAT_MESSAGE_FROM_SYSTEM
,
35 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
43 MessageBox(hWndOwner
, lpMsg
, NULL
, MB_OK
| MB_ICONERROR
);
45 LocalFree((LPVOID
)lpMsg
);
50 InitImageInfo(PIMGINFO ImgInfo
)
54 ZeroMemory(ImgInfo
, sizeof(*ImgInfo
));
56 ImgInfo
->hBitmap
= LoadImage(hApplet
,
57 MAKEINTRESOURCE(IDB_ROSBMP
),
63 if (ImgInfo
->hBitmap
!= NULL
)
65 GetObject(ImgInfo
->hBitmap
, sizeof(BITMAP
), &bitmap
);
67 ImgInfo
->cxSource
= bitmap
.bmWidth
;
68 ImgInfo
->cySource
= bitmap
.bmHeight
;
74 SetRegTextData(HWND hwnd
,
83 if (RegQueryValueEx(hKey
,
88 &BufSize
) == ERROR_SUCCESS
)
90 lpBuf
= HeapAlloc(GetProcessHeap(),
95 if (RegQueryValueEx(hKey
,
100 &BufSize
) == ERROR_SUCCESS
)
107 HeapFree(GetProcessHeap(),
114 SetProcSpeed(HWND hwnd
,
122 DWORD BufSize
= sizeof(DWORD
);
125 if (RegQueryValueEx(hKey
,
130 &BufSize
) == ERROR_SUCCESS
)
134 _stprintf(szBuf
, _T("%.2f MHz"), dwBuf
);
138 double flt
= dwBuf
/ 1000.0;
139 _stprintf(szBuf
, _T("%.2f GHz"), flt
);
149 GetSystemInformation(HWND hwnd
)
152 TCHAR ProcKey
[] = _T("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
153 MEMORYSTATUSEX MemStat
;
158 /* Get Processor information *
159 * although undocumented, this information is being pulled
160 * directly out of the registry instead of via setupapi as it
161 * contains all the info we need, and should remain static
163 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
167 &hKey
) == ERROR_SUCCESS
)
171 _T("VendorIdentifier"),
172 IDC_PROCESSORMANUFACTURER
);
176 _T("ProcessorNameString"),
186 /* Get total physical RAM */
187 MemStat
.dwLength
= sizeof(MemStat
);
188 if (GlobalMemoryStatusEx(&MemStat
))
193 static const UINT uStrId
[] = {
200 if (MemStat
.ullTotalPhys
> 1024 * 1024 * 1024)
202 /* We're dealing with GBs or more */
203 MemStat
.ullTotalPhys
/= 1024 * 1024;
206 if (MemStat
.ullTotalPhys
> 1024 * 1024)
208 /* We're dealing with TBs or more */
209 MemStat
.ullTotalPhys
/= 1024;
212 if (MemStat
.ullTotalPhys
> 1024 * 1024)
214 /* We're dealing with PBs or more */
216 MemStat
.ullTotalPhys
/= 1024;
219 dTotalPhys
= (double)MemStat
.ullTotalPhys
/ 1024;
222 dTotalPhys
= (double)MemStat
.ullTotalPhys
/ 1024;
225 dTotalPhys
= (double)MemStat
.ullTotalPhys
/ 1024;
229 /* We're daling with MBs */
230 dTotalPhys
= (double)MemStat
.ullTotalPhys
/ 1024 / 1024;
233 if (LoadString(hApplet
, uStrId
[i
], szStr
, sizeof(szStr
) / sizeof(szStr
[0])))
235 Ret
= _stprintf(Buf
, _T("%.2f %s"), dTotalPhys
, szStr
);
248 /* Property page dialog callback */
250 GeneralPageProc(HWND hwndDlg
,
255 static IMGINFO ImgInfo
;
257 UNREFERENCED_PARAMETER(lParam
);
258 UNREFERENCED_PARAMETER(wParam
);
264 HWND hLink
= GetDlgItem(hwndDlg
, IDC_ROSHOMEPAGE_LINK
);
267 _T("http://www.reactos.org"),
270 InitImageInfo(&ImgInfo
);
271 GetSystemInformation(hwndDlg
);
277 if (LOWORD(wParam
) == IDC_LICENCE
)
280 MAKEINTRESOURCE(IDD_LICENCE
),
291 LPDRAWITEMSTRUCT lpDrawItem
;
292 lpDrawItem
= (LPDRAWITEMSTRUCT
) lParam
;
293 if(lpDrawItem
->CtlID
== IDC_ROSIMG
)
298 /* position image in centre of dialog */
299 left
= (lpDrawItem
->rcItem
.right
- ImgInfo
.cxSource
) / 2;
301 hdcMem
= CreateCompatibleDC(lpDrawItem
->hDC
);
304 SelectObject(hdcMem
, ImgInfo
.hBitmap
);
305 BitBlt(lpDrawItem
->hDC
,
307 lpDrawItem
->rcItem
.top
,
308 lpDrawItem
->rcItem
.right
- lpDrawItem
->rcItem
.left
,
309 lpDrawItem
->rcItem
.bottom
- lpDrawItem
->rcItem
.top
,