add shell extension for displaying processor information in device manager

svn path=/trunk/; revision=29249
This commit is contained in:
Christoph von Wittich 2007-09-27 17:04:44 +00:00
parent f36fe07cbe
commit de304494a0
6 changed files with 187 additions and 0 deletions

View file

@ -0,0 +1,7 @@
LIBRARY devcpux.dll
EXPORTS
PropSheetExtProc@12
; EOF

View file

@ -0,0 +1,19 @@
<module name="devcpux" type="win32dll" installbase="system32" installname="devcpux.dll">
<importlibrary definition="devcpux.def" />
<include base="devcpux">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="UNICODE" />
<define name="_UNICODE" />
<define name="__REACTOS__" />
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x600</define>
<define name="_WIN32_WINNT">0x501</define>
<define name="WINVER">0x501</define>
<library>kernel32</library>
<library>user32</library>
<library>ntdll</library>
<library>powrprof</library>
<library>comctl32</library>
<file>processor.c</file>
<file>processor.rc</file>
</module>

View file

@ -0,0 +1,121 @@
/*
* PROJECT: ReactOS Shell Extensions
* LICENSE: LGPL - See COPYING in the top level directory
* FILE: dll\win32\shellext\devcpux\processor.c
* PURPOSE:
* COPYRIGHT: Copyright 2007 Christoph von Wittich <Christoph_vW@ReactOS.org>
*
*/
#include <windows.h>
#include <setupapi.h>
#include <powrprof.h>
#include "resource.h"
HINSTANCE g_hInstance = NULL;
int APIENTRY ProcessorDlgProc (HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
BOOL
APIENTRY
DllMain (HANDLE hInstance, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_ATTACH:
case DLL_PROCESS_DETACH:
break;
}
g_hInstance = (HINSTANCE) hInstance;
return TRUE;
}
BOOL
APIENTRY
PropSheetExtProc(PSP_PROPSHEETPAGE_REQUEST PropPageRequest, LPFNADDPROPSHEETPAGE fAddFunc, LPARAM lParam)
{
PROPSHEETPAGE PropSheetPage;
HPROPSHEETPAGE hPropSheetPage;
if(PropPageRequest->PageRequested != SPPSR_ENUM_ADV_DEVICE_PROPERTIES)
return FALSE;
if ((!PropPageRequest->DeviceInfoSet) || (!PropPageRequest->DeviceInfoData))
return FALSE;
ZeroMemory(&PropSheetPage, sizeof(PROPSHEETPAGE));
PropSheetPage.dwSize = sizeof(PROPSHEETPAGE);
PropSheetPage.hInstance = g_hInstance;
PropSheetPage.pszTemplate = MAKEINTRESOURCE(DLG_PROCESSORINFO);
PropSheetPage.pfnDlgProc = ProcessorDlgProc;
hPropSheetPage = CreatePropertySheetPage(&PropSheetPage);
if(hPropSheetPage)
return FALSE;
if(!(*fAddFunc)(hPropSheetPage, lParam)) {
DestroyPropertySheetPage (hPropSheetPage);
return FALSE;
}
return TRUE;
}
void
AddFeature(WCHAR* szFeatures, WCHAR* Feature, BOOL* bFirst)
{
if (!*bFirst)
wcscat(szFeatures, L", ");
*bFirst = FALSE;
wcscat(szFeatures, Feature);
}
int
APIENTRY
ProcessorDlgProc (HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
switch (uMessage) {
case WM_INITDIALOG:
{
WCHAR szFeatures[MAX_PATH] = L"";
WCHAR szModel[3];
WCHAR szStepping[3];
WCHAR szCurrentMhz[10];
BOOL bFirst = TRUE;
SYSTEM_INFO SystemInfo;
PROCESSOR_POWER_INFORMATION PowerInfo;
if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE))
AddFeature(szFeatures, L"MMX", &bFirst);
if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE))
AddFeature(szFeatures, L"SSE", &bFirst);
if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
AddFeature(szFeatures, L"SSE2", &bFirst);
/*if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
AddFeature(szFeatures, L"SSE3", &bFirst); */
if (IsProcessorFeaturePresent(PF_3DNOW_INSTRUCTIONS_AVAILABLE))
AddFeature(szFeatures, L"3DNOW", &bFirst);
SetDlgItemTextW(hDlg, IDC_FEATURES, szFeatures);
GetSystemInfo(&SystemInfo);
wsprintf(szModel, L"%x", HIBYTE(SystemInfo.wProcessorRevision));
wsprintf(szStepping, L"%d", LOBYTE(SystemInfo.wProcessorRevision));
SetDlgItemTextW(hDlg, IDC_MODEL, szModel);
SetDlgItemTextW(hDlg, IDC_STEPPING, szStepping);
CallNtPowerInformation(11, NULL, 0, &PowerInfo, sizeof(PowerInfo));
wsprintf(szCurrentMhz, L"%ld %s", PowerInfo.CurrentMhz, L"MHz");
SetDlgItemTextW(hDlg, IDC_CORESPEED, szCurrentMhz);
return TRUE;
}
}
return FALSE;
}

View file

@ -0,0 +1,31 @@
#include <windows.h>
#include "resource.h"
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Processor Shell Extension\0"
#define REACTOS_STR_INTERNAL_NAME "processorext\0"
#define REACTOS_STR_ORIGINAL_FILENAME "processorext.dll\0"
#include <reactos/version.rc>
DLG_PROCESSORINFO DIALOG DISCARDABLE 0, 0, 200, 220
STYLE WS_POPUP | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "CPU"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "Features:",-1,5,23,50,51
LTEXT "Test",IDC_FEATURES,50,23,80,51
LTEXT "Model:",-1,5,33,50,51
LTEXT "test",IDC_MODEL,50,33,80,51
LTEXT "Stepping:",-1,5,43,50,51
LTEXT "test",IDC_STEPPING,50,43,80,51
LTEXT "Core Speed:",-1,5,53,50,51
LTEXT "test",IDC_CORESPEED,50,53,80,51
END

View file

@ -0,0 +1,6 @@
#define DLG_PROCESSORINFO 201
#define IDC_FEATURES 301
#define IDC_MODEL 302
#define IDC_STEPPING 303
#define IDC_CORESPEED 304

View file

@ -10,4 +10,7 @@
<directory name="deskmon">
<xi:include href="deskmon/deskmon.rbuild" />
</directory>
<directory name="devcpux">
<xi:include href="devcpux/devcpux.rbuild" />
</directory>
</group>