#define NDEBUG
#include <debug.h>
-typedef VOID (WINAPI *PINITCOMMONCONTROLS)(VOID);
-
typedef enum
{
HWPD_STANDARDLIST = 0,
}
+static BOOL
+DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd)
+{
+ PHWDEVINFO HwDevInfo;
+ BOOL Ret = FALSE;
+
+ HwDevInfo = (PHWDEVINFO)ListViewGetSelectedItemData(hpd->hWndDevList);
+ if (HwDevInfo != NULL)
+ {
+ Ret = DisplayDeviceAdvancedProperties(hpd->hWnd,
+ HwDevInfo->ClassDevInfo->hDevInfo,
+ &HwDevInfo->DevInfoData,
+ hpd->hComCtl32) != -1;
+ }
+
+ return Ret;
+}
+
+
static VOID
UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd)
{
PHWDEVINFO HwDevInfo;
HWND hBtnTroubleShoot, hBtnProperties;
- DWORD RegDataType;
hBtnTroubleShoot = GetDlgItem(hpd->hWnd,
IDC_TROUBLESHOOT);
WCHAR szBuffer[256];
LPWSTR szFormatted = NULL;
- if (!SetupDiGetDeviceRegistryProperty(HwDevInfo->ClassDevInfo->hDevInfo,
- &HwDevInfo->DevInfoData,
- SPDRP_MFG,
- &RegDataType,
- (PBYTE)szBuffer,
- sizeof(szBuffer),
- NULL) ||
- RegDataType != REG_SZ)
- {
- /* FIXME - check string for NULL termination! */
- szBuffer[0] = L'\0';
- }
- if (LoadAndFormatString(hDllInstance,
+ /* get the manufacturer string */
+ if (GetDeviceManufacturerString(HwDevInfo->ClassDevInfo->hDevInfo,
+ &HwDevInfo->DevInfoData,
+ szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0])) &&
+ LoadAndFormatString(hDllInstance,
IDS_MANUFACTURER,
&szFormatted,
szBuffer) != 0)
LocalFree((HLOCAL)szFormatted);
}
- /* FIXME - Display location and status */
+ /* get the location string */
+ if (GetDeviceLocationString(HwDevInfo->DevInfoData.DevInst,
+ szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0])) &&
+ LoadAndFormatString(hDllInstance,
+ IDS_LOCATION,
+ &szFormatted,
+ szBuffer) != 0)
+ {
+ SetDlgItemText(hpd->hWnd,
+ IDC_LOCATION,
+ szFormatted);
+ LocalFree((HLOCAL)szFormatted);
+ }
+
+ if (GetDeviceStatusString(HwDevInfo->ClassDevInfo->hDevInfo,
+ &HwDevInfo->DevInfoData,
+ szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0])) &&
+ LoadAndFormatString(hDllInstance,
+ IDS_STATUS,
+ &szFormatted,
+ szBuffer) != 0)
+ {
+ SetDlgItemText(hpd->hWnd,
+ IDC_STATUS,
+ szFormatted);
+ LocalFree((HLOCAL)szFormatted);
+ }
}
else
{
EnableWindow(hBtnTroubleShoot,
HwDevInfo != NULL);
- EnableWindow(hBtnTroubleShoot,
- hBtnProperties != NULL);
+ EnableWindow(hBtnProperties,
+ HwDevInfo != NULL);
}
+
static VOID
FreeDevicesList(IN PHARDWARE_PAGE_DATA hpd)
{
ClassDevInfo = hpd->ClassDevInfo;
LastClassDevInfo = ClassDevInfo + hpd->NumberOfGuids;
- /* free the device info set handles */
+ /* free the device info set handles and structures */
while (ClassDevInfo != LastClassDevInfo)
{
if (ClassDevInfo->hDevInfo != INVALID_HANDLE_VALUE)
{
SetupDiDestroyDeviceInfoList(ClassDevInfo->hDevInfo);
+ ClassDevInfo->hDevInfo = INVALID_HANDLE_VALUE;
}
- ClassDevInfo->hDevInfo = NULL;
+
ClassDevInfo->ItemCount = 0;
ClassDevInfo->ImageIndex = 0;
while (ClassDevInfo != LastClassDevInfo)
{
ClassDevInfo->ImageIndex = -1;
+
+ /* open a class device handle for the GUID we're processing */
ClassDevInfo->hDevInfo = SetupDiGetClassDevs(&ClassDevInfo->Guid,
NULL,
hpd->hWnd,
&ClassDevInfo->Guid,
&ClassDevInfo->ImageIndex);
+ /* enumerate all devices in the class */
while (SetupDiEnumDeviceInfo(ClassDevInfo->hDevInfo,
MemberIndex++,
&DevInfoData))
}
}
+ /* save all information for the current device */
ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount].ClassDevInfo = ClassDevInfo;
ClassDevInfo->HwDevInfo[ClassDevInfo->ItemCount++].DevInfoData = DevInfoData;
}
static VOID
-FillDevicesList(IN PHARDWARE_PAGE_DATA hpd)
+FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd)
{
PHWCLASSDEVINFO ClassDevInfo, LastClassDevInfo;
PHWDEVINFO HwDevInfo, LastHwDevInfo;
INT iItem;
LVITEM li;
+ /* get the device name */
if ((SetupDiGetDeviceRegistryProperty(ClassDevInfo->hDevInfo,
&HwDevInfo->DevInfoData,
SPDRP_FRIENDLYNAME,
{
ItemCount++;
- if (SetupDiGetClassDescription(&ClassDevInfo->Guid,
- szBuffer,
- sizeof(szBuffer) / sizeof(szBuffer[0]),
- NULL))
+ /* get the device type for the second column */
+ if (GetDeviceTypeString(&HwDevInfo->DevInfoData,
+ szBuffer,
+ sizeof(szBuffer) / sizeof(szBuffer[0])))
{
li.mask = LVIF_TEXT;
li.iItem = iItem;
}
break;
}
+
+ case NM_DBLCLK:
+ {
+ DisplaySelectedDeviceProperties(hpd);
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_TROUBLESHOOT:
+ {
+ /* FIXME - start the help using the command in the window text */
+ break;
+ }
+
+ case IDC_PROPERTIES:
+ {
+ DisplaySelectedDeviceProperties(hpd);
+ break;
}
}
break;
InitializeDevicesList(hpd);
/* fill the devices list view control */
- FillDevicesList(hpd);
+ FillDevicesListViewControl(hpd);
/* decide whether to show or hide the troubleshoot button */
EnableTroubleShoot(hpd,
* hWndParent: Handle to the parent window
* lpGuids: An array of guids of devices that are to be listed
* uNumberOfGuids: Numbers of guids in the Guids array
- * Unknown: Unknown parameter, see NOTEs
+ * DisplayMode: Sets the size of the device list view control
*
* RETURN VALUE
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
- * REVISIONS
- * 13-05-2005 first working version (Sebastian Gasiorek <zebasoftis@gmail.com>)
- *
- * TODO
- * missing: device icon in list view, Troubleshoot button, device properties,
- * status description,
- * devices should be visible afer PSN_SETACTIVE message
- *
+ * @implemented
*/
HWND
WINAPI
IN HWPAGE_DISPLAYMODE DisplayMode)
{
PHARDWARE_PAGE_DATA hpd;
- PINITCOMMONCONTROLS pInitCommonControls;
/* allocate the HARDWARE_PAGE_DATA structure. Make sure it is
zeroed because the initialization code assumes that in
i < uNumberOfGuids;
i++)
{
+ hpd->ClassDevInfo[i].hDevInfo = INVALID_HANDLE_VALUE;
hpd->ClassDevInfo[i].Guid = lpGuids[i];
}
/* load comctl32.dll dynamically */
- hpd->hComCtl32 = LoadLibrary(TEXT("comctl32.dll"));
+ hpd->hComCtl32 = LoadAndInitComctl32();
if (hpd->hComCtl32 == NULL)
{
goto Cleanup;
}
- /* initialize the common controls */
- pInitCommonControls = (PINITCOMMONCONTROLS)GetProcAddress(hpd->hComCtl32,
- "InitCommonControls");
- if (pInitCommonControls == NULL)
- {
- goto Cleanup;
- }
- pInitCommonControls();
-
/* create the dialog */
hWnd = CreateDialogParam(hDllInstance,
MAKEINTRESOURCE(IDD_HARDWARE),
* Returns the handle of the hardware page window that has been created or
* NULL if it failed.
*
- * REVISIONS
- *
- * NOTE
- *
+ * @implemented
*/
HWND
WINAPI