From a1bf8bb33946b962ccc80e660b48fd74de90c54c Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 26 Nov 2005 02:12:58 +0000 Subject: [PATCH] display the advanced device properties svn path=/trunk/; revision=19599 --- reactos/lib/devmgr/hwpage.c | 84 +++++++++++++++++++++++++++++++----- reactos/lib/devmgr/precomp.h | 26 ++++++++++- reactos/lib/devmgr/stubs.c | 4 +- 3 files changed, 99 insertions(+), 15 deletions(-) diff --git a/reactos/lib/devmgr/hwpage.c b/reactos/lib/devmgr/hwpage.c index 6cc7b068085..b596caccebb 100644 --- a/reactos/lib/devmgr/hwpage.c +++ b/reactos/lib/devmgr/hwpage.c @@ -126,6 +126,70 @@ InitializeDevicesList(IN PHARDWARE_PAGE_DATA hpd) } +static BOOL +DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd) +{ + PHWDEVINFO HwDevInfo; + BOOL Ret = FALSE; + + HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList); + if (HwDevInfo != NULL) + { + PWSTR szDeviceInstanceId = NULL; + DWORD DeviceInstanceIdLen = 0; + + /* find out how much size is needed for the buffer */ + if (SetupDiGetDeviceInstanceId(HwDevInfo->ClassDevInfo->hDevInfo, + &HwDevInfo->DevInfoData, + NULL, + 0, + &DeviceInstanceIdLen)) + { + DPRINT1("SetupDiGetDeviceInterfaceDetail unexpectedly returned TRUE!\n"); + goto Cleanup; + } + + if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) + { + goto Cleanup; + } + + szDeviceInstanceId = HeapAlloc(GetProcessHeap(), + 0, + DeviceInstanceIdLen * sizeof(WCHAR)); + if (szDeviceInstanceId == NULL) + { + goto Cleanup; + } + + /* read the device instance id */ + if (!SetupDiGetDeviceInstanceId(HwDevInfo->ClassDevInfo->hDevInfo, + &HwDevInfo->DevInfoData, + szDeviceInstanceId, + DeviceInstanceIdLen, + &DeviceInstanceIdLen)) + { + goto Cleanup; + } + + /* display the properties dialog */ + Ret = DeviceAdvancedProperties(hpd->hWnd, + NULL, + szDeviceInstanceId) >= 0; + +Cleanup: + if (szDeviceInstanceId != NULL) + { + HeapFree(GetProcessHeap(), + 0, + szDeviceInstanceId); + } + } + + return Ret; +} + + static VOID UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd) { @@ -158,6 +222,10 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd) RegDataType != REG_SZ) { szBuffer[0] = L'\0'; + LoadString(hDllInstance, + IDS_UNKNOWN, + szBuffer, + sizeof(szBuffer) / sizeof(szBuffer[0])); } /* FIXME - check string for NULL termination! */ if (LoadAndFormatString(hDllInstance, @@ -183,15 +251,10 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd) RegDataType != REG_SZ) { szBuffer[0] = L'\0'; - - if (cRet == CR_NO_SUCH_REGISTRY_KEY || - cRet == CR_NO_SUCH_VALUE) - { - LoadString(hDllInstance, - IDS_UNKNOWN, - szBuffer, - sizeof(szBuffer) / sizeof(szBuffer[0])); - } + LoadString(hDllInstance, + IDS_UNKNOWN, + szBuffer, + sizeof(szBuffer) / sizeof(szBuffer[0])); } /* FIXME - check string for NULL termination! */ @@ -756,8 +819,7 @@ HardwareDlgProc(IN HWND hwndDlg, case IDC_PROPERTIES: { - /* FIXME - display the properties dialog for the currently - selected device */ + DisplaySelectedDeviceProperties(hpd); break; } } diff --git a/reactos/lib/devmgr/precomp.h b/reactos/lib/devmgr/precomp.h index f779f50f90c..baf6d8b0f98 100644 --- a/reactos/lib/devmgr/precomp.h +++ b/reactos/lib/devmgr/precomp.h @@ -145,19 +145,41 @@ DeviceCreateHardwarePageEx(HWND hWndParent, int WINAPI DevicePropertiesExA(HWND hWndParent, - HINSTANCE hInst, LPCSTR lpMachineName, LPCSTR lpDeviceID, + HINSTANCE hInst, DWORD Unknown); int WINAPI DevicePropertiesExW(HWND hWndParent, - HINSTANCE hInst, LPCWSTR lpMachineName, LPCWSTR lpDeviceID, + HINSTANCE hInst, DWORD Unknown); +#ifdef UNICODE +#define DeviceManager_Execute DeviceManager_ExecuteW +#define DeviceProperties_RunDLL DeviceProperties_RunDLLW +#define DeviceProperties DevicePropertiesW +#define DeviceProblemText DeviceProblemTextW +#define DeviceProblemWizard DeviceProblemWizardW +#define DeviceProblemWizard_RunDLL DeviceProblemWizard_RunDLLW +#define DeviceManagerPrint DeviceManagerPrintW +#define DeviceAdvancedProperties DeviceAdvancedPropertiesW +#define DevicePropertiesEx DevicePropertiesExW +#else +#define DeviceManager_Execute DeviceManager_ExecuteA +#define DeviceProperties_RunDLL DeviceProperties_RunDLLA +#define DeviceProperties DevicePropertiesA +#define DeviceProblemText DeviceProblemTextA +#define DeviceProblemWizard DeviceProblemWizardA +#define DeviceProblemWizard_RunDLL DeviceProblemWizard_RunDLLA +#define DeviceManagerPrint DeviceManagerPrintA +#define DeviceAdvancedProperties DeviceAdvancedPropertiesA +#define DevicePropertiesEx DevicePropertiesExA +#endif + /* MISC.C */ DWORD diff --git a/reactos/lib/devmgr/stubs.c b/reactos/lib/devmgr/stubs.c index c5f3dd1a0d7..0d80ee6c58d 100644 --- a/reactos/lib/devmgr/stubs.c +++ b/reactos/lib/devmgr/stubs.c @@ -640,9 +640,9 @@ DeviceAdvancedPropertiesW(HWND hWndParent, int WINAPI DevicePropertiesExA(HWND hWndParent, - HINSTANCE hInst, LPCSTR lpMachineName, LPCSTR lpDeviceID, + HINSTANCE hInst, DWORD Unknown) { UNIMPLEMENTED; @@ -678,9 +678,9 @@ DevicePropertiesExA(HWND hWndParent, int WINAPI DevicePropertiesExW(HWND hWndParent, - HINSTANCE hInst, LPCWSTR lpMachineName, LPCWSTR lpDeviceID, + HINSTANCE hInst, DWORD Unknown) { UNIMPLEMENTED;