handle device updates in the advanced property pages and refresh the
information
Modified: trunk/reactos/lib/devmgr/advprop.c
Modified: trunk/reactos/lib/devmgr/hwpage.c
Modified: trunk/reactos/lib/devmgr/precomp.h
_____
Modified: trunk/reactos/lib/devmgr/advprop.c
--- trunk/reactos/lib/devmgr/advprop.c 2005-12-01 17:08:52 UTC (rev
19799)
+++ trunk/reactos/lib/devmgr/advprop.c 2005-12-01 17:23:26 UTC (rev
19800)
@@ -51,6 +51,8 @@
BOOL DeviceEnabled;
WCHAR szDevName[255];
WCHAR szTemp[255];
+ WCHAR szDeviceID[1];
+ /* struct may be dynamically expanded here! */
} DEVADVPROP_INFO, *PDEVADVPROP_INFO;
@@ -188,11 +190,25 @@
static VOID
UpdateDevInfo(IN HWND hwndDlg,
- IN PDEVADVPROP_INFO dap)
+ IN PDEVADVPROP_INFO dap,
+ IN BOOL ReOpenDevice)
{
HICON hIcon;
HWND hDevUsage;
+ if (ReOpenDevice)
+ {
+ /* note, we ignore the fact that SetupDiOpenDeviceInfo could
fail here,
+ in case of failure we're still going to query information
from it even
+ though those calls are going to fail. But they return
readable strings
+ even in that case. */
+ SetupDiOpenDeviceInfo(dap->DeviceInfoSet,
+ dap->szDeviceID,
+ hwndDlg,
+ 0,
+ dap->DeviceInfoData);
+ }
+
/* get the device name */
if (GetDeviceDescriptionString(dap->DeviceInfoSet,
dap->DeviceInfoData,
@@ -367,7 +383,8 @@
(DWORD_PTR)dap);
UpdateDevInfo(hwndDlg,
- dap);
+ dap,
+ FALSE);
}
Ret = TRUE;
break;
@@ -377,7 +394,8 @@
{
/* FIXME - don't call UpdateDevInfo in all events */
UpdateDevInfo(hwndDlg,
- dap);
+ dap,
+ TRUE);
break;
}
@@ -406,6 +424,7 @@
INT_PTR
DisplayDeviceAdvancedProperties(IN HWND hWndParent,
+ IN LPCWSTR lpDeviceID OPTIONAL,
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN HINSTANCE hComCtl32,
@@ -420,6 +439,7 @@
PDEVADVPROP_INFO DevAdvPropInfo;
DWORD PropertySheetType;
HANDLE hMachine = NULL;
+ DWORD DevIdSize = 0;
INT_PTR Ret = -1;
/* we don't want to statically link against comctl32, so find the
@@ -440,6 +460,29 @@
return -1;
}
+ if (lpDeviceID == NULL)
+ {
+ /* find out how much size is needed for the device id */
+ if (SetupDiGetDeviceInstanceId(DeviceInfoSet,
+ DeviceInfoData,
+ NULL,
+ 0,
+ &DevIdSize))
+ {
+ DPRINT1("SetupDiGetDeviceInterfaceDetail unexpectedly
returned TRUE!\n");
+ return -1;
+ }
+
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
+ {
+ return -1;
+ }
+ }
+ else
+ {
+ DevIdSize = (DWORD)wcslen(lpDeviceID) + 1;
+ }
+
if (lpMachineName != NULL)
{
CONFIGRET cr = CM_Connect_Machine(lpMachineName,
@@ -454,12 +497,27 @@
"Driver", ... pages */
DevAdvPropInfo = HeapAlloc(GetProcessHeap(),
0,
- sizeof(DEVADVPROP_INFO));
+ FIELD_OFFSET(DEVADVPROP_INFO,
+ szDeviceID) +
+ (DevIdSize * sizeof(WCHAR)));
if (DevAdvPropInfo == NULL)
{
goto Cleanup;
}
+ if (lpDeviceID == NULL)
+ {
+ /* read the device instance id */
+ if (!SetupDiGetDeviceInstanceId(DeviceInfoSet,
+ DeviceInfoData,
+ DevAdvPropInfo->szDeviceID,
+ DevIdSize,
+ NULL))
+ {
+ goto Cleanup;
+ }
+ }
+
DevAdvPropInfo->DeviceInfoSet = DeviceInfoSet;
DevAdvPropInfo->DeviceInfoData = DeviceInfoData;
DevAdvPropInfo->hComCtl32 = hComCtl32;
@@ -630,6 +688,7 @@
&DevInfoData))
{
Ret = DisplayDeviceAdvancedProperties(hWndParent,
+ lpDeviceID,
hDevInfo,
&DevInfoData,
hComCtl32,
_____
Modified: trunk/reactos/lib/devmgr/hwpage.c
--- trunk/reactos/lib/devmgr/hwpage.c 2005-12-01 17:08:52 UTC (rev
19799)
+++ trunk/reactos/lib/devmgr/hwpage.c 2005-12-01 17:23:26 UTC (rev
19800)
@@ -135,6 +135,7 @@
if (HwDevInfo != NULL)
{
Ret = DisplayDeviceAdvancedProperties(hpd->hWnd,
+ NULL,
HwDevInfo->ClassDevInfo->hDevInfo,
&HwDevInfo->DevInfoData,
hpd->hComCtl32,
_____
Modified: trunk/reactos/lib/devmgr/precomp.h
--- trunk/reactos/lib/devmgr/precomp.h 2005-12-01 17:08:52 UTC (rev
19799)
+++ trunk/reactos/lib/devmgr/precomp.h 2005-12-01 17:23:26 UTC (rev
19800)
@@ -184,6 +184,7 @@
INT_PTR
DisplayDeviceAdvancedProperties(IN HWND hWndParent,
+ IN LPCWSTR lpDeviceID OPTIONAL,
IN HDEVINFO DeviceInfoSet,
IN PSP_DEVINFO_DATA DeviceInfoData,
IN HINSTANCE hComCtl32,