- support remote device property sheets
authorThomas Bluemel <thomas@reactsoft.com>
Wed, 30 Nov 2005 16:33:05 +0000 (16:33 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Wed, 30 Nov 2005 16:33:05 +0000 (16:33 +0000)
- display the device status

svn path=/trunk/; revision=19777

reactos/lib/devmgr/En.rc
reactos/lib/devmgr/advprop.c
reactos/lib/devmgr/devmgr.xml
reactos/lib/devmgr/hwpage.c
reactos/lib/devmgr/misc.c
reactos/lib/devmgr/precomp.h
reactos/lib/devmgr/resource.h

index 8c2a593..79df71c 100644 (file)
@@ -11,6 +11,60 @@ BEGIN
     IDS_STATUS "Device Status: %1"
     IDS_UNKNOWN "Unknown"
     IDS_LOCATIONSTR "Location %1!u! (%2)"
+    IDS_DEVCODE " (Code %1!u!)"
+END
+
+STRINGTABLE
+BEGIN
+    IDS_DEV_NO_PROBLEM "This device is working properly."
+    IDS_DEV_NOT_CONFIGURED "CM_PROB_NOT_CONFIGURED"
+    IDS_DEV_OUT_OF_MEMORY "CM_PROB_DEVLOADER_FAILED"
+    IDS_DEV_ENTRY_IS_WRONG_TYPE "CM_PROB_ENTRY_IS_WRONG_TYPE"
+    IDS_DEV_LACKED_ARBITRATOR "CM_PROB_LACKED_ARBITRATOR"
+    IDS_DEV_BOOT_CONFIG_CONFLICT "CM_PROB_BOOT_CONFIG_CONFLICT"
+    IDS_DEV_FAILED_FILTER "CM_PROB_FAILED_FILTER"
+    IDS_DEV_DEVLOADER_NOT_FOUND "CM_PROB_DEVLOADER_NOT_FOUND"
+    IDS_DEV_INVALID_DATA "CM_PROB_INVALID_DATA"
+    IDS_DEV_FAILED_START "CM_PROB_FAILED_START"
+    IDS_DEV_LIAR "CM_PROB_LIAR"
+    IDS_DEV_NORMAL_CONFLICT "CM_PROB_NORMAL_CONFLICT"
+    IDS_DEV_NOT_VERIFIED "CM_PROB_NOT_VERIFIED"
+    IDS_DEV_NEED_RESTART "CM_PROB_NEED_RESTART"
+    IDS_DEV_REENUMERATION "CM_PROB_REENUMERATION"
+    IDS_DEV_PARTIAL_LOG_CONF "CM_PROB_PARTIAL_LOG_CONF"
+    IDS_DEV_UNKNOWN_RESOURCE "CM_PROB_UNKNOWN_RESOURCE"
+    IDS_DEV_REINSTALL "CM_PROB_REINSTALL"
+    IDS_DEV_REGISTRY "CM_PROB_REGISTRY"
+    IDS_DEV_WILL_BE_REMOVED "CM_PROB_WILL_BE_REMOVED"
+    IDS_DEV_DISABLED "CM_PROB_DISABLED"
+    IDS_DEV_DEVLOADER_NOT_READY "CM_PROB_DEVLOADER_NOT_READY"
+    IDS_DEV_DEVICE_NOT_THERE "CM_PROB_DEVICE_NOT_THERE"
+    IDS_DEV_MOVED "CM_PROB_MOVED"
+    IDS_DEV_TOO_EARLY "CM_PROB_TOO_EARLY"
+    IDS_DEV_NO_VALID_LOG_CONF "CM_PROB_NO_VALID_LOG_CONF"
+    IDS_DEV_FAILED_INSTALL "CM_PROB_FAILED_INSTALL"
+    IDS_DEV_HARDWARE_DISABLED "CM_PROB_HARDWARE_DISABLED"
+    IDS_DEV_CANT_SHARE_IRQ "CM_PROB_CANT_SHARE_IRQ"
+    IDS_DEV_FAILED_ADD "CM_PROB_FAILED_ADD"
+    IDS_DEV_DISABLED_SERVICE "CM_PROB_DISABLED_SERVICE"
+    IDS_DEV_TRANSLATION_FAILED "CM_PROB_TRANSLATION_FAILED"
+    IDS_DEV_NO_SOFTCONFIG "CM_PROB_NO_SOFTCONFIG"
+    IDS_DEV_BIOS_TABLE "CM_PROB_BIOS_TABLE"
+    IDS_DEV_IRQ_TRANSLATION_FAILED "CM_PROB_IRQ_TRANSLATION_FAILED"
+    IDS_DEV_FAILED_DRIVER_ENTRY "CM_PROB_FAILED_DRIVER_ENTRY"
+    IDS_DEV_DRIVER_FAILED_PRIOR_UNLOAD "CM_PROB_DRIVER_FAILED_PRIOR_UNLOAD"
+    IDS_DEV_DRIVER_FAILED_LOAD "CM_PROB_DRIVER_FAILED_LOAD"
+    IDS_DEV_DRIVER_SERVICE_KEY_INVALID "CM_PROB_DRIVER_SERVICE_KEY_INVALID"
+    IDS_DEV_LEGACY_SERVICE_NO_DEVICES "CM_PROB_LEGACY_SERVICE_NO_DEVICES"
+    IDS_DEV_DUPLICATE_DEVICE "CM_PROB_DUPLICATE_DEVICE"
+    IDS_DEV_FAILED_POST_START "CM_PROB_FAILED_POST_START"
+    IDS_DEV_HALTED "CM_PROB_HALTED"
+    IDS_DEV_PHANTOM "CM_PROB_PHANTOM"
+    IDS_DEV_SYSTEM_SHUTDOWN "CM_PROB_SYSTEM_SHUTDOWN"
+    IDS_DEV_HELD_FOR_EJECT "CM_PROB_HELD_FOR_EJECT"
+    IDS_DEV_DRIVER_BLOCKED "CM_PROB_DRIVER_BLOCKED"
+    IDS_DEV_REGISTRY_TOO_LARGE "CM_PROB_REGISTRY_TOO_LARGE"
+    IDS_DEV_SETPROPERTIES_FAILED "CM_PROB_SETPROPERTIES_FAILED"
 END
 
 IDD_HARDWARE DIALOG DISCARDABLE  0, 0, 300, 400
index 669ea82..1d22252 100644 (file)
@@ -39,6 +39,7 @@ typedef struct _DEVADVPROP_INFO
     HDEVINFO DeviceInfoSet;
     PSP_DEVINFO_DATA DeviceInfoData;
     HINSTANCE hComCtl32;
+    HANDLE hMachine;
     WCHAR szDevName[255];
     WCHAR szTemp[255];
 } DEVADVPROP_INFO, *PDEVADVPROP_INFO;
@@ -52,6 +53,7 @@ AdvPropGeneralDlgProc(IN HWND hwndDlg,
                       IN LPARAM lParam)
 {
     PDEVADVPROP_INFO dap;
+    INT_PTR Ret = FALSE;
 
     dap = (PDEVADVPROP_INFO)GetWindowLongPtr(hwndDlg,
                                              DWL_USER);
@@ -120,8 +122,8 @@ AdvPropGeneralDlgProc(IN HWND hwndDlg,
                     }
 
                     /* set the device status edit control text */
-                    if (GetDeviceStatusString(dap->DeviceInfoSet,
-                                              dap->DeviceInfoData,
+                    if (GetDeviceStatusString(dap->DeviceInfoData->DevInst,
+                                              dap->hMachine,
                                               dap->szTemp,
                                               sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
                     {
@@ -130,6 +132,7 @@ AdvPropGeneralDlgProc(IN HWND hwndDlg,
                                        dap->szTemp);
                     }
                 }
+                Ret = TRUE;
                 break;
             }
 
@@ -152,7 +155,7 @@ AdvPropGeneralDlgProc(IN HWND hwndDlg,
         }
     }
 
-    return FALSE;
+    return Ret;
 }
 
 
@@ -160,9 +163,9 @@ INT_PTR
 DisplayDeviceAdvancedProperties(IN HWND hWndParent,
                                 IN HDEVINFO DeviceInfoSet,
                                 IN PSP_DEVINFO_DATA DeviceInfoData,
-                                IN HINSTANCE hComCtl32)
+                                IN HINSTANCE hComCtl32,
+                                IN LPCWSTR lpMachineName)
 {
-    DWORD RegDataType;
     PROPSHEETHEADER psh = {0};
     PROPSHEETPAGE pspGeneral = {0};
     DWORD nPropSheets = 0;
@@ -171,6 +174,8 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
     PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW;
     PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage;
     PDEVADVPROP_INFO DevAdvPropInfo;
+    DWORD PropertySheetType;
+    HANDLE hMachine = NULL;
     UINT nPages = 0;
     union
     {
@@ -201,6 +206,16 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
         return -1;
     }
 
+    if (lpMachineName != NULL)
+    {
+        CONFIGRET cr = CM_Connect_Machine(lpMachineName,
+                                          &hMachine);
+        if (cr != CR_SUCCESS)
+        {
+            return -1;
+        }
+    }
+
     /* create the internal structure associated with the "General",
        "Driver", ... pages */
     DevAdvPropInfo = HeapAlloc(GetProcessHeap(),
@@ -208,45 +223,37 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
                                sizeof(DEVADVPROP_INFO));
     if (DevAdvPropInfo == NULL)
     {
-        return -1;
+        goto Cleanup;
     }
 
     DevAdvPropInfo->DeviceInfoSet = DeviceInfoSet;
     DevAdvPropInfo->DeviceInfoData = DeviceInfoData;
     DevAdvPropInfo->hComCtl32 = hComCtl32;
+    DevAdvPropInfo->hMachine = hMachine;
     DevAdvPropInfo->szDevName[0] = L'\0';
 
     /* get the device name */
-    if ((SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
-                                          DeviceInfoData,
-                                          SPDRP_FRIENDLYNAME,
-                                          &RegDataType,
-                                          (PBYTE)DevAdvPropInfo->szDevName,
-                                          sizeof(DevAdvPropInfo->szDevName),
-                                          NULL) ||
-         SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
-                                          DeviceInfoData,
-                                          SPDRP_DEVICEDESC,
-                                          &RegDataType,
-                                          (PBYTE)DevAdvPropInfo->szDevName,
-                                          sizeof(DevAdvPropInfo->szDevName),
-                                          NULL)) &&
-        RegDataType == REG_SZ)
+    if (GetDeviceDescriptionString(DeviceInfoSet,
+                                   DeviceInfoData,
+                                   DevAdvPropInfo->szDevName,
+                                   sizeof(DevAdvPropInfo->szDevName) / sizeof(DevAdvPropInfo->szDevName[0])))
     {
-        /* FIXME - check string for NULL termination! */
-
         psh.dwSize = sizeof(PROPSHEETHEADER);
         psh.dwFlags =  PSH_PROPTITLE;
         psh.hwndParent = hWndParent;
         psh.pszCaption = DevAdvPropInfo->szDevName;
 
+        PropertySheetType = lpMachineName != NULL ?
+                                DIGCDP_FLAG_REMOTE_ADVANCED :
+                                DIGCDP_FLAG_ADVANCED;
+
         /* find out how many property sheets we need */
         if (SetupDiGetClassDevPropertySheets(DeviceInfoSet,
                                              DeviceInfoData,
                                              &psh,
                                              0,
                                              &nPropSheets,
-                                             DIGCDP_FLAG_ADVANCED) &&
+                                             PropertySheetType) &&
             nPropSheets != 0)
         {
             DPRINT1("SetupDiGetClassDevPropertySheets unexpectedly returned TRUE!\n");
@@ -291,7 +298,7 @@ DisplayDeviceAdvancedProperties(IN HWND hWndParent,
                                                   &psh,
                                                   nPropSheets,
                                                   NULL,
-                                                  DIGCDP_FLAG_ADVANCED))
+                                                  PropertySheetType))
             {
                 goto Cleanup;
             }
@@ -343,6 +350,11 @@ Cleanup:
              0,
              DevAdvPropInfo);
 
+    if (hMachine != NULL)
+    {
+        CM_Disconnect_Machine(hMachine);
+    }
+
     return Ret;
 }
 
@@ -380,16 +392,23 @@ DeviceAdvancedPropertiesW(HWND hWndParent,
     HINSTANCE hComCtl32;
     INT_PTR Ret = -1;
 
-    /* FIXME - handle remote device properties */
-
-    UNREFERENCED_PARAMETER(lpMachineName);
-
     /* dynamically load comctl32 */
     hComCtl32 = LoadAndInitComctl32();
     if (hComCtl32 != NULL)
     {
-        hDevInfo = SetupDiCreateDeviceInfoList(NULL,
-                                               hWndParent);
+        if (lpMachineName != NULL)
+        {
+            hDevInfo = SetupDiCreateDeviceInfoListEx(NULL,
+                                                     hWndParent,
+                                                     lpMachineName,
+                                                     NULL);
+        }
+        else
+        {
+            hDevInfo = SetupDiCreateDeviceInfoList(NULL,
+                                                   hWndParent);
+        }
+
         if (hDevInfo != INVALID_HANDLE_VALUE)
         {
             DevInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
@@ -402,7 +421,8 @@ DeviceAdvancedPropertiesW(HWND hWndParent,
                 Ret = DisplayDeviceAdvancedProperties(hWndParent,
                                                       hDevInfo,
                                                       &DevInfoData,
-                                                      hComCtl32);
+                                                      hComCtl32,
+                                                      lpMachineName);
             }
 
             SetupDiDestroyDeviceInfoList(hDevInfo);
@@ -469,12 +489,18 @@ DeviceAdvancedPropertiesA(HWND hWndParent,
                                     lpDeviceIDW);
 
 Cleanup:
-    HeapFree(GetProcessHeap(),
-             0,
-             lpMachineNameW);
-    HeapFree(GetProcessHeap(),
-             0,
-             lpDeviceIDW);
+    if (lpMachineNameW != NULL)
+    {
+        HeapFree(GetProcessHeap(),
+                 0,
+                 lpMachineNameW);
+    }
+    if (lpDeviceIDW != NULL)
+    {
+        HeapFree(GetProcessHeap(),
+                 0,
+                 lpDeviceIDW);
+    }
 
     return Ret;
 }
index 6e9b94c..4b5023e 100644 (file)
@@ -8,6 +8,7 @@
        <define name="_WIN32_IE">0x600</define>
        <define name="_WIN32_WINNT">0x501</define>
        <define name="WINVER">0x501</define>
+       <define name="_SETUPAPI_VER">0x501</define>
        <library>kernel32</library>
        <library>ntdll</library>
        <library>setupapi</library>
index 3fc516b..accb815 100644 (file)
@@ -136,7 +136,8 @@ DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd)
         Ret = DisplayDeviceAdvancedProperties(hpd->hWnd,
                                               HwDevInfo->ClassDevInfo->hDevInfo,
                                               &HwDevInfo->DevInfoData,
-                                              hpd->hComCtl32) != -1;
+                                              hpd->hComCtl32,
+                                              NULL) != -1;
     }
 
     return Ret;
@@ -192,8 +193,8 @@ UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
             LocalFree((HLOCAL)szFormatted);
         }
 
-        if (GetDeviceStatusString(HwDevInfo->ClassDevInfo->hDevInfo,
-                                  &HwDevInfo->DevInfoData,
+        if (GetDeviceStatusString(HwDevInfo->DevInfoData.DevInst,
+                                  NULL,
                                   szBuffer,
                                   sizeof(szBuffer) / sizeof(szBuffer[0])) &&
             LoadAndFormatString(hDllInstance,
@@ -357,29 +358,15 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
 
             while (HwDevInfo != LastHwDevInfo)
             {
-                DWORD RegDataType;
                 INT iItem;
                 LVITEM li;
 
                 /* get the device name */
-                if ((SetupDiGetDeviceRegistryProperty(ClassDevInfo->hDevInfo,
-                                                      &HwDevInfo->DevInfoData,
-                                                      SPDRP_FRIENDLYNAME,
-                                                      &RegDataType,
-                                                      (PBYTE)szBuffer,
-                                                      sizeof(szBuffer),
-                                                      NULL) ||
-                     SetupDiGetDeviceRegistryProperty(ClassDevInfo->hDevInfo,
-                                                      &HwDevInfo->DevInfoData,
-                                                      SPDRP_DEVICEDESC,
-                                                      &RegDataType,
-                                                      (PBYTE)szBuffer,
-                                                      sizeof(szBuffer),
-                                                      NULL)) &&
-                    RegDataType == REG_SZ)
+                if (GetDeviceDescriptionString(ClassDevInfo->hDevInfo,
+                                               &HwDevInfo->DevInfoData,
+                                               szBuffer,
+                                               sizeof(szBuffer) / sizeof(szBuffer[0])))
                 {
-                    /* FIXME - check string for NULL termination! */
-
                     li.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT | LVIF_IMAGE;
                     li.iItem = ItemCount;
                     li.iSubItem = 0;
@@ -405,7 +392,7 @@ FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
                             li.iSubItem = 1;
 
                             ListView_SetItem(hpd->hWndDevList,
-                                             &li);                  
+                                             &li);
                         }
                     }
                 }
@@ -674,6 +661,7 @@ HardwareDlgProc(IN HWND hwndDlg,
                 IN LPARAM lParam)
 {
     PHARDWARE_PAGE_DATA hpd;
+    INT_PTR Ret = FALSE;
 
     hpd = (PHARDWARE_PAGE_DATA)GetWindowLongPtr(hwndDlg,
                                                 DWL_USER);
@@ -820,6 +808,7 @@ HardwareDlgProc(IN HWND hwndDlg,
                     EnableTroubleShoot(hpd,
                                        GetWindowTextLength(hwndDlg) != 0);
                 }
+                Ret = TRUE;
                 break;
             }
 
@@ -854,7 +843,7 @@ HardwareDlgProc(IN HWND hwndDlg,
         }
     }
 
-    return FALSE;
+    return Ret;
 }
 
 
index 7eac129..8da0f0f 100644 (file)
@@ -94,6 +94,41 @@ AllocAndLoadString(OUT LPWSTR *lpTarget,
 }
 
 
+static INT
+AllocAndLoadStringsCat(OUT LPWSTR *lpTarget,
+                       IN HINSTANCE hInst,
+                       IN UINT uID1,
+                       IN UINT uID2)
+{
+    INT ln;
+
+    ln = LengthOfStrResource(hInst,
+                             uID1);
+    ln += LengthOfStrResource(hInst,
+                              uID2);
+    if (ln++ > 0)
+    {
+        (*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
+                                         ln * sizeof(WCHAR));
+        if ((*lpTarget) != NULL)
+        {
+            INT Ret, Ret2 = 0;
+            if (!(Ret = LoadStringW(hInst, uID1, *lpTarget, ln)))
+            {
+                LocalFree((HLOCAL)(*lpTarget));
+            }
+            else if (!(Ret2 = LoadStringW(hInst, uID2, *lpTarget + Ret, ln - Ret)))
+            {
+                LocalFree((HLOCAL)(*lpTarget));
+                Ret = 0;
+            }
+            return Ret + Ret2;
+        }
+    }
+    return 0;
+}
+
+
 DWORD
 LoadAndFormatString(IN HINSTANCE hInstance,
                     IN UINT uID,
@@ -127,6 +162,41 @@ LoadAndFormatString(IN HINSTANCE hInstance,
 }
 
 
+DWORD
+LoadAndFormatStringsCat(IN HINSTANCE hInstance,
+                        IN UINT uID1,
+                        IN UINT uID2,
+                        OUT LPWSTR *lpTarget,
+                        ...)
+{
+    DWORD Ret = 0;
+    LPWSTR lpFormat;
+    va_list lArgs;
+
+    if (AllocAndLoadStringsCat(&lpFormat,
+                               hInstance,
+                               uID1,
+                               uID2) > 0)
+    {
+        va_start(lArgs, lpTarget);
+        /* let's use FormatMessage to format it because it has the ability to allocate
+           memory automatically */
+        Ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
+                             lpFormat,
+                             0,
+                             0,
+                             (LPWSTR)lpTarget,
+                             0,
+                             &lArgs);
+        va_end(lArgs);
+
+        LocalFree((HLOCAL)lpFormat);
+    }
+
+    return Ret;
+}
+
+
 LPARAM
 ListViewGetSelectedItemData(IN HWND hwnd)
 {
@@ -293,16 +363,130 @@ GetDeviceLocationString(IN DEVINST dnDevInst,
 }
 
 
+static const UINT ProblemStringId[] =
+{
+    IDS_DEV_NO_PROBLEM,
+    IDS_DEV_NOT_CONFIGURED,
+    IDS_DEV_OUT_OF_MEMORY,
+    IDS_DEV_ENTRY_IS_WRONG_TYPE,
+    IDS_DEV_LACKED_ARBITRATOR,
+    IDS_DEV_BOOT_CONFIG_CONFLICT,
+    IDS_DEV_FAILED_FILTER,
+    IDS_DEV_DEVLOADER_NOT_FOUND,
+    IDS_DEV_INVALID_DATA,
+    IDS_DEV_FAILED_START,
+    IDS_DEV_LIAR,
+    IDS_DEV_NORMAL_CONFLICT,
+    IDS_DEV_NOT_VERIFIED,
+    IDS_DEV_NEED_RESTART,
+    IDS_DEV_REENUMERATION,
+    IDS_DEV_PARTIAL_LOG_CONF,
+    IDS_DEV_UNKNOWN_RESOURCE,
+    IDS_DEV_REINSTALL,
+    IDS_DEV_REGISTRY,
+    IDS_UNKNOWN, /* CM_PROB_VXDLDR, not used on NT */
+    IDS_DEV_WILL_BE_REMOVED,
+    IDS_DEV_DISABLED,
+    IDS_DEV_DEVLOADER_NOT_READY,
+    IDS_DEV_DEVICE_NOT_THERE,
+    IDS_DEV_MOVED,
+    IDS_DEV_TOO_EARLY,
+    IDS_DEV_NO_VALID_LOG_CONF,
+    IDS_DEV_FAILED_INSTALL,
+    IDS_DEV_HARDWARE_DISABLED,
+    IDS_DEV_CANT_SHARE_IRQ,
+    IDS_DEV_FAILED_ADD,
+    IDS_DEV_DISABLED_SERVICE,
+    IDS_DEV_TRANSLATION_FAILED,
+    IDS_DEV_NO_SOFTCONFIG,
+    IDS_DEV_BIOS_TABLE,
+    IDS_DEV_IRQ_TRANSLATION_FAILED,
+    IDS_DEV_FAILED_DRIVER_ENTRY,
+    IDS_DEV_DRIVER_FAILED_PRIOR_UNLOAD,
+    IDS_DEV_DRIVER_FAILED_LOAD,
+    IDS_DEV_DRIVER_SERVICE_KEY_INVALID,
+    IDS_DEV_LEGACY_SERVICE_NO_DEVICES,
+    IDS_DEV_DUPLICATE_DEVICE,
+    IDS_DEV_FAILED_POST_START,
+    IDS_DEV_HALTED,
+    IDS_DEV_PHANTOM,
+    IDS_DEV_SYSTEM_SHUTDOWN,
+    IDS_DEV_HELD_FOR_EJECT,
+    IDS_DEV_DRIVER_BLOCKED,
+    IDS_DEV_REGISTRY_TOO_LARGE,
+    IDS_DEV_SETPROPERTIES_FAILED,
+};
+
+
 BOOL
-GetDeviceStatusString(IN HDEVINFO DeviceInfoSet,
-                      IN PSP_DEVINFO_DATA DeviceInfoData,
+GetDeviceStatusString(IN DEVINST DevInst,
+                      IN HANDLE hMachine,
                       OUT LPWSTR szBuffer,
                       IN DWORD BufferSize)
 {
-    return LoadString(hDllInstance,
-                      IDS_UNKNOWN,
-                       szBuffer,
-                       BufferSize) != 0;
+    CONFIGRET cr;
+    ULONG Status, ProblemNumber;
+    BOOL Ret = FALSE;
+
+    if (hMachine != NULL)
+    {
+        cr = CM_Get_DevNode_Status_Ex(&Status,
+                                      &ProblemNumber,
+                                      DevInst,
+                                      0,
+                                      hMachine);
+    }
+    else
+    {
+        cr = CM_Get_DevNode_Status(&Status,
+                                   &ProblemNumber,
+                                   DevInst,
+                                   0);
+    }
+
+    if (cr == CR_SUCCESS)
+    {
+        UINT MessageId;
+
+        if (ProblemNumber < sizeof(ProblemStringId) / sizeof(ProblemStringId[0]))
+            MessageId = ProblemStringId[ProblemNumber];
+        else
+            MessageId = IDS_UNKNOWN;
+
+        szBuffer[0] = L'\0';
+        if (ProblemNumber == 0)
+        {
+            if (LoadString(hDllInstance,
+                           MessageId,
+                           szBuffer,
+                           BufferSize))
+            {
+                Ret = TRUE;
+            }
+        }
+        else
+        {
+            LPWSTR szProblem;
+
+            if (LoadAndFormatStringsCat(hDllInstance,
+                                        MessageId,
+                                        IDS_DEVCODE,
+                                        &szProblem,
+                                        ProblemNumber))
+            {
+                wcsncpy(szBuffer,
+                        szProblem,
+                        BufferSize - 1);
+                szBuffer[BufferSize - 1] = L'\0';
+
+                LocalFree((HLOCAL)szProblem);
+
+                Ret = TRUE;
+            }
+        }
+    }
+
+    return Ret;
 }
 
 
@@ -337,6 +521,50 @@ GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
 }
 
 
+BOOL
+GetDeviceDescriptionString(IN HDEVINFO DeviceInfoSet,
+                           IN PSP_DEVINFO_DATA DeviceInfoData,
+                           OUT LPWSTR szBuffer,
+                           IN DWORD BufferSize)
+{
+    DWORD RegDataType;
+    BOOL Ret = FALSE;
+
+    if ((SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
+                                          DeviceInfoData,
+                                          SPDRP_FRIENDLYNAME,
+                                          &RegDataType,
+                                          (PBYTE)szBuffer,
+                                          BufferSize * sizeof(WCHAR),
+                                          NULL) ||
+         SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
+                                          DeviceInfoData,
+                                          SPDRP_DEVICEDESC,
+                                          &RegDataType,
+                                          (PBYTE)szBuffer,
+                                          BufferSize * sizeof(WCHAR),
+                                          NULL)) &&
+        RegDataType == REG_SZ)
+    {
+        /* FIXME - check string for NULL termination! */
+        Ret = TRUE;
+    }
+    else
+    {
+        szBuffer[0] = L'\0';
+        if (LoadString(hDllInstance,
+                       IDS_UNKNOWN,
+                       szBuffer,
+                       BufferSize))
+        {
+            Ret = TRUE;
+        }
+    }
+
+    return Ret;
+}
+
+
 HINSTANCE
 LoadAndInitComctl32(VOID)
 {
index 8f5b163..bf15b0d 100644 (file)
@@ -186,7 +186,8 @@ INT_PTR
 DisplayDeviceAdvancedProperties(IN HWND hWndParent,
                                 IN HDEVINFO DeviceInfoSet,
                                 IN PSP_DEVINFO_DATA DeviceInfoData,
-                                IN HINSTANCE hComCtl32);
+                                IN HINSTANCE hComCtl32,
+                                IN LPCWSTR lpMachineName);
 
 /* MISC.C */
 
@@ -196,6 +197,13 @@ LoadAndFormatString(IN HINSTANCE hInstance,
                     OUT LPWSTR *lpTarget,
                     ...);
 
+DWORD
+LoadAndFormatStringsCat(IN HINSTANCE hInstance,
+                        IN UINT uID1,
+                        IN UINT uID2,
+                        OUT LPWSTR *lpTarget,
+                        ...);
+
 LPARAM
 ListViewGetSelectedItemData(IN HWND hwnd);
 
@@ -218,8 +226,8 @@ GetDeviceLocationString(IN DEVINST dnDevInst,
                         IN DWORD BufferSize);
 
 BOOL
-GetDeviceStatusString(IN HDEVINFO DeviceInfoSet,
-                      IN PSP_DEVINFO_DATA DeviceInfoData,
+GetDeviceStatusString(IN DEVINST DevInst,
+                      IN HANDLE hMachine,
                       OUT LPWSTR szBuffer,
                       IN DWORD BufferSize);
 
@@ -228,6 +236,12 @@ GetDeviceTypeString(IN PSP_DEVINFO_DATA DeviceInfoData,
                     OUT LPWSTR szBuffer,
                     IN DWORD BufferSize);
 
+BOOL
+GetDeviceDescriptionString(IN HDEVINFO DeviceInfoSet,
+                           IN PSP_DEVINFO_DATA DeviceInfoData,
+                           OUT LPWSTR szBuffer,
+                           IN DWORD BufferSize);
+
 #endif /* __DEVMGR_H */
 
 /* EOF */
index 76f50cb..4ca98b1 100644 (file)
 #define IDS_STATUS             0x104
 #define IDS_UNKNOWN            0x105
 #define IDS_LOCATIONSTR                0x106
+#define IDS_DEVCODE            0x107
+
+#define IDS_DEV_NO_PROBLEM                     0x200
+#define IDS_DEV_NOT_CONFIGURED                 0x201
+#define IDS_DEV_DEVLOADER_FAILED               0x202
+#define IDS_DEV_OUT_OF_MEMORY                  0x203
+#define IDS_DEV_ENTRY_IS_WRONG_TYPE            0x204
+#define IDS_DEV_LACKED_ARBITRATOR              0x205
+#define IDS_DEV_BOOT_CONFIG_CONFLICT           0x206
+#define IDS_DEV_FAILED_FILTER                  0x207
+#define IDS_DEV_DEVLOADER_NOT_FOUND            0x208
+#define IDS_DEV_INVALID_DATA                   0x209
+#define IDS_DEV_FAILED_START                   0x20A
+#define IDS_DEV_LIAR                           0x20B
+#define IDS_DEV_NORMAL_CONFLICT                        0x20C
+#define IDS_DEV_NOT_VERIFIED                   0x20D
+#define IDS_DEV_NEED_RESTART                   0x20E
+#define IDS_DEV_REENUMERATION                  0x20F
+#define IDS_DEV_PARTIAL_LOG_CONF               0x210
+#define IDS_DEV_UNKNOWN_RESOURCE               0x211
+#define IDS_DEV_REINSTALL                      0x212
+#define IDS_DEV_REGISTRY                       0x213
+#define IDS_DEV_WILL_BE_REMOVED                        0x214
+#define IDS_DEV_DISABLED                       0x215
+#define IDS_DEV_DEVLOADER_NOT_READY            0x216
+#define IDS_DEV_DEVICE_NOT_THERE               0x217
+#define IDS_DEV_MOVED                          0x218
+#define IDS_DEV_TOO_EARLY                      0x219
+#define IDS_DEV_NO_VALID_LOG_CONF              0x21A
+#define IDS_DEV_FAILED_INSTALL                 0x21B
+#define IDS_DEV_HARDWARE_DISABLED              0x21C
+#define IDS_DEV_CANT_SHARE_IRQ                 0x21D
+#define IDS_DEV_FAILED_ADD                     0x21E
+#define IDS_DEV_DISABLED_SERVICE               0x21F
+#define IDS_DEV_TRANSLATION_FAILED             0x220
+#define IDS_DEV_NO_SOFTCONFIG                  0x221
+#define IDS_DEV_BIOS_TABLE                     0x222
+#define IDS_DEV_IRQ_TRANSLATION_FAILED         0x223
+#define IDS_DEV_FAILED_DRIVER_ENTRY            0x224
+#define IDS_DEV_DRIVER_FAILED_PRIOR_UNLOAD     0x225
+#define IDS_DEV_DRIVER_FAILED_LOAD             0x226
+#define IDS_DEV_DRIVER_SERVICE_KEY_INVALID     0x227
+#define IDS_DEV_LEGACY_SERVICE_NO_DEVICES      0x228
+#define IDS_DEV_DUPLICATE_DEVICE               0x229
+#define IDS_DEV_FAILED_POST_START              0x22A
+#define IDS_DEV_HALTED                         0x22B
+#define IDS_DEV_PHANTOM                                0x22C
+#define IDS_DEV_SYSTEM_SHUTDOWN                        0x22D
+#define IDS_DEV_HELD_FOR_EJECT                 0x22E
+#define IDS_DEV_DRIVER_BLOCKED                 0x22F
+#define IDS_DEV_REGISTRY_TOO_LARGE             0x230
+#define IDS_DEV_SETPROPERTIES_FAILED           0x231
 
 #endif /* __DEVMGR_RESOURCE_H */