Display the driver provider, date and version. Based on a patch by Herve.
authorThomas Bluemel <thomas@reactsoft.com>
Tue, 27 Dec 2005 17:15:51 +0000 (17:15 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Tue, 27 Dec 2005 17:15:51 +0000 (17:15 +0000)
svn path=/trunk/; revision=20373

reactos/lib/devmgr/advprop.c
reactos/lib/devmgr/misc.c
reactos/lib/devmgr/precomp.h

index a4f05d6..43b5212 100644 (file)
@@ -79,6 +79,71 @@ typedef struct _DEVADVPROP_INFO
 #define PM_INITIALIZE (WM_APP + 0x101)
 
 
+static VOID
+UpdateDriverDlg(IN HWND hwndDlg,
+                IN PDEVADVPROP_INFO dap)
+{
+    HDEVINFO DeviceInfoSet;
+    PSP_DEVINFO_DATA DeviceInfoData;
+
+    if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
+    {
+        DeviceInfoSet = dap->CurrentDeviceInfoSet;
+        DeviceInfoData = &dap->CurrentDeviceInfoData;
+    }
+    else
+    {
+        DeviceInfoSet = dap->DeviceInfoSet;
+        DeviceInfoData = &dap->DeviceInfoData;
+    }
+
+    /* set the device image */
+    SendDlgItemMessage(hwndDlg,
+                       IDC_DEVICON,
+                       STM_SETICON,
+                       (WPARAM)dap->hDevIcon,
+                       0);
+
+    /* set the device name edit control text */
+    SetDlgItemText(hwndDlg,
+                   IDC_DEVNAME,
+                   dap->szDevName);
+
+    /* query the driver provider */
+    if (GetDriverProviderString(DeviceInfoSet,
+                                DeviceInfoData,
+                                dap->szTemp,
+                                sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
+    {
+        SetDlgItemText(hwndDlg,
+                       IDC_DRVPROVIDER,
+                       dap->szTemp);
+    }
+
+    /* query the driver date */
+    if (GetDriverDateString(DeviceInfoSet,
+                            DeviceInfoData,
+                            dap->szTemp,
+                            sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
+    {
+        SetDlgItemText(hwndDlg,
+                       IDC_DRVDATE,
+                       dap->szTemp);
+    }
+
+    /* query the driver version */
+    if (GetDriverVersionString(DeviceInfoSet,
+                               DeviceInfoData,
+                               dap->szTemp,
+                               sizeof(dap->szTemp) / sizeof(dap->szTemp[0])))
+    {
+        SetDlgItemText(hwndDlg,
+                       IDC_DRVVERSION,
+                       dap->szTemp);
+    }
+}
+
+
 static INT_PTR
 CALLBACK
 AdvProcDriverDlgProc(IN HWND hwndDlg,
@@ -116,17 +181,8 @@ AdvProcDriverDlgProc(IN HWND hwndDlg,
                                      DWL_USER,
                                      (DWORD_PTR)dap);
 
-                    /* set the device image */
-                    SendDlgItemMessage(hwndDlg,
-                                       IDC_DEVICON,
-                                       STM_SETICON,
-                                       (WPARAM)dap->hDevIcon,
-                                       0);
-
-                    /* set the device name edit control text */
-                    SetDlgItemText(hwndDlg,
-                                   IDC_DEVNAME,
-                                   dap->szDevName);
+                    UpdateDriverDlg(hwndDlg,
+                                    dap);
                 }
                 Ret = TRUE;
                 break;
@@ -391,7 +447,7 @@ UpdateDevInfo(IN HWND hwndDlg,
         }
         else
         {
-    GetParentNode:
+GetParentNode:
             /* get the parent node from the initial devinst */
             CM_Get_Parent_Ex(&dap->ParentDevInst,
                              dap->DeviceInfoData.DevInst,
index dbe5792..0bab6c8 100644 (file)
@@ -449,16 +449,202 @@ GetDeviceStatusString(IN DEVINST DevInst,
     else
     {
 GeneralMessage:
-        Ret = LoadString(hDllInstance,
-                         MessageId,
-                         szBuffer,
-                         (int)BufferSize);
+        if (LoadString(hDllInstance,
+                        MessageId,
+                        szBuffer,
+                        (int)BufferSize))
+        {
+            Ret = TRUE;
+        }
+    }
+
+    return Ret;
+}
+
+
+BOOL
+GetDriverProviderString(IN HDEVINFO DeviceInfoSet,
+                        IN PSP_DEVINFO_DATA DeviceInfoData,
+                        OUT LPWSTR szBuffer,
+                        IN DWORD BufferSize)
+{
+    HKEY hKey;
+    DWORD dwSize, dwType;
+    BOOL Ret = FALSE;
+
+    szBuffer[0] = L'\0';
+
+    /* get driver provider, date and version */
+    hKey = SetupDiOpenDevRegKey(DeviceInfoSet,
+                                DeviceInfoData,
+                                DICS_FLAG_GLOBAL,
+                                0,
+                                DIREG_DRV,
+                                KEY_QUERY_VALUE);
+    if (hKey != INVALID_HANDLE_VALUE)
+    {
+        /* query the driver provider */
+        dwSize = BufferSize;
+        if (RegQueryValueEx(hKey,
+                            REGSTR_VAL_PROVIDER_NAME,
+                            NULL,
+                            &dwType,
+                            (LPBYTE)szBuffer,
+                            &dwSize) == ERROR_SUCCESS &&
+            dwType == REG_SZ &&
+            szBuffer[0] != L'\0')
+        {
+            Ret = TRUE;
+        }
+        else
+        {
+            szBuffer[0] = L'\0';
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    if (szBuffer[0] == L'\0')
+    {
+        /* unable to query the information */
+        if (LoadString(hDllInstance,
+                       IDS_UNKNOWN,
+                       szBuffer,
+                       BufferSize))
+        {
+            Ret = TRUE;
+        }
     }
 
     return Ret;
 }
 
 
+BOOL
+GetDriverVersionString(IN HDEVINFO DeviceInfoSet,
+                       IN PSP_DEVINFO_DATA DeviceInfoData,
+                       OUT LPWSTR szBuffer,
+                       IN DWORD BufferSize)
+{
+    HKEY hKey;
+    DWORD dwSize, dwType;
+    BOOL Ret = FALSE;
+
+    szBuffer[0] = L'\0';
+
+    /* get driver provider, date and version */
+    hKey = SetupDiOpenDevRegKey(DeviceInfoSet,
+                                DeviceInfoData,
+                                DICS_FLAG_GLOBAL,
+                                0,
+                                DIREG_DRV,
+                                KEY_QUERY_VALUE);
+    if (hKey != INVALID_HANDLE_VALUE)
+    {
+        /* query the driver provider */
+        dwSize = BufferSize;
+        if (RegQueryValueEx(hKey,
+                            L"DriverVersion",
+                            NULL,
+                            &dwType,
+                            (LPBYTE)szBuffer,
+                            &dwSize) == ERROR_SUCCESS &&
+            dwType == REG_SZ &&
+            szBuffer[0] != L'\0')
+        {
+            Ret = TRUE;
+        }
+        else
+        {
+            szBuffer[0] = L'\0';
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    if (szBuffer[0] == L'\0')
+    {
+        /* unable to query the information */
+        if (LoadString(hDllInstance,
+                       IDS_UNKNOWN,
+                       szBuffer,
+                       BufferSize))
+        {
+            Ret = TRUE;
+        }
+    }
+
+    return Ret;
+}
+
+BOOL
+GetDriverDateString(IN HDEVINFO DeviceInfoSet,
+                    IN PSP_DEVINFO_DATA DeviceInfoData,
+                    OUT LPWSTR szBuffer,
+                    IN DWORD BufferSize)
+{
+    HKEY hKey;
+    FILETIME DriverDate;
+    SYSTEMTIME SystemTime, LocalTime;
+    DWORD dwSize, dwType;
+    BOOL Ret = FALSE;
+
+    szBuffer[0] = L'\0';
+
+    /* get driver provider, date and version */
+    hKey = SetupDiOpenDevRegKey(DeviceInfoSet,
+                                DeviceInfoData,
+                                DICS_FLAG_GLOBAL,
+                                0,
+                                DIREG_DRV,
+                                KEY_QUERY_VALUE);
+    if (hKey != INVALID_HANDLE_VALUE)
+    {
+        /* query the driver provider */
+        dwSize = sizeof(FILETIME);
+        if (RegQueryValueEx(hKey,
+                            L"DriverDateData",
+                            NULL,
+                            &dwType,
+                            (LPBYTE)&DriverDate,
+                            &dwSize) == ERROR_SUCCESS &&
+            dwType == REG_BINARY &&
+            dwSize == sizeof(FILETIME) &&
+            FileTimeToSystemTime(&DriverDate,
+                                 &SystemTime) &&
+            SystemTimeToTzSpecificLocalTime(NULL,
+                                            &SystemTime,
+                                            &LocalTime) &&
+            GetDateFormat(LOCALE_USER_DEFAULT,
+                          DATE_SHORTDATE,
+                          &LocalTime,
+                          NULL,
+                          szBuffer,
+                          BufferSize) != 0)
+        {
+            Ret = TRUE;
+        }
+
+        RegCloseKey(hKey);
+    }
+
+    if (!Ret)
+    {
+        /* unable to query the information */
+        if (LoadString(hDllInstance,
+                       IDS_UNKNOWN,
+                       szBuffer,
+                       BufferSize))
+        {
+            Ret = TRUE;
+        }
+    }
+
+    return Ret;
+}
+
+
+
 BOOL
 IsDeviceHidden(IN DEVINST DevInst,
                IN HMACHINE hMachine,
index 9f34aee..9ae7f66 100644 (file)
@@ -2,6 +2,7 @@
 #define __DEVMGR_H
 
 #include <windows.h>
+#include <regstr.h>
 #include <setupapi.h>
 #include <cfgmgr32.h>
 #include <commctrl.h>
@@ -256,6 +257,24 @@ GetDeviceStatusString(IN DEVINST DevInst,
                       OUT LPWSTR szBuffer,
                       IN DWORD BufferSize);
 
+BOOL
+GetDriverProviderString(IN HDEVINFO DeviceInfoSet,
+                        IN PSP_DEVINFO_DATA DeviceInfoData,
+                        OUT LPWSTR szBuffer,
+                        IN DWORD BufferSize);
+
+BOOL
+GetDriverVersionString(IN HDEVINFO DeviceInfoSet,
+                       IN PSP_DEVINFO_DATA DeviceInfoData,
+                       OUT LPWSTR szBuffer,
+                       IN DWORD BufferSize);
+
+BOOL
+GetDriverDateString(IN HDEVINFO DeviceInfoSet,
+                    IN PSP_DEVINFO_DATA DeviceInfoData,
+                    OUT LPWSTR szBuffer,
+                    IN DWORD BufferSize);
+
 BOOL
 IsDeviceHidden(IN DEVINST DevInst,
                IN HMACHINE hMachine,