ReactOS 0.4.16-dev-197-g92996da
processor.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Shell Extensions
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: dll/shellext/devcpux/processor.c
5 * PURPOSE:
6 * COPYRIGHT: Copyright 2007 Christoph von Wittich <Christoph_vW@ReactOS.org>
7 *
8 */
9
10#define WIN32_NO_STATUS
11#define _INC_WINDOWS
12#define COM_NO_WINDOWS_H
13#include <stdarg.h>
14#include <windef.h>
15#include <winbase.h>
16#include <winreg.h>
17#include <winuser.h>
18#include <setupapi.h>
19#include <powrprof.h>
20#include <strsafe.h>
21
22#include "resource.h"
23
26
27BOOL
30{
31 switch (dwReason)
32 {
37 break;
38 }
39
41 return TRUE;
42}
43
44
45BOOL
48{
50 HPROPSHEETPAGE hPropSheetPage;
51
53 return FALSE;
54
55 if ((!PropPageRequest->DeviceInfoSet) || (!PropPageRequest->DeviceInfoData))
56 return FALSE;
57
59 PropSheetPage.dwSize = sizeof(PROPSHEETPAGE);
60 PropSheetPage.hInstance = g_hInstance;
63
64 hPropSheetPage = CreatePropertySheetPage(&PropSheetPage);
65 if(!hPropSheetPage)
66 return FALSE;
67
68 if(!(fAddFunc)(hPropSheetPage, lParam)) {
69 DestroyPropertySheetPage (hPropSheetPage);
70 return FALSE;
71 }
72
73 return TRUE;
74}
75
76void
77AddFeature(WCHAR* szFeatures, size_t cbDest, WCHAR* Feature, BOOL* bFirst)
78{
79 if (!*bFirst)
80 StringCbCatW(szFeatures, cbDest, L", ");
81 *bFirst = FALSE;
82 StringCbCatW(szFeatures, cbDest, Feature);
83}
84
88{
89 switch (uMessage) {
90 case WM_INITDIALOG:
91 {
92 WCHAR szFeatures[MAX_PATH] = L"";
93 WCHAR szModel[3];
94 WCHAR szStepping[3];
95 WCHAR szMhz[16];
96 WCHAR szCurrentMhz[10];
97 BOOL bFirst = TRUE;
98 SYSTEM_INFO SystemInfo;
100
101 if (!LoadStringW(g_hInstance, IDS_MEGAHERTZ, szMhz, ARRAYSIZE(szMhz)))
102 {
103 StringCbCopyW(szMhz, sizeof(szMhz), L"%ld MHz");
104 }
105
107 AddFeature(szFeatures, sizeof(szFeatures), L"MMX", &bFirst);
109 AddFeature(szFeatures, sizeof(szFeatures), L"SSE", &bFirst);
111 AddFeature(szFeatures, sizeof(szFeatures), L"SSE2", &bFirst);
112 /*if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
113 AddFeature(szFeatures, sizeof(szFeatures), L"SSE3", &bFirst); */
115 AddFeature(szFeatures, sizeof(szFeatures), L"3DNOW", &bFirst);
116
117 SetDlgItemTextW(hDlg, IDC_FEATURES, szFeatures);
118
119 GetSystemInfo(&SystemInfo);
120
121 StringCbPrintfW(szModel, sizeof(szModel), L"%x", HIBYTE(SystemInfo.wProcessorRevision));
122 StringCbPrintfW(szStepping, sizeof(szStepping), L"%d", LOBYTE(SystemInfo.wProcessorRevision));
123
124 SetDlgItemTextW(hDlg, IDC_MODEL, szModel);
125 SetDlgItemTextW(hDlg, IDC_STEPPING, szStepping);
126
127 CallNtPowerInformation(11, NULL, 0, &PowerInfo, sizeof(PowerInfo));
128 StringCbPrintfW(szCurrentMhz, sizeof(szCurrentMhz), szMhz, PowerInfo.CurrentMhz);
129 SetDlgItemTextW(hDlg, IDC_CORESPEED, szCurrentMhz);
130
131 return TRUE;
132 }
133 }
134 return FALSE;
135}
DWORD dwReason
Definition: misc.cpp:141
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
Definition: cdrom.h:1077
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_MEGAHERTZ
Definition: resource.h:62
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define APIENTRY
Definition: api.h:79
INT_PTR CALLBACK ProcessorDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
Definition: processor.c:87
BOOL APIENTRY DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
Definition: processor.c:29
HINSTANCE g_hInstance
Definition: processor.c:24
void AddFeature(WCHAR *szFeatures, size_t cbDest, WCHAR *Feature, BOOL *bFirst)
Definition: processor.c:77
BOOL APIENTRY PropSheetExtProc(PSP_PROPSHEETPAGE_REQUEST PropPageRequest, LPFNADDPROPSHEETPAGE fAddFunc, LPARAM lParam)
Definition: processor.c:47
#define DLG_PROCESSORINFO
Definition: resource.h:3
#define IDC_STEPPING
Definition: resource.h:7
#define IDC_CORESPEED
Definition: resource.h:8
#define IDC_FEATURES
Definition: resource.h:5
#define IDC_MODEL
Definition: resource.h:6
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3155
#define DLL_THREAD_DETACH
Definition: compat.h:133
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
#define DLL_THREAD_ATTACH
Definition: compat.h:132
VOID WINAPI GetSystemInfo(IN LPSYSTEM_INFO lpSystemInfo)
Definition: sysinfo.c:143
BOOL WINAPI IsProcessorFeaturePresent(IN DWORD ProcessorFeature)
Definition: sysinfo.c:169
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LOBYTE(W)
Definition: jmemdos.c:487
#define HIBYTE(W)
Definition: jmemdos.c:486
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define L(x)
Definition: ntvdm.h:50
NTSTATUS WINAPI CallNtPowerInformation(POWER_INFORMATION_LEVEL InformationLevel, PVOID lpInputBuffer, ULONG nInputBufferSize, PVOID lpOutputBuffer, ULONG nOutputBufferSize)
Definition: powrprof.c:59
#define CreatePropertySheetPage
Definition: prsht.h:399
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
#define PROPSHEETPAGE
Definition: prsht.h:389
#define SPPSR_ENUM_ADV_DEVICE_PROPERTIES
Definition: setupapi.h:615
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
STRSAFEAPI StringCbCatW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:342
PSP_DEVINFO_DATA DeviceInfoData
Definition: setupapi.h:1104
WORD wProcessorRevision
Definition: winbase.h:1205
HANDLE HINSTANCE
Definition: typedefs.h:77
int32_t INT_PTR
Definition: typedefs.h:64
#define ZeroMemory
Definition: winbase.h:1736
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define WM_INITDIALOG
Definition: winuser.h:1742
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define PF_3DNOW_INSTRUCTIONS_AVAILABLE
Definition: ketypes.h:131
#define PF_MMX_INSTRUCTIONS_AVAILABLE
Definition: ketypes.h:127
#define PF_XMMI64_INSTRUCTIONS_AVAILABLE
Definition: ketypes.h:134
#define PF_XMMI_INSTRUCTIONS_AVAILABLE
Definition: ketypes.h:130
__wchar_t WCHAR
Definition: xmlstorage.h:180