2 * ReactOS Device Manager Applet
3 * Copyright (C) 2004 - 2005 ReactOS Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * PROJECT: ReactOS devmgr.dll
22 * FILE: lib/devmgr/hwpage.c
23 * PURPOSE: ReactOS Device Manager
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
33 typedef struct _HWDEVINFO
35 struct _HWCLASSDEVINFO
*ClassDevInfo
;
36 SP_DEVINFO_DATA DevInfoData
;
38 } HWDEVINFO
, *PHWDEVINFO
;
40 typedef struct _HWCLASSDEVINFO
47 } HWCLASSDEVINFO
, *PHWCLASSDEVINFO
;
49 typedef struct _HARDWARE_PAGE_DATA
53 HINSTANCE hComCtl32
; /* only save this to keep track of the references */
54 INT DevListViewHeight
;
55 SP_CLASSIMAGELIST_DATA ClassImageListData
;
56 HWPAGE_DISPLAYMODE DisplayMode
;
58 /* parent window subclass info */
59 WNDPROC ParentOldWndProc
;
63 HWCLASSDEVINFO ClassDevInfo
[1];
64 /* struct may be dynamically expanded here! */
65 } HARDWARE_PAGE_DATA
, *PHARDWARE_PAGE_DATA
;
67 #define CX_TYPECOLUMN_WIDTH 80
70 InitializeDevicesList(IN PHARDWARE_PAGE_DATA hpd
)
77 /* set the list view style */
78 (void)ListView_SetExtendedListViewStyle(hpd
->hWndDevList
,
79 LVS_EX_FULLROWSELECT
);
81 /* set the list view image list */
82 if (hpd
->ClassImageListData
.ImageList
!= NULL
)
84 (void)ListView_SetImageList(hpd
->hWndDevList
,
85 hpd
->ClassImageListData
.ImageList
,
89 GetClientRect(hpd
->hWndDevList
,
92 /* add the list view columns */
93 lvc
.mask
= LVCF_TEXT
| LVCF_WIDTH
;
94 lvc
.fmt
= LVCFMT_LEFT
;
95 lvc
.pszText
= szColName
;
97 if (LoadString(hDllInstance
,
100 sizeof(szColName
) / sizeof(szColName
[0])))
102 lvc
.cx
= rcClient
.right
- CX_TYPECOLUMN_WIDTH
-
103 GetSystemMetrics(SM_CXVSCROLL
);
104 (void)ListView_InsertColumn(hpd
->hWndDevList
,
108 if (LoadString(hDllInstance
,
111 sizeof(szColName
) / sizeof(szColName
[0])))
113 lvc
.cx
= CX_TYPECOLUMN_WIDTH
;
114 (void)ListView_InsertColumn(hpd
->hWndDevList
,
122 DisplaySelectedDeviceProperties(IN PHARDWARE_PAGE_DATA hpd
)
124 PHWDEVINFO HwDevInfo
;
125 SP_DEVINFO_DATA DevInfoData
;
128 HwDevInfo
= (PHWDEVINFO
)ListViewGetSelectedItemData(hpd
->hWndDevList
);
129 if (HwDevInfo
!= NULL
)
131 /* make a copy of the SP_DEVINFO_DATA structure on the stack, it may
132 become invalid in case the devices are updated */
133 DevInfoData
= HwDevInfo
->DevInfoData
;
135 /* display the advanced properties */
136 Ret
= DisplayDeviceAdvancedProperties(hpd
->hWnd
,
138 HwDevInfo
->ClassDevInfo
->hDevInfo
,
150 UpdateControlStates(IN PHARDWARE_PAGE_DATA hpd
)
152 PHWDEVINFO HwDevInfo
;
153 HWND hBtnTroubleShoot
, hBtnProperties
;
155 hBtnTroubleShoot
= GetDlgItem(hpd
->hWnd
,
157 hBtnProperties
= GetDlgItem(hpd
->hWnd
,
160 HwDevInfo
= (PHWDEVINFO
)ListViewGetSelectedItemData(hpd
->hWndDevList
);
161 if (HwDevInfo
!= NULL
)
163 /* update static controls */
165 LPWSTR szFormatted
= NULL
;
167 /* get the manufacturer string */
168 if (GetDeviceManufacturerString(HwDevInfo
->ClassDevInfo
->hDevInfo
,
169 &HwDevInfo
->DevInfoData
,
171 sizeof(szBuffer
) / sizeof(szBuffer
[0])) &&
172 LoadAndFormatString(hDllInstance
,
177 SetDlgItemText(hpd
->hWnd
,
180 LocalFree((HLOCAL
)szFormatted
);
183 /* get the location string */
184 if (GetDeviceLocationString(HwDevInfo
->DevInfoData
.DevInst
,
187 sizeof(szBuffer
) / sizeof(szBuffer
[0])) &&
188 LoadAndFormatString(hDllInstance
,
193 SetDlgItemText(hpd
->hWnd
,
196 LocalFree((HLOCAL
)szFormatted
);
199 if (GetDeviceStatusString(HwDevInfo
->DevInfoData
.DevInst
,
202 sizeof(szBuffer
) / sizeof(szBuffer
[0])) &&
203 LoadAndFormatString(hDllInstance
,
208 SetDlgItemText(hpd
->hWnd
,
211 LocalFree((HLOCAL
)szFormatted
);
216 /* clear static controls */
217 SetDlgItemText(hpd
->hWnd
,
220 SetDlgItemText(hpd
->hWnd
,
223 SetDlgItemText(hpd
->hWnd
,
228 EnableWindow(hBtnTroubleShoot
,
230 EnableWindow(hBtnProperties
,
236 FreeDevicesList(IN PHARDWARE_PAGE_DATA hpd
)
238 PHWCLASSDEVINFO ClassDevInfo
, LastClassDevInfo
;
240 ClassDevInfo
= hpd
->ClassDevInfo
;
241 LastClassDevInfo
= ClassDevInfo
+ hpd
->NumberOfGuids
;
243 /* free the device info set handles and structures */
244 while (ClassDevInfo
!= LastClassDevInfo
)
246 if (ClassDevInfo
->hDevInfo
!= INVALID_HANDLE_VALUE
)
248 SetupDiDestroyDeviceInfoList(ClassDevInfo
->hDevInfo
);
249 ClassDevInfo
->hDevInfo
= INVALID_HANDLE_VALUE
;
252 ClassDevInfo
->ItemCount
= 0;
253 ClassDevInfo
->ImageIndex
= 0;
255 if (ClassDevInfo
->HwDevInfo
!= NULL
)
257 HeapFree(GetProcessHeap(),
259 ClassDevInfo
->HwDevInfo
);
260 ClassDevInfo
->HwDevInfo
= NULL
;
269 BuildDevicesList(IN PHARDWARE_PAGE_DATA hpd
)
271 PHWCLASSDEVINFO ClassDevInfo
, LastClassDevInfo
;
272 SP_DEVINFO_DATA DevInfoData
;
274 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
276 ClassDevInfo
= hpd
->ClassDevInfo
;
277 LastClassDevInfo
= ClassDevInfo
+ hpd
->NumberOfGuids
;
279 while (ClassDevInfo
!= LastClassDevInfo
)
281 ClassDevInfo
->ImageIndex
= -1;
283 /* open a class device handle for the GUID we're processing */
284 ClassDevInfo
->hDevInfo
= SetupDiGetClassDevs(&ClassDevInfo
->Guid
,
287 DIGCF_PRESENT
| DIGCF_PROFILE
);
288 if (ClassDevInfo
->hDevInfo
!= INVALID_HANDLE_VALUE
)
290 DWORD MemberIndex
= 0;
292 SetupDiGetClassImageIndex(&hpd
->ClassImageListData
,
294 &ClassDevInfo
->ImageIndex
);
296 /* enumerate all devices in the class */
297 while (SetupDiEnumDeviceInfo(ClassDevInfo
->hDevInfo
,
301 BOOL HideDevice
= FALSE
;
303 if (ClassDevInfo
->HwDevInfo
!= NULL
)
305 PHWDEVINFO HwNewDevInfo
= HeapReAlloc(GetProcessHeap(),
307 ClassDevInfo
->HwDevInfo
,
308 (ClassDevInfo
->ItemCount
+ 1) *
310 if (HwNewDevInfo
!= NULL
)
312 ClassDevInfo
->HwDevInfo
= HwNewDevInfo
;
316 DPRINT1("Unable to allocate memory for %d SP_DEVINFO_DATA structures!\n",
317 ClassDevInfo
->ItemCount
+ 1);
323 ClassDevInfo
->HwDevInfo
= HeapAlloc(GetProcessHeap(),
326 if (ClassDevInfo
->HwDevInfo
== NULL
)
328 DPRINT1("Unable to allocate memory for a SP_DEVINFO_DATA structures!\n");
333 /* Find out if the device should be hidden by default */
334 IsDeviceHidden(DevInfoData
.DevInst
,
338 /* save all information for the current device */
339 ClassDevInfo
->HwDevInfo
[ClassDevInfo
->ItemCount
].ClassDevInfo
= ClassDevInfo
;
340 ClassDevInfo
->HwDevInfo
[ClassDevInfo
->ItemCount
].DevInfoData
= DevInfoData
;
341 ClassDevInfo
->HwDevInfo
[ClassDevInfo
->ItemCount
++].HideDevice
= HideDevice
;
351 DeviceIdMatch(IN HDEVINFO DeviceInfoSet
,
352 IN PSP_DEVINFO_DATA DeviceInfoData
,
353 IN LPCWSTR lpDeviceId
)
356 LPWSTR lpQueriedDeviceId
;
359 if (!SetupDiGetDeviceInstanceId(DeviceInfoSet
,
364 GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
366 if (DevIdLen
== wcslen(lpDeviceId
) + 1)
368 lpQueriedDeviceId
= HeapAlloc(GetProcessHeap(),
370 DevIdLen
* sizeof(WCHAR
));
371 if (lpQueriedDeviceId
!= NULL
)
373 if (SetupDiGetDeviceInstanceId(DeviceInfoSet
,
379 Ret
= (wcscmp(lpDeviceId
,
380 lpQueriedDeviceId
) == 0);
383 HeapFree(GetProcessHeap(),
395 FillDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd
,
396 IN LPCWSTR lpSelectDeviceId OPTIONAL
,
397 IN GUID
*SelectedClassGuid OPTIONAL
)
399 PHWCLASSDEVINFO ClassDevInfo
, LastClassDevInfo
;
400 PHWDEVINFO HwDevInfo
, LastHwDevInfo
;
402 BOOL SelectedInClass
;
405 BuildDevicesList(hpd
);
407 ClassDevInfo
= hpd
->ClassDevInfo
;
408 LastClassDevInfo
= ClassDevInfo
+ hpd
->NumberOfGuids
;
410 while (ClassDevInfo
!= LastClassDevInfo
)
412 if (ClassDevInfo
->HwDevInfo
!= NULL
)
414 HwDevInfo
= ClassDevInfo
->HwDevInfo
;
415 LastHwDevInfo
= HwDevInfo
+ ClassDevInfo
->ItemCount
;
417 SelectedInClass
= (SelectedClassGuid
!= NULL
&&
418 IsEqualGUID(SelectedClassGuid
,
419 &ClassDevInfo
->Guid
));
420 while (HwDevInfo
!= LastHwDevInfo
)
425 /* get the device name */
426 if (!HwDevInfo
->HideDevice
&&
427 GetDeviceDescriptionString(ClassDevInfo
->hDevInfo
,
428 &HwDevInfo
->DevInfoData
,
430 sizeof(szBuffer
) / sizeof(szBuffer
[0])))
432 li
.mask
= LVIF_PARAM
| LVIF_STATE
| LVIF_TEXT
| LVIF_IMAGE
;
433 li
.iItem
= ItemCount
;
434 if ((ItemCount
== 0 && lpSelectDeviceId
== NULL
) ||
436 DeviceIdMatch(ClassDevInfo
->hDevInfo
,
437 &HwDevInfo
->DevInfoData
,
440 li
.state
= LVIS_SELECTED
;
442 li
.stateMask
= LVIS_SELECTED
;
443 li
.pszText
= szBuffer
;
444 li
.iImage
= ClassDevInfo
->ImageIndex
;
445 li
.lParam
= (LPARAM
)HwDevInfo
;
447 iItem
= ListView_InsertItem(hpd
->hWndDevList
,
453 /* get the device type for the second column */
454 if (GetDeviceTypeString(&HwDevInfo
->DevInfoData
,
456 sizeof(szBuffer
) / sizeof(szBuffer
[0])))
462 (void)ListView_SetItem(hpd
->hWndDevList
,
475 /* update the controls */
476 UpdateControlStates(hpd
);
481 UpdateDevicesListViewControl(IN PHARDWARE_PAGE_DATA hpd
)
483 PHWDEVINFO HwDevInfo
;
484 GUID SelectedClassGuid
= {0};
485 LPWSTR lpDeviceId
= NULL
;
487 /* if a device currently is selected, remember the device id so we can
488 select the device after the update if still present */
489 HwDevInfo
= (PHWDEVINFO
)ListViewGetSelectedItemData(hpd
->hWndDevList
);
490 if (HwDevInfo
!= NULL
)
493 if (!SetupDiGetDeviceInstanceId(HwDevInfo
->ClassDevInfo
->hDevInfo
,
494 &HwDevInfo
->DevInfoData
,
498 GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
500 SelectedClassGuid
= HwDevInfo
->DevInfoData
.ClassGuid
;
501 lpDeviceId
= HeapAlloc(GetProcessHeap(),
503 DevIdLen
* sizeof(WCHAR
));
504 if (lpDeviceId
!= NULL
&&
505 !SetupDiGetDeviceInstanceId(HwDevInfo
->ClassDevInfo
->hDevInfo
,
506 &HwDevInfo
->DevInfoData
,
511 HeapFree(GetProcessHeap(),
519 /* clear the devices list view control */
520 (void)ListView_DeleteAllItems(hpd
->hWndDevList
);
522 /* free the device list */
523 FreeDevicesList(hpd
);
525 /* build rebuild the device list and fill the list box again */
526 FillDevicesListViewControl(hpd
,
528 (lpDeviceId
!= NULL
?
532 if (lpDeviceId
!= NULL
)
534 HeapFree(GetProcessHeap(),
543 ParentSubWndProc(IN HWND hwnd
,
548 PHARDWARE_PAGE_DATA hpd
;
550 hpd
= (PHARDWARE_PAGE_DATA
)GetProp(hwnd
,
551 L
"DevMgrSubClassInfo");
556 /* resize the hardware page */
557 SetWindowPos(hpd
->hWnd
,
565 else if (uMsg
== WM_DEVICECHANGE
&& IsWindowVisible(hpd
->hWnd
))
567 /* forward a WM_DEVICECHANGE message to the hardware
568 page which wouldn't get the message itself as it is
570 SendMessage(hpd
->hWnd
,
576 /* pass the message the the old window proc */
577 return CallWindowProc(hpd
->ParentOldWndProc
,
585 /* this is not a good idea if the subclassed window was an ansi
586 window, but we failed finding out the previous window proc
587 so we can't use CallWindowProc. This should rarely - if ever -
590 return DefWindowProc(hwnd
,
599 HardwareDlgResize(IN PHARDWARE_PAGE_DATA hpd
,
604 HWND hControl
, hButton
;
608 POINT ptMargin
= {0};
609 POINT ptMarginGroup
= {0};
611 /* use left margin of the IDC_DEVICES label as the right
612 margin of all controls outside the group box */
613 hControl
= GetDlgItem(hpd
->hWnd
,
615 GetWindowRect(hControl
,
617 MapWindowPoints(hControl
,
622 Width
= cx
- (2 * ptMargin
.x
);
624 if ((dwp
= BeginDeferWindowPos(8)))
626 /* rc already has the window rect of IDC_DEVICES! */
627 if (!(dwp
= DeferWindowPos(dwp
,
634 SWP_NOMOVE
| SWP_NOZORDER
)))
639 /* resize the devices list view control */
640 GetWindowRect(hpd
->hWndDevList
,
642 MapWindowPoints(hpd
->hWndDevList
,
646 y
= pt
.y
+ hpd
->DevListViewHeight
+ ptMargin
.y
;
647 if (!(dwp
= DeferWindowPos(dwp
,
653 hpd
->DevListViewHeight
,
654 SWP_NOMOVE
| SWP_NOZORDER
)))
659 /* resize the group box control */
660 hControl
= GetDlgItem(hpd
->hWnd
,
661 IDC_PROPERTIESGROUP
);
662 GetWindowRect(hControl
,
664 if (!(dwp
= DeferWindowPos(dwp
,
676 /* use left margin of the IDC_MANUFACTURER label as the right
677 margin of all controls inside the group box */
678 hControl
= GetDlgItem(hpd
->hWnd
,
680 GetWindowRect(hControl
,
682 MapWindowPoints(hControl
,
687 ptMarginGroup
.y
= ptMargin
.y
* 2;
688 Width
= cx
- (2 * ptMarginGroup
.x
);
689 y
+= ptMarginGroup
.y
;
690 if (!(dwp
= DeferWindowPos(dwp
,
701 y
+= rc
.bottom
- rc
.top
+ (ptMargin
.y
/ 2);
703 /* resize the IDC_LOCATION label */
704 hControl
= GetDlgItem(hpd
->hWnd
,
706 GetWindowRect(hControl
,
708 if (!(dwp
= DeferWindowPos(dwp
,
719 y
+= rc
.bottom
- rc
.top
+ (ptMargin
.y
/ 2);
721 /* measure the size of the buttons */
722 hButton
= GetDlgItem(hpd
->hWnd
,
724 GetWindowRect(hButton
,
727 /* resize the IDC_STATUS label */
728 hControl
= GetDlgItem(hpd
->hWnd
,
730 GetWindowRect(hControl
,
732 if (!(dwp
= DeferWindowPos(dwp
,
738 cy
- y
- (3 * ptMargin
.y
) -
739 (rcButton
.bottom
- rcButton
.top
),
745 /* move the IDC_PROPERTIES button */
746 y
= cy
- (2 * ptMargin
.y
) - (rcButton
.bottom
- rcButton
.top
);
747 x
= cx
- ptMarginGroup
.x
- (rcButton
.right
- rcButton
.left
);
748 if (!(dwp
= DeferWindowPos(dwp
,
755 SWP_NOSIZE
| SWP_NOZORDER
)))
760 /* move the IDC_TROUBLESHOOT button */
761 hButton
= GetDlgItem(hpd
->hWnd
,
763 GetWindowRect(hButton
,
765 x
-= (ptMargin
.x
/ 2) + (rcButton
.right
- rcButton
.left
);
766 if (!(dwp
= DeferWindowPos(dwp
,
773 SWP_NOSIZE
| SWP_NOZORDER
)))
778 EndDeferWindowPos(dwp
);
784 EnableTroubleShoot(PHARDWARE_PAGE_DATA hpd
,
787 HWND hBtnTroubleShoot
= GetDlgItem(hpd
->hWnd
,
790 ShowWindow(hBtnTroubleShoot
,
791 Enable
? SW_SHOW
: SW_HIDE
);
797 HardwareDlgProc(IN HWND hwndDlg
,
802 PHARDWARE_PAGE_DATA hpd
;
805 hpd
= (PHARDWARE_PAGE_DATA
)GetWindowLongPtr(hwndDlg
,
808 if (hpd
!= NULL
|| uMsg
== WM_INITDIALOG
)
814 NMHDR
*pnmh
= (NMHDR
*)lParam
;
815 if (pnmh
->hwndFrom
== hpd
->hWndDevList
)
819 case LVN_ITEMCHANGED
:
821 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
823 if ((pnmv
->uChanged
& LVIF_STATE
) &&
824 ((pnmv
->uOldState
& (LVIS_FOCUSED
| LVIS_SELECTED
)) ||
825 (pnmv
->uNewState
& (LVIS_FOCUSED
| LVIS_SELECTED
))))
827 UpdateControlStates(hpd
);
834 DisplaySelectedDeviceProperties(hpd
);
844 switch (LOWORD(wParam
))
846 case IDC_TROUBLESHOOT
:
848 /* FIXME - start the help using the command in the window text */
854 DisplaySelectedDeviceProperties(hpd
);
862 HardwareDlgResize(hpd
,
864 (INT
)HIWORD(lParam
));
869 LPCWSTR szWndText
= (LPCWSTR
)lParam
;
870 EnableTroubleShoot(hpd
,
871 (szWndText
!= NULL
&& szWndText
[0] != L
'\0'));
875 case WM_DEVICECHANGE
:
877 /* FIXME - don't call UpdateDevicesListViewControl for all events */
878 UpdateDevicesListViewControl(hpd
);
885 hpd
= (PHARDWARE_PAGE_DATA
)lParam
;
891 SetWindowLongPtr(hwndDlg
,
895 hpd
->ClassImageListData
.cbSize
= sizeof(SP_CLASSIMAGELIST_DATA
);
897 SetupDiGetClassImageList(&hpd
->ClassImageListData
);
899 /* calculate the size of the devices list view control */
900 hpd
->hWndDevList
= GetDlgItem(hwndDlg
,
902 if (hpd
->hWndDevList
!= NULL
)
905 GetClientRect(hpd
->hWndDevList
,
907 hpd
->DevListViewHeight
= rcClient
.bottom
;
909 if (hpd
->DisplayMode
== HWPD_LARGELIST
)
911 hpd
->DevListViewHeight
= (hpd
->DevListViewHeight
* 3) / 2;
915 /* subclass the parent window */
916 hWndParent
= GetAncestor(hwndDlg
,
918 if (hWndParent
!= NULL
)
922 if (GetClientRect(hWndParent
,
924 SetWindowPos(hwndDlg
,
932 /* subclass the parent window. This is not safe
933 if the parent window belongs to another thread! */
934 hpd
->ParentOldWndProc
= (WNDPROC
)SetWindowLongPtr(hWndParent
,
936 (LONG_PTR
)ParentSubWndProc
);
938 if (hpd
->ParentOldWndProc
!= NULL
&&
940 L
"DevMgrSubClassInfo",
943 hpd
->hWndParent
= hWndParent
;
948 /* initialize the devices list view control */
949 InitializeDevicesList(hpd
);
951 /* fill the devices list view control */
952 FillDevicesListViewControl(hpd
,
956 /* decide whether to show or hide the troubleshoot button */
957 EnableTroubleShoot(hpd
,
958 GetWindowTextLength(hwndDlg
) != 0);
966 /* free devices list */
967 FreeDevicesList(hpd
);
969 /* restore the old window proc of the subclassed parent window */
970 if (hpd
->hWndParent
!= NULL
&& hpd
->ParentOldWndProc
!= NULL
)
972 SetWindowLongPtr(hpd
->hWndParent
,
974 (LONG_PTR
)hpd
->ParentOldWndProc
);
977 if (hpd
->ClassImageListData
.ImageList
!= NULL
)
979 SetupDiDestroyClassImageList(&hpd
->ClassImageListData
);
982 /* free the reference to comctl32 */
983 FreeLibrary(hpd
->hComCtl32
);
984 hpd
->hComCtl32
= NULL
;
986 /* free the allocated resources */
987 HeapFree(GetProcessHeap(),
999 /***************************************************************************
1001 * DeviceCreateHardwarePageEx
1004 * Creates a hardware page
1007 * hWndParent: Handle to the parent window
1008 * lpGuids: An array of guids of devices that are to be listed
1009 * uNumberOfGuids: Numbers of guids in the Guids array
1010 * DisplayMode: Sets the size of the device list view control
1013 * Returns the handle of the hardware page window that has been created or
1014 * NULL if it failed.
1020 DeviceCreateHardwarePageEx(IN HWND hWndParent
,
1022 IN UINT uNumberOfGuids
,
1023 IN HWPAGE_DISPLAYMODE DisplayMode
)
1025 PHARDWARE_PAGE_DATA hpd
;
1027 /* allocate the HARDWARE_PAGE_DATA structure. Make sure it is
1028 zeroed because the initialization code assumes that in
1030 hpd
= HeapAlloc(GetProcessHeap(),
1032 FIELD_OFFSET(HARDWARE_PAGE_DATA
,
1033 ClassDevInfo
[uNumberOfGuids
]));
1039 hpd
->DisplayMode
= ((DisplayMode
> HWPD_MAX
) ? HWPD_STANDARDLIST
: DisplayMode
);
1041 /* initialize the HARDWARE_PAGE_DATA structure */
1042 hpd
->NumberOfGuids
= uNumberOfGuids
;
1047 hpd
->ClassDevInfo
[i
].hDevInfo
= INVALID_HANDLE_VALUE
;
1048 hpd
->ClassDevInfo
[i
].Guid
= lpGuids
[i
];
1051 /* load comctl32.dll dynamically */
1052 hpd
->hComCtl32
= LoadAndInitComctl32();
1053 if (hpd
->hComCtl32
== NULL
)
1058 /* create the dialog */
1059 hWnd
= CreateDialogParam(hDllInstance
,
1060 MAKEINTRESOURCE(IDD_HARDWARE
),
1071 /* oops, something went wrong... */
1072 if (hpd
->hComCtl32
!= NULL
)
1074 FreeLibrary(hpd
->hComCtl32
);
1077 HeapFree(GetProcessHeap(),
1087 /***************************************************************************
1089 * DeviceCreateHardwarePage
1092 * Creates a hardware page
1095 * hWndParent: Handle to the parent window
1096 * lpGuid: Guid of the device
1099 * Returns the handle of the hardware page window that has been created or
1100 * NULL if it failed.
1106 DeviceCreateHardwarePage(IN HWND hWndParent
,
1109 return DeviceCreateHardwarePageEx(hWndParent
,