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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * PROJECT: ReactOS devmgr.dll
22 * FILE: lib/devmgr/advprop.c
23 * PURPOSE: ReactOS Device Manager
24 * PROGRAMMER: Thomas Weidenmueller <w3seek@reactos.com>
25 * Ged Murphy <gedmurphy@reactos.org>
35 DWORD WINAPI
pSetupGuidFromString(PCWSTR pString
, LPGUID lpGUID
);
37 typedef INT_PTR (WINAPI
*PPROPERTYSHEETW
)(LPCPROPSHEETHEADERW
);
38 typedef HPROPSHEETPAGE (WINAPI
*PCREATEPROPERTYSHEETPAGEW
)(LPCPROPSHEETPAGEW
);
39 typedef BOOL (WINAPI
*PDESTROYPROPERTYSHEETPAGE
)(HPROPSHEETPAGE
);
41 typedef struct _DEVADVPROP_INFO
45 WNDPROC ParentOldWndProc
;
48 HDEVINFO DeviceInfoSet
;
49 SP_DEVINFO_DATA DeviceInfoData
;
50 HDEVINFO CurrentDeviceInfoSet
;
51 SP_DEVINFO_DATA CurrentDeviceInfoData
;
52 DEVINST ParentDevInst
;
54 LPCWSTR lpMachineName
;
57 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
58 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
60 DWORD PropertySheetType
;
62 HPROPSHEETPAGE
*DevPropSheets
;
69 UINT FreeDevPropSheets
: 1;
71 UINT DeviceStarted
: 1;
72 UINT DeviceUsageChanged
: 1;
73 UINT CloseDevInst
: 1;
75 UINT DoDefaultDevAction
: 1;
76 UINT PageInitialized
: 1;
77 UINT ShowRemotePages
: 1;
78 UINT HasDriverPage
: 1;
79 UINT HasResourcePage
: 1;
80 UINT HasPowerPage
: 1;
87 /* struct may be dynamically expanded here! */
88 } DEVADVPROP_INFO
, *PDEVADVPROP_INFO
;
91 typedef struct _ENUMDRIVERFILES_CONTEXT
93 HWND hDriversListView
;
95 } ENUMDRIVERFILES_CONTEXT
, *PENUMDRIVERFILES_CONTEXT
;
97 #define PM_INITIALIZE (WM_APP + 0x101)
101 EnumDeviceDriverFilesCallback(IN PVOID Context
,
102 IN UINT Notification
,
107 PENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
= (PENUMDRIVERFILES_CONTEXT
)Context
;
109 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
110 li
.iItem
= EnumDriverFilesContext
->nCount
++;
112 li
.state
= (li
.iItem
== 0 ? LVIS_SELECTED
: 0);
113 li
.stateMask
= LVIS_SELECTED
;
114 li
.pszText
= (LPWSTR
)Param1
;
115 (void)ListView_InsertItem(EnumDriverFilesContext
->hDriversListView
,
122 UpdateDriverDetailsDlg(IN HWND hwndDlg
,
123 IN HWND hDriversListView
,
124 IN PDEVADVPROP_INFO dap
)
126 HDEVINFO DeviceInfoSet
;
127 PSP_DEVINFO_DATA DeviceInfoData
;
128 SP_DRVINFO_DATA DriverInfoData
;
129 ENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
;
131 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
133 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
134 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
138 DeviceInfoSet
= dap
->DeviceInfoSet
;
139 DeviceInfoData
= &dap
->DeviceInfoData
;
142 /* set the device image */
143 SendDlgItemMessage(hwndDlg
,
146 (WPARAM
)dap
->hDevIcon
,
149 /* set the device name edit control text */
150 SetDlgItemText(hwndDlg
,
154 /* fill the driver files list view */
155 EnumDriverFilesContext
.hDriversListView
= hDriversListView
;
156 EnumDriverFilesContext
.nCount
= 0;
158 (void)ListView_DeleteAllItems(EnumDriverFilesContext
.hDriversListView
);
159 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA
);
160 if (FindCurrentDriver(DeviceInfoSet
,
163 SetupDiSetSelectedDriver(DeviceInfoSet
,
167 HSPFILEQ queueHandle
;
169 queueHandle
= SetupOpenFileQueue();
170 if (queueHandle
!= (HSPFILEQ
)INVALID_HANDLE_VALUE
)
172 SP_DEVINSTALL_PARAMS DeviceInstallParams
= {0};
173 DeviceInstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS
);
174 if (SetupDiGetDeviceInstallParams(DeviceInfoSet
,
176 &DeviceInstallParams
))
178 DeviceInstallParams
.FileQueue
= queueHandle
;
179 DeviceInstallParams
.Flags
|= DI_NOVCP
;
181 if (SetupDiSetDeviceInstallParams(DeviceInfoSet
,
183 &DeviceInstallParams
) &&
184 SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES
,
192 /* enumerate the driver files */
193 SetupScanFileQueue(queueHandle
,
194 SPQ_SCAN_USE_CALLBACK
,
196 EnumDeviceDriverFilesCallback
,
197 &EnumDriverFilesContext
,
200 /* update the list view column width */
201 GetClientRect(hDriversListView
,
203 lvc
.mask
= LVCF_WIDTH
;
204 lvc
.cx
= rcClient
.right
;
205 (void)ListView_SetColumn(hDriversListView
,
209 /* highlight the first item from list */
210 if (ListView_GetSelectedCount(hDriversListView
) != 0)
212 ListView_SetItemState(hDriversListView
,
214 LVIS_FOCUSED
| LVIS_SELECTED
,
215 LVIS_FOCUSED
| LVIS_SELECTED
);
220 SetupCloseFileQueue(queueHandle
);
227 UpdateDriverVersionInfoDetails(IN HWND hwndDlg
,
228 IN LPCWSTR lpszDriverPath
)
232 LPVOID lpData
= NULL
;
236 WCHAR szLangInfo
[255];
237 WCHAR szLangPath
[MAX_PATH
];
238 LPWSTR lpCompanyName
= NULL
;
239 LPWSTR lpFileVersion
= NULL
;
240 LPWSTR lpLegalCopyright
= NULL
;
241 LPWSTR lpDigitalSigner
= NULL
;
243 WCHAR szNotAvailable
[255];
245 /* extract version info from selected file */
246 dwVerInfoSize
= GetFileVersionInfoSize(lpszDriverPath
,
251 lpData
= HeapAlloc(GetProcessHeap(),
257 if (!GetFileVersionInfo(lpszDriverPath
,
263 if (!VerQueryValue(lpData
,
264 L
"\\VarFileInfo\\Translation",
269 dwLangId
= *(LPDWORD
)lpInfo
;
270 swprintf(szLangInfo
, L
"\\StringFileInfo\\%04x%04x\\",
271 LOWORD(dwLangId
), HIWORD(dwLangId
));
273 /* read CompanyName */
274 wcscpy(szLangPath
, szLangInfo
);
275 wcscat(szLangPath
, L
"CompanyName");
277 VerQueryValue(lpData
,
279 (void **)&lpCompanyName
,
282 /* read FileVersion */
283 wcscpy(szLangPath
, szLangInfo
);
284 wcscat(szLangPath
, L
"FileVersion");
286 VerQueryValue(lpData
,
288 (void **)&lpFileVersion
,
291 /* read LegalTrademarks */
292 wcscpy(szLangPath
, szLangInfo
);
293 wcscat(szLangPath
, L
"LegalCopyright");
295 VerQueryValue(lpData
,
297 (void **)&lpLegalCopyright
,
300 /* TODO: read digital signer info */
303 if (!LoadString(hDllInstance
,
306 sizeof(szNotAvailable
) / sizeof(WCHAR
)))
308 wcscpy(szNotAvailable
, L
"n/a");
313 lpCompanyName
= szNotAvailable
;
314 SetDlgItemText(hwndDlg
,
319 lpFileVersion
= szNotAvailable
;
320 SetDlgItemText(hwndDlg
,
324 if (!lpLegalCopyright
)
325 lpLegalCopyright
= szNotAvailable
;
326 SetDlgItemText(hwndDlg
,
330 if (!lpDigitalSigner
)
331 lpDigitalSigner
= szNotAvailable
;
332 SetDlgItemText(hwndDlg
,
336 /* release version info */
338 HeapFree(GetProcessHeap(),
346 DriverDetailsDlgProc(IN HWND hwndDlg
,
351 PDEVADVPROP_INFO dap
;
354 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
357 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
363 switch (LOWORD(wParam
))
386 HWND hDriversListView
;
388 dap
= (PDEVADVPROP_INFO
)lParam
;
391 SetWindowLongPtr(hwndDlg
,
395 hDriversListView
= GetDlgItem(hwndDlg
,
398 /* add a column to the list view control */
399 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
400 lvc
.fmt
= LVCFMT_LEFT
;
402 (void)ListView_InsertColumn(hDriversListView
,
406 UpdateDriverDetailsDlg(hwndDlg
,
417 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
419 switch (pnmhdr
->code
)
421 case LVN_ITEMCHANGED
:
423 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
424 HWND hDriversListView
= GetDlgItem(hwndDlg
,
427 if (ListView_GetSelectedCount(hDriversListView
) == 0)
429 /* nothing is selected - empty the labels */
430 SetDlgItemText(hwndDlg
,
433 SetDlgItemText(hwndDlg
,
436 SetDlgItemText(hwndDlg
,
439 SetDlgItemText(hwndDlg
,
443 else if (pnmv
->uNewState
!= 0)
445 /* extract version info and update the labels */
446 WCHAR szDriverPath
[MAX_PATH
];
448 ListView_GetItemText(hDriversListView
,
454 UpdateDriverVersionInfoDetails(hwndDlg
,
469 UpdateDriverDlg(IN HWND hwndDlg
,
470 IN PDEVADVPROP_INFO dap
)
472 HDEVINFO DeviceInfoSet
;
473 PSP_DEVINFO_DATA DeviceInfoData
;
475 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
477 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
478 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
482 DeviceInfoSet
= dap
->DeviceInfoSet
;
483 DeviceInfoData
= &dap
->DeviceInfoData
;
486 /* set the device image */
487 SendDlgItemMessage(hwndDlg
,
490 (WPARAM
)dap
->hDevIcon
,
493 /* set the device name edit control text */
494 SetDlgItemText(hwndDlg
,
498 /* query the driver provider */
499 if (GetDriverProviderString(DeviceInfoSet
,
502 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
504 SetDlgItemText(hwndDlg
,
509 /* query the driver date */
510 if (GetDriverDateString(DeviceInfoSet
,
513 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
515 SetDlgItemText(hwndDlg
,
520 /* query the driver version */
521 if (GetDriverVersionString(DeviceInfoSet
,
524 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
526 SetDlgItemText(hwndDlg
,
535 AdvProcDriverDlgProc(IN HWND hwndDlg
,
540 PDEVADVPROP_INFO dap
;
543 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
546 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
552 switch (LOWORD(wParam
))
554 case IDC_DRIVERDETAILS
:
556 DialogBoxParam(hDllInstance
,
557 MAKEINTRESOURCE(IDD_DRIVERDETAILS
),
559 DriverDetailsDlgProc
,
569 NMHDR
*hdr
= (NMHDR
*)lParam
;
580 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
583 SetWindowLongPtr(hwndDlg
,
587 UpdateDriverDlg(hwndDlg
,
601 SetListViewText(HWND hwnd
,
607 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
610 li
.state
= 0; //(li.iItem == 0 ? LVIS_SELECTED : 0);
611 li
.stateMask
= LVIS_SELECTED
;
613 (void)ListView_InsertItem(hwnd
,
619 UpdateDetailsDlg(IN HWND hwndDlg
,
620 IN PDEVADVPROP_INFO dap
)
631 IDS_PROP_HARDWAREIDS
,
632 IDS_PROP_COMPATIBLEIDS
,
633 IDS_PROP_MATCHINGDEVICEID
,
636 IDS_PROP_CAPABILITIES
,
637 IDS_PROP_DEVNODEFLAGS
,
638 IDS_PROP_CONFIGFLAGS
,
639 IDS_PROP_CSCONFIGFLAGS
,
640 IDS_PROP_EJECTIONRELATIONS
,
641 IDS_PROP_REMOVALRELATIONS
,
642 IDS_PROP_BUSRELATIONS
,
643 IDS_PROP_DEVUPPERFILTERS
,
644 IDS_PROP_DEVLOWERFILTERS
,
645 IDS_PROP_CLASSUPPERFILTERS
,
646 IDS_PROP_CLASSLOWERFILTERS
,
647 IDS_PROP_CLASSINSTALLER
,
648 IDS_PROP_CLASSCOINSTALLER
,
649 IDS_PROP_DEVICECOINSTALLER
,
650 IDS_PROP_FIRMWAREREVISION
,
651 IDS_PROP_CURRENTPOWERSTATE
,
652 IDS_PROP_POWERCAPABILITIES
,
653 IDS_PROP_POWERSTATEMAPPINGS
657 /* set the device image */
658 SendDlgItemMessage(hwndDlg
,
661 (WPARAM
)dap
->hDevIcon
,
664 /* set the device name edit control text */
665 SetDlgItemText(hwndDlg
,
670 hwndComboBox
= GetDlgItem(hwndDlg
,
671 IDC_DETAILSPROPNAME
);
673 hwndListView
= GetDlgItem(hwndDlg
,
674 IDC_DETAILSPROPVALUE
);
676 for (i
= 0; i
!= sizeof(Properties
) / sizeof(Properties
[0]); i
++)
678 /* fill in the device usage combo box */
679 if (LoadString(hDllInstance
,
682 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
684 SendMessage(hwndComboBox
,
687 (LPARAM
)dap
->szTemp
);
692 GetClientRect(hwndListView
,
695 /* add a column to the list view control */
696 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
697 lvc
.fmt
= LVCFMT_LEFT
;
698 lvc
.cx
= rcClient
.right
;
699 (void)ListView_InsertColumn(hwndListView
,
703 SendMessage(hwndComboBox
,
708 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
710 SetFocus(hwndComboBox
);
715 DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap
,
716 IN HWND hwndListView
,
719 HDEVINFO DeviceInfoSet
;
720 PSP_DEVINFO_DATA DeviceInfoData
;
729 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
731 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
732 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
736 DeviceInfoSet
= dap
->DeviceInfoSet
;
737 DeviceInfoData
= &dap
->DeviceInfoData
;
741 SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
750 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
752 swprintf(dap
->szTemp
, L
"Error: Getting the size failed! (Error: %ld)", GetLastError());
753 SetListViewText(hwndListView
, 0, dap
->szTemp
);
758 lpBuffer
= HeapAlloc(GetProcessHeap(),
761 if (lpBuffer
== NULL
)
763 SetListViewText(hwndListView
, 0, L
"Error: Allocating the buffer failed!");
767 if (SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
775 if (dwType
== REG_SZ
)
777 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
779 else if (dwType
== REG_MULTI_SZ
)
781 lpStr
= (LPWSTR
)lpBuffer
;
785 len
= wcslen(lpStr
) + 1;
787 SetListViewText(hwndListView
, index
, lpStr
);
793 else if (dwType
== REG_DWORD
)
795 dwValue
= *(DWORD
*) lpBuffer
;
799 case SPDRP_CAPABILITIES
:
801 if (dwValue
& CM_DEVCAP_LOCKSUPPORTED
)
802 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_LOCKSUPPORTED");
803 if (dwValue
& CM_DEVCAP_EJECTSUPPORTED
)
804 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_EJECTSUPPORTED");
805 if (dwValue
& CM_DEVCAP_REMOVABLE
)
806 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_REMOVABLE");
807 if (dwValue
& CM_DEVCAP_DOCKDEVICE
)
808 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_DOCKDEVICE");
809 if (dwValue
& CM_DEVCAP_UNIQUEID
)
810 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_UNIQUEID");
811 if (dwValue
& CM_DEVCAP_SILENTINSTALL
)
812 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SILENTINSTALL");
813 if (dwValue
& CM_DEVCAP_RAWDEVICEOK
)
814 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_RAWDEVICEOK");
815 if (dwValue
& CM_DEVCAP_SURPRISEREMOVALOK
)
816 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SURPRISEREMOVALOK");
817 if (dwValue
& CM_DEVCAP_HARDWAREDISABLED
)
818 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_HARDWAREDISABLED");
819 if (dwValue
& CM_DEVCAP_NONDYNAMIC
)
820 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_NONDYNAMIC");
823 case SPDRP_CONFIGFLAGS
:
825 if (dwValue
& CONFIGFLAG_DISABLED
)
826 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_DISABLED");
827 if (dwValue
& CONFIGFLAG_REMOVED
)
828 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REMOVED");
829 if (dwValue
& CONFIGFLAG_MANUAL_INSTALL
)
830 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_MANUAL_INSTALL");
831 if (dwValue
& CONFIGFLAG_IGNORE_BOOT_LC
)
832 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_IGNORE_BOOT_LC");
833 if (dwValue
& CONFIGFLAG_NET_BOOT
)
834 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NET_BOOT");
835 if (dwValue
& CONFIGFLAG_REINSTALL
)
836 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REINSTALL");
837 if (dwValue
& CONFIGFLAG_FAILEDINSTALL
)
838 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_FAILEDINSTALL");
839 if (dwValue
& CONFIGFLAG_CANTSTOPACHILD
)
840 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_CANTSTOPACHILD");
841 if (dwValue
& CONFIGFLAG_OKREMOVEROM
)
842 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_OKREMOVEROM");
843 if (dwValue
& CONFIGFLAG_NOREMOVEEXIT
)
844 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NOREMOVEEXIT");
848 swprintf(dap
->szTemp
, L
"0x%08lx", dwValue
);
849 SetListViewText(hwndListView
, 0, dap
->szTemp
);
855 SetListViewText(hwndListView
, 0, L
"Error: Unsupported value type!");
861 SetListViewText(hwndListView
, 0, L
"Error: Retrieving the value failed!");
864 HeapFree(GetProcessHeap(),
870 DisplayDevNodeFlags(IN PDEVADVPROP_INFO dap
,
871 IN HWND hwndListView
)
877 CM_Get_DevNode_Status_Ex(&dwStatus
,
879 dap
->DeviceInfoData
.DevInst
,
884 if (dwStatus
& DN_ROOT_ENUMERATED
)
885 SetListViewText(hwndListView
, index
++, L
"DN_ROOT_ENUMERATED");
886 if (dwStatus
& DN_DRIVER_LOADED
)
887 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_LOADED");
888 if (dwStatus
& DN_ENUM_LOADED
)
889 SetListViewText(hwndListView
, index
++, L
"DN_ENUM_LOADED");
890 if (dwStatus
& DN_STARTED
)
891 SetListViewText(hwndListView
, index
++, L
"DN_STARTED");
892 if (dwStatus
& DN_MANUAL
)
893 SetListViewText(hwndListView
, index
++, L
"DN_MANUAL");
894 if (dwStatus
& DN_NEED_TO_ENUM
)
895 SetListViewText(hwndListView
, index
++, L
"DN_NEED_TO_ENUM");
896 if (dwStatus
& DN_DRIVER_BLOCKED
)
897 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_BLOCKED");
898 if (dwStatus
& DN_HARDWARE_ENUM
)
899 SetListViewText(hwndListView
, index
++, L
"DN_HARDWARE_ENUM");
900 if (dwStatus
& DN_NEED_RESTART
)
901 SetListViewText(hwndListView
, index
++, L
"DN_NEED_RESTART");
902 if (dwStatus
& DN_CHILD_WITH_INVALID_ID
)
903 SetListViewText(hwndListView
, index
++, L
"DN_CHILD_WITH_INVALID_ID");
904 if (dwStatus
& DN_HAS_PROBLEM
)
905 SetListViewText(hwndListView
, index
++, L
"DN_HAS_PROBLEM");
906 if (dwStatus
& DN_FILTERED
)
907 SetListViewText(hwndListView
, index
++, L
"DN_FILTERED");
908 if (dwStatus
& DN_LEGACY_DRIVER
)
909 SetListViewText(hwndListView
, index
++, L
"DN_LEGACY_DRIVER");
910 if (dwStatus
& DN_DISABLEABLE
)
911 SetListViewText(hwndListView
, index
++, L
"DN_DISABLEABLE");
912 if (dwStatus
& DN_REMOVABLE
)
913 SetListViewText(hwndListView
, index
++, L
"DN_REMOVABLE");
914 if (dwStatus
& DN_PRIVATE_PROBLEM
)
915 SetListViewText(hwndListView
, index
++, L
"DN_PRIVATE_PROBLEM");
916 if (dwStatus
& DN_MF_PARENT
)
917 SetListViewText(hwndListView
, index
++, L
"DN_MF_PARENT");
918 if (dwStatus
& DN_MF_CHILD
)
919 SetListViewText(hwndListView
, index
++, L
"DN_MF_CHILD");
920 if (dwStatus
& DN_WILL_BE_REMOVED
)
921 SetListViewText(hwndListView
, index
++, L
"DN_WILL_BE_REMOVED");
923 if (dwStatus
& DN_NOT_FIRST_TIMEE
)
924 SetListViewText(hwndListView
, index
++, L
"DN_NOT_FIRST_TIMEE");
925 if (dwStatus
& DN_STOP_FREE_RES
)
926 SetListViewText(hwndListView
, index
++, L
"DN_STOP_FREE_RES");
927 if (dwStatus
& DN_REBAL_CANDIDATE
)
928 SetListViewText(hwndListView
, index
++, L
"DN_REBAL_CANDIDATE");
929 if (dwStatus
& DN_BAD_PARTIAL
)
930 SetListViewText(hwndListView
, index
++, L
"DN_BAD_PARTIAL");
931 if (dwStatus
& DN_NT_ENUMERATOR
)
932 SetListViewText(hwndListView
, index
++, L
"DN_NT_ENUMERATOR");
933 if (dwStatus
& DN_NT_DRIVER
)
934 SetListViewText(hwndListView
, index
++, L
"DN_NT_DRIVER");
936 if (dwStatus
& DN_NEEDS_LOCKING
)
937 SetListViewText(hwndListView
, index
++, L
"DN_NEEDS_LOCKING");
938 if (dwStatus
& DN_ARM_WAKEUP
)
939 SetListViewText(hwndListView
, index
++, L
"DN_ARM_WAKEUP");
940 if (dwStatus
& DN_APM_ENUMERATOR
)
941 SetListViewText(hwndListView
, index
++, L
"DN_APM_ENUMERATOR");
942 if (dwStatus
& DN_APM_DRIVER
)
943 SetListViewText(hwndListView
, index
++, L
"DN_APM_DRIVER");
944 if (dwStatus
& DN_SILENT_INSTALL
)
945 SetListViewText(hwndListView
, index
++, L
"DN_SILENT_INSTALL");
946 if (dwStatus
& DN_NO_SHOW_IN_DM
)
947 SetListViewText(hwndListView
, index
++, L
"DN_NO_SHOW_IN_DM");
948 if (dwStatus
& DN_BOOT_LOG_PROB
)
949 SetListViewText(hwndListView
, index
++, L
"DN_BOOT_LOG_PROB");
951 // swprintf(dap->szTemp, L"0x%08x", dwStatus);
952 // SetListViewText(hwndListView, 0, dap->szTemp);
957 DisplayDevNodeEnumerator(IN PDEVADVPROP_INFO dap
,
958 IN HWND hwndListView
)
960 HDEVINFO DeviceInfoSet
;
961 PSP_DEVINFO_DATA DeviceInfoData
;
965 DWORD dwSize
= 256 * sizeof(WCHAR
);
967 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
969 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
970 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
974 DeviceInfoSet
= dap
->DeviceInfoSet
;
975 DeviceInfoData
= &dap
->DeviceInfoData
;
978 CM_Get_DevNode_Registry_Property_ExW(DeviceInfoData
->DevInst
,
979 CM_DRP_ENUMERATOR_NAME
,
986 SetListViewText(hwndListView
, 0, szBuffer
);
991 DisplayCsFlags(IN PDEVADVPROP_INFO dap
,
992 IN HWND hwndListView
)
997 CM_Get_HW_Prof_Flags_Ex(dap
->szDevName
,
998 0, /* current hardware profile */
1004 if (dwValue
& CSCONFIGFLAG_DISABLED
)
1005 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DISABLED");
1007 if (dwValue
& CSCONFIGFLAG_DO_NOT_CREATE
)
1008 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_CREATE");
1010 if (dwValue
& CSCONFIGFLAG_DO_NOT_START
)
1011 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_START");
1016 DisplayMatchingDeviceId(IN PDEVADVPROP_INFO dap
,
1017 IN HWND hwndListView
)
1019 HDEVINFO DeviceInfoSet
;
1020 PSP_DEVINFO_DATA DeviceInfoData
;
1021 WCHAR szBuffer
[256];
1026 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1028 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1029 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1033 DeviceInfoSet
= dap
->DeviceInfoSet
;
1034 DeviceInfoData
= &dap
->DeviceInfoData
;
1037 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1043 if (hKey
!= INVALID_HANDLE_VALUE
)
1045 dwSize
= 256 * sizeof(WCHAR
);
1046 if (RegQueryValueEx(hKey
,
1047 L
"MatchingDeviceId",
1051 &dwSize
) == ERROR_SUCCESS
)
1053 SetListViewText(hwndListView
, 0, szBuffer
);
1062 DisplayDeviceCoinstallers(IN PDEVADVPROP_INFO dap
,
1063 IN HWND hwndListView
)
1065 HDEVINFO DeviceInfoSet
;
1066 PSP_DEVINFO_DATA DeviceInfoData
;
1075 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1077 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1078 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1082 DeviceInfoSet
= dap
->DeviceInfoSet
;
1083 DeviceInfoData
= &dap
->DeviceInfoData
;
1086 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1092 if (hKey
!= INVALID_HANDLE_VALUE
)
1095 if (RegQueryValueEx(hKey
,
1100 &dwSize
) == ERROR_SUCCESS
&&
1104 lpBuffer
= HeapAlloc(GetProcessHeap(),
1108 RegQueryValueEx(hKey
,
1115 lpStr
= (LPWSTR
)lpBuffer
;
1119 len
= wcslen(lpStr
) + 1;
1121 SetListViewText(hwndListView
, index
, lpStr
);
1127 HeapFree(GetProcessHeap(),
1138 DisplayClassProperties(IN PDEVADVPROP_INFO dap
,
1139 IN HWND hwndListView
,
1140 IN LPWSTR lpProperty
)
1142 HDEVINFO DeviceInfoSet
;
1143 PSP_DEVINFO_DATA DeviceInfoData
;
1144 WCHAR szClassGuid
[45];
1154 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1156 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1157 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1161 DeviceInfoSet
= dap
->DeviceInfoSet
;
1162 DeviceInfoData
= &dap
->DeviceInfoData
;
1165 dwSize
= 45 * sizeof(WCHAR
);
1166 if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
1170 (LPBYTE
)szClassGuid
,
1175 pSetupGuidFromString(szClassGuid
,
1178 hKey
= SetupDiOpenClassRegKey(&ClassGuid
,
1180 if (hKey
!= INVALID_HANDLE_VALUE
)
1183 if (RegQueryValueEx(hKey
,
1188 &dwSize
) == ERROR_SUCCESS
&&
1191 lpBuffer
= HeapAlloc(GetProcessHeap(),
1195 RegQueryValueEx(hKey
,
1202 if (dwType
== REG_SZ
)
1204 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
1206 else if (dwType
== REG_MULTI_SZ
)
1208 lpStr
= (LPWSTR
)lpBuffer
;
1212 len
= wcslen(lpStr
) + 1;
1214 SetListViewText(hwndListView
, index
, lpStr
);
1221 HeapFree(GetProcessHeap(),
1232 DisplayDeviceProperties(IN PDEVADVPROP_INFO dap
,
1233 IN HWND hwndComboBox
,
1234 IN HWND hwndListView
)
1238 Index
= (INT
)SendMessage(hwndComboBox
,
1242 if (Index
== CB_ERR
)
1245 (void)ListView_DeleteAllItems(hwndListView
);
1250 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
1253 case 1: /* Hardware ID */
1254 DisplayDevicePropertyText(dap
,
1259 case 2: /* Compatible IDs */
1260 DisplayDevicePropertyText(dap
,
1262 SPDRP_COMPATIBLEIDS
);
1265 case 3: /* Matching ID */
1266 DisplayMatchingDeviceId(dap
,
1270 case 4: /* Service */
1271 DisplayDevicePropertyText(dap
,
1276 case 5: /* Enumerator */
1277 DisplayDevNodeEnumerator(dap
,
1281 case 6: /* Capabilities */
1282 DisplayDevicePropertyText(dap
,
1284 SPDRP_CAPABILITIES
);
1287 case 7: /* Devnode Flags */
1288 DisplayDevNodeFlags(dap
,
1292 case 8: /* Config Flags */
1293 DisplayDevicePropertyText(dap
,
1298 case 9: /* CSConfig Flags */
1304 case 10: /* Ejection relation */
1307 case 11: /* Removal relations */
1310 case 12: /* Bus relation */
1314 case 13: /* Device Upper Filters */
1315 DisplayDevicePropertyText(dap
,
1317 SPDRP_UPPERFILTERS
);
1320 case 14: /* Device Lower Filters */
1321 DisplayDevicePropertyText(dap
,
1323 SPDRP_LOWERFILTERS
);
1326 case 15: /* Class Upper Filters */
1327 DisplayClassProperties(dap
,
1332 case 16: /* Class Lower Filters */
1333 DisplayClassProperties(dap
,
1338 case 17: /* Class Installer */
1339 DisplayClassProperties(dap
,
1345 case 18: /* Class Coinstaller */
1349 case 19: /* Device Coinstaller */
1350 DisplayDeviceCoinstallers(dap
,
1355 case 20: /* Firmware Revision */
1358 case 21: /* Current Power State */
1361 case 20: /* Power Capabilities */
1364 case 21: /* Power State Mappings */
1369 SetListViewText(hwndListView
, 0, L
"<Not implemented yet>");
1377 AdvProcDetailsDlgProc(IN HWND hwndDlg
,
1382 PDEVADVPROP_INFO dap
;
1383 INT_PTR Ret
= FALSE
;
1385 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
1388 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
1394 switch (LOWORD(wParam
))
1396 case IDC_DETAILSPROPNAME
:
1397 if (HIWORD(wParam
) == CBN_SELCHANGE
)
1399 DisplayDeviceProperties(dap
,
1400 GetDlgItem(hwndDlg
, IDC_DETAILSPROPNAME
),
1401 GetDlgItem(hwndDlg
, IDC_DETAILSPROPVALUE
));
1410 NMHDR
*hdr
= (NMHDR
*)lParam
;
1421 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1424 SetWindowLongPtr(hwndDlg
,
1428 UpdateDetailsDlg(hwndDlg
,
1442 InitDevUsageActions(IN HWND hwndDlg
,
1444 IN PDEVADVPROP_INFO dap
)
1455 i
!= sizeof(Actions
) / sizeof(Actions
[0]);
1458 /* fill in the device usage combo box */
1459 if (LoadString(hDllInstance
,
1462 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1464 Index
= (INT
)SendMessage(hComboBox
,
1467 (LPARAM
)dap
->szTemp
);
1468 if (Index
!= CB_ERR
)
1470 SendMessage(hComboBox
,
1473 (LPARAM
)Actions
[i
]);
1477 case IDS_ENABLEDEVICE
:
1478 if (dap
->DeviceStarted
)
1480 SendMessage(hComboBox
,
1487 case IDS_DISABLEDEVICE
:
1488 if (!dap
->DeviceStarted
)
1490 SendMessage(hComboBox
,
1507 GetSelectedUsageAction(IN HWND hComboBox
)
1512 Index
= (INT
)SendMessage(hComboBox
,
1516 if (Index
!= CB_ERR
)
1518 INT iRet
= (INT
) SendMessage(hComboBox
,
1533 ApplyGeneralSettings(IN HWND hwndDlg
,
1534 IN PDEVADVPROP_INFO dap
)
1538 if (dap
->DeviceUsageChanged
&& dap
->IsAdmin
&& dap
->CanDisable
)
1540 UINT SelectedUsageAction
;
1541 BOOL NeedReboot
= FALSE
;
1543 SelectedUsageAction
= GetSelectedUsageAction(GetDlgItem(hwndDlg
,
1545 switch (SelectedUsageAction
)
1547 case IDS_ENABLEDEVICE
:
1548 if (!dap
->DeviceStarted
)
1550 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1551 &dap
->DeviceInfoData
,
1558 case IDS_DISABLEDEVICE
:
1559 if (dap
->DeviceStarted
)
1561 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1562 &dap
->DeviceInfoData
,
1577 /* make PropertySheet() return PSM_REBOOTSYSTEM */
1578 PropSheet_RebootSystem(hwndDlg
);
1583 /* FIXME - display an error message */
1584 DPRINT1("Failed to enable/disable device! LastError: %d\n",
1589 Ret
= !dap
->DeviceUsageChanged
;
1591 /* disable the apply button */
1592 PropSheet_UnChanged(GetParent(hwndDlg
),
1594 dap
->DeviceUsageChanged
= FALSE
;
1600 UpdateDevInfo(IN HWND hwndDlg
,
1601 IN PDEVADVPROP_INFO dap
,
1604 HWND hDevUsage
, hPropSheetDlg
, hDevProbBtn
;
1606 ULONG Status
, ProblemNumber
;
1607 SP_DEVINSTALL_PARAMS_W InstallParams
;
1608 UINT TroubleShootStrId
= IDS_TROUBLESHOOTDEV
;
1609 BOOL bFlag
, bDevActionAvailable
= TRUE
;
1610 BOOL bDrvInstalled
= FALSE
;
1612 HDEVINFO DeviceInfoSet
= NULL
;
1613 PSP_DEVINFO_DATA DeviceInfoData
= NULL
;
1614 PROPSHEETHEADER psh
;
1615 DWORD nDriverPages
= 0;
1616 BOOL RecalcPages
= FALSE
;
1618 hPropSheetDlg
= GetParent(hwndDlg
);
1620 if (dap
->PageInitialized
)
1622 /* switch to the General page */
1623 PropSheet_SetCurSelByID(hPropSheetDlg
,
1626 /* remove and destroy the existing device property sheet pages */
1627 if (dap
->DevPropSheets
!= NULL
)
1630 iPage
!= dap
->nDevPropSheets
;
1633 if (dap
->DevPropSheets
[iPage
] != NULL
)
1635 PropSheet_RemovePage(hPropSheetDlg
,
1637 dap
->DevPropSheets
[iPage
]);
1646 if (dap
->FreeDevPropSheets
)
1648 /* don't free the array if it's the one allocated in
1649 DisplayDeviceAdvancedProperties */
1650 HeapFree(GetProcessHeap(),
1652 dap
->DevPropSheets
);
1654 dap
->FreeDevPropSheets
= FALSE
;
1657 dap
->DevPropSheets
= NULL
;
1658 dap
->nDevPropSheets
= 0;
1662 /* create a new device info set and re-open the device */
1663 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1665 SetupDiDestroyDeviceInfoList(dap
->CurrentDeviceInfoSet
);
1668 dap
->ParentDevInst
= 0;
1669 dap
->CurrentDeviceInfoSet
= SetupDiCreateDeviceInfoListEx(NULL
,
1673 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1675 if (SetupDiOpenDeviceInfo(dap
->CurrentDeviceInfoSet
,
1679 &dap
->CurrentDeviceInfoData
))
1681 if (dap
->CloseDevInst
)
1683 SetupDiDestroyDeviceInfoList(dap
->DeviceInfoSet
);
1686 dap
->CloseDevInst
= TRUE
;
1687 dap
->DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1688 dap
->DeviceInfoData
= dap
->CurrentDeviceInfoData
;
1689 dap
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
1697 /* get the parent node from the initial devinst */
1698 CM_Get_Parent_Ex(&dap
->ParentDevInst
,
1699 dap
->DeviceInfoData
.DevInst
,
1704 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1706 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1707 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1711 DeviceInfoSet
= dap
->DeviceInfoSet
;
1712 DeviceInfoData
= &dap
->DeviceInfoData
;
1717 DeviceInfoSet
= dap
->DeviceInfoSet
;
1718 DeviceInfoData
= &dap
->DeviceInfoData
;
1721 dap
->HasDriverPage
= FALSE
;
1722 dap
->HasResourcePage
= FALSE
;
1723 dap
->HasPowerPage
= FALSE
;
1724 if (IsDriverInstalled(DeviceInfoData
->DevInst
,
1729 if (SetupDiCallClassInstaller((dap
->ShowRemotePages
?
1730 DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
:
1731 DIF_ADDPROPERTYPAGE_ADVANCED
),
1735 /* get install params */
1736 InstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
1737 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet
,
1741 /* zero the flags */
1742 InstallParams
.Flags
= 0;
1745 dap
->HasDriverPage
= !(InstallParams
.Flags
& DI_DRIVERPAGE_ADDED
);
1746 dap
->HasResourcePage
= !(InstallParams
.Flags
& DI_RESOURCEPAGE_ADDED
);
1747 dap
->HasPowerPage
= !(InstallParams
.Flags
& DI_FLAGSEX_POWERPAGE_ADDED
);
1751 /* get the device icon */
1752 if (dap
->hDevIcon
!= NULL
)
1754 DestroyIcon(dap
->hDevIcon
);
1755 dap
->hDevIcon
= NULL
;
1757 if (!SetupDiLoadClassIcon(&DeviceInfoData
->ClassGuid
,
1761 dap
->hDevIcon
= NULL
;
1764 /* get the device name */
1765 if (GetDeviceDescriptionString(DeviceInfoSet
,
1768 sizeof(dap
->szDevName
) / sizeof(dap
->szDevName
[0])))
1770 PropSheet_SetTitle(hPropSheetDlg
,
1775 /* set the device image */
1776 SendDlgItemMessage(hwndDlg
,
1779 (WPARAM
)dap
->hDevIcon
,
1782 /* set the device name edit control text */
1783 SetDlgItemText(hwndDlg
,
1787 /* set the device type edit control text */
1788 if (GetDeviceTypeString(DeviceInfoData
,
1790 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1792 SetDlgItemText(hwndDlg
,
1797 /* set the device manufacturer edit control text */
1798 if (GetDeviceManufacturerString(DeviceInfoSet
,
1801 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1803 SetDlgItemText(hwndDlg
,
1804 IDC_DEVMANUFACTURER
,
1808 /* set the device location edit control text */
1809 if (GetDeviceLocationString(DeviceInfoSet
,
1813 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1815 SetDlgItemText(hwndDlg
,
1820 /* set the device status edit control text */
1821 if (GetDeviceStatusString(DeviceInfoData
->DevInst
,
1824 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1826 SetDlgItemText(hwndDlg
,
1831 /* set the device troubleshoot button text and disable it if necessary */
1832 hDevProbBtn
= GetDlgItem(hwndDlg
,
1834 cr
= CM_Get_DevNode_Status_Ex(&Status
,
1836 DeviceInfoData
->DevInst
,
1839 if (cr
== CR_SUCCESS
&& (Status
& DN_HAS_PROBLEM
))
1841 switch (ProblemNumber
)
1843 case CM_PROB_DEVLOADER_FAILED
:
1845 /* FIXME - only if it's not a root bus devloader,
1846 disable the button otherwise */
1847 TroubleShootStrId
= IDS_UPDATEDRV
;
1851 case CM_PROB_OUT_OF_MEMORY
:
1852 case CM_PROB_ENTRY_IS_WRONG_TYPE
:
1853 case CM_PROB_LACKED_ARBITRATOR
:
1854 case CM_PROB_FAILED_START
:
1856 case CM_PROB_UNKNOWN_RESOURCE
:
1858 TroubleShootStrId
= IDS_UPDATEDRV
;
1862 case CM_PROB_BOOT_CONFIG_CONFLICT
:
1863 case CM_PROB_NORMAL_CONFLICT
:
1864 case CM_PROB_REENUMERATION
:
1866 /* FIXME - Troubleshoot conflict */
1870 case CM_PROB_FAILED_FILTER
:
1871 case CM_PROB_REINSTALL
:
1872 case CM_PROB_FAILED_INSTALL
:
1874 TroubleShootStrId
= IDS_REINSTALLDRV
;
1878 case CM_PROB_DEVLOADER_NOT_FOUND
:
1881 1) if it's a missing system devloader:
1882 - disable the button (Reinstall Driver)
1883 2) if it's not a system devloader but still missing:
1885 3) if it's not a system devloader but the file can be found:
1887 4) if it's a missing or empty software key
1893 case CM_PROB_INVALID_DATA
:
1894 case CM_PROB_PARTIAL_LOG_CONF
:
1895 case CM_PROB_NO_VALID_LOG_CONF
:
1896 case CM_PROB_HARDWARE_DISABLED
:
1897 case CM_PROB_CANT_SHARE_IRQ
:
1898 case CM_PROB_TRANSLATION_FAILED
:
1899 case CM_PROB_SYSTEM_SHUTDOWN
:
1900 case CM_PROB_PHANTOM
:
1901 bDevActionAvailable
= FALSE
;
1904 case CM_PROB_NOT_VERIFIED
:
1905 case CM_PROB_DEVICE_NOT_THERE
:
1906 /* FIXME - search hardware */
1909 case CM_PROB_NEED_RESTART
:
1910 case CM_PROB_WILL_BE_REMOVED
:
1912 case CM_PROB_TOO_EARLY
:
1913 case CM_PROB_DISABLED_SERVICE
:
1914 TroubleShootStrId
= IDS_REBOOT
;
1917 case CM_PROB_REGISTRY
:
1918 /* FIXME - check registry? */
1921 case CM_PROB_DISABLED
:
1922 /* if device was disabled by the user: */
1923 TroubleShootStrId
= IDS_ENABLEDEV
;
1924 /* FIXME - otherwise disable button because the device was
1925 disabled by the system*/
1928 case CM_PROB_DEVLOADER_NOT_READY
:
1929 /* FIXME - if it's a graphics adapter:
1930 - if it's a a secondary adapter and the main adapter
1940 case CM_PROB_FAILED_ADD
:
1941 TroubleShootStrId
= IDS_PROPERTIES
;
1946 if (LoadString(hDllInstance
,
1949 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])) != 0)
1951 SetWindowText(hDevProbBtn
,
1954 EnableWindow(hDevProbBtn
,
1955 dap
->IsAdmin
&& bDevActionAvailable
);
1957 /* check if the device can be enabled/disabled */
1958 hDevUsage
= GetDlgItem(hwndDlg
,
1961 dap
->CanDisable
= FALSE
;
1962 dap
->DeviceStarted
= FALSE
;
1964 if (CanDisableDevice(DeviceInfoData
->DevInst
,
1968 dap
->CanDisable
= bFlag
;
1971 if (IsDeviceStarted(DeviceInfoData
->DevInst
,
1975 dap
->DeviceStarted
= bFlag
;
1978 /* enable/disable the device usage controls */
1979 EnableWindow(GetDlgItem(hwndDlg
,
1981 dap
->CanDisable
&& dap
->IsAdmin
);
1982 EnableWindow(hDevUsage
,
1983 dap
->CanDisable
&& dap
->IsAdmin
);
1985 /* clear the combobox */
1986 SendMessage(hDevUsage
,
1990 if (dap
->CanDisable
)
1992 InitDevUsageActions(hwndDlg
,
1997 /* find out how many new device property sheets to add.
1998 fake a PROPSHEETHEADER structure, we don't plan to
1999 call PropertySheet again!*/
2000 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2004 /* get the number of device property sheets for the device */
2005 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2010 dap
->PropertySheetType
) &&
2011 nDriverPages
!= 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
2013 dap
->nDevPropSheets
+= nDriverPages
;
2020 /* include the driver page */
2021 if (dap
->HasDriverPage
)
2022 dap
->nDevPropSheets
++;
2024 /* include the details page */
2025 dap
->nDevPropSheets
++;
2027 /* add the device property sheets */
2028 if (dap
->nDevPropSheets
!= 0)
2030 dap
->DevPropSheets
= HeapAlloc(GetProcessHeap(),
2032 dap
->nDevPropSheets
* sizeof(HPROPSHEETPAGE
));
2033 if (dap
->DevPropSheets
!= NULL
)
2035 if (nDriverPages
!= 0)
2037 psh
.phpage
= dap
->DevPropSheets
;
2039 /* query the device property sheet pages to add */
2040 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2043 dap
->nDevPropSheets
,
2045 dap
->PropertySheetType
))
2047 /* add the property sheets */
2049 iPage
!= nDriverPages
;
2052 if (PropSheet_AddPage(hPropSheetDlg
,
2053 dap
->DevPropSheets
[iPage
]))
2059 dap
->FreeDevPropSheets
= TRUE
;
2063 /* cleanup, we were unable to get the device property sheets */
2064 iPage
= nDriverPages
;
2065 dap
->nDevPropSheets
-= nDriverPages
;
2072 /* add the driver page if necessary */
2073 if (dap
->HasDriverPage
)
2075 PROPSHEETPAGE pspDriver
= {0};
2076 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2077 pspDriver
.dwFlags
= PSP_DEFAULT
;
2078 pspDriver
.hInstance
= hDllInstance
;
2079 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDRIVER
);
2080 pspDriver
.pfnDlgProc
= AdvProcDriverDlgProc
;
2081 pspDriver
.lParam
= (LPARAM
)dap
;
2082 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2083 if (dap
->DevPropSheets
[iPage
] != NULL
)
2085 if (PropSheet_AddPage(hPropSheetDlg
,
2086 dap
->DevPropSheets
[iPage
]))
2093 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2094 dap
->DevPropSheets
[iPage
] = NULL
;
2101 PROPSHEETPAGE pspDetails
= {0};
2102 pspDetails
.dwSize
= sizeof(PROPSHEETPAGE
);
2103 pspDetails
.dwFlags
= PSP_DEFAULT
;
2104 pspDetails
.hInstance
= hDllInstance
;
2105 pspDetails
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDETAILS
);
2106 pspDetails
.pfnDlgProc
= AdvProcDetailsDlgProc
;
2107 pspDetails
.lParam
= (LPARAM
)dap
;
2108 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDetails
);
2109 if (dap
->DevPropSheets
[iPage
] != NULL
)
2111 if (PropSheet_AddPage(hPropSheetDlg
,
2112 dap
->DevPropSheets
[iPage
]))
2119 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2120 dap
->DevPropSheets
[iPage
] = NULL
;
2125 /* FIXME: Add the resources page */
2127 /* FIXME: Add the power page */
2130 dap
->nDevPropSheets
= 0;
2135 PropSheet_RecalcPageSizes(hPropSheetDlg
);
2138 /* finally, disable the apply button */
2139 PropSheet_UnChanged(hPropSheetDlg
,
2141 dap
->DeviceUsageChanged
= FALSE
;
2147 DlgParentSubWndProc(IN HWND hwnd
,
2152 PDEVADVPROP_INFO dap
;
2154 dap
= (PDEVADVPROP_INFO
)GetProp(hwnd
,
2155 L
"DevMgrDevChangeSub");
2158 if (uMsg
== WM_DEVICECHANGE
&& !IsWindowVisible(dap
->hWndGeneralPage
))
2160 SendMessage(dap
->hWndGeneralPage
,
2166 /* pass the message the the old window proc */
2167 return CallWindowProc(dap
->ParentOldWndProc
,
2175 /* this is not a good idea if the subclassed window was an ansi
2176 window, but we failed finding out the previous window proc
2177 so we can't use CallWindowProc. This should rarely - if ever -
2180 return DefWindowProc(hwnd
,
2190 AdvPropGeneralDlgProc(IN HWND hwndDlg
,
2195 PDEVADVPROP_INFO dap
;
2196 INT_PTR Ret
= FALSE
;
2198 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
2201 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
2207 switch (LOWORD(wParam
))
2211 if (HIWORD(wParam
) == CBN_SELCHANGE
)
2213 PropSheet_Changed(GetParent(hwndDlg
),
2215 dap
->DeviceUsageChanged
= TRUE
;
2220 case IDC_DEVPROBLEM
:
2224 /* display the device problem wizard */
2225 ShowDeviceProblemWizard(hwndDlg
,
2227 &dap
->DeviceInfoData
,
2238 NMHDR
*hdr
= (NMHDR
*)lParam
;
2242 ApplyGeneralSettings(hwndDlg
,
2251 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2256 dap
->hWndGeneralPage
= hwndDlg
;
2258 SetWindowLongPtr(hwndDlg
,
2262 /* subclass the parent window to always receive
2263 WM_DEVICECHANGE messages */
2264 hWndParent
= GetParent(hwndDlg
);
2265 if (hWndParent
!= NULL
)
2267 /* subclass the parent window. This is not safe
2268 if the parent window belongs to another thread! */
2269 dap
->ParentOldWndProc
= (WNDPROC
)SetWindowLongPtr(hWndParent
,
2271 (LONG_PTR
)DlgParentSubWndProc
);
2273 if (dap
->ParentOldWndProc
!= NULL
&&
2275 L
"DevMgrDevChangeSub",
2278 dap
->hWndParent
= hWndParent
;
2282 /* do not call UpdateDevInfo directly in here because it modifies
2283 the pages of the property sheet! */
2284 PostMessage(hwndDlg
,
2293 case WM_DEVICECHANGE
:
2295 /* FIXME - don't call UpdateDevInfo for all events */
2296 UpdateDevInfo(hwndDlg
,
2305 UpdateDevInfo(hwndDlg
,
2308 dap
->PageInitialized
= TRUE
;
2314 /* restore the old window proc of the subclassed parent window */
2315 if (dap
->hWndParent
!= NULL
&& dap
->ParentOldWndProc
!= NULL
)
2317 if (SetWindowLongPtr(dap
->hWndParent
,
2319 (LONG_PTR
)dap
->ParentOldWndProc
) == (LONG_PTR
)DlgParentSubWndProc
)
2321 RemoveProp(dap
->hWndParent
,
2322 L
"DevMgrDevChangeSub");
2335 DisplayDeviceAdvancedProperties(IN HWND hWndParent
,
2336 IN LPCWSTR lpDeviceID OPTIONAL
,
2337 IN HDEVINFO DeviceInfoSet
,
2338 IN PSP_DEVINFO_DATA DeviceInfoData
,
2339 IN HINSTANCE hComCtl32
,
2340 IN LPCWSTR lpMachineName
,
2343 PROPSHEETHEADER psh
= {0};
2344 PROPSHEETPAGE pspGeneral
= {0};
2345 PPROPERTYSHEETW pPropertySheetW
;
2346 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
2347 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
2348 PDEVADVPROP_INFO DevAdvPropInfo
;
2349 HMACHINE hMachine
= NULL
;
2350 DWORD DevIdSize
= 0;
2353 /* we don't want to statically link against comctl32, so find the
2354 functions we need dynamically */
2356 (PPROPERTYSHEETW
)GetProcAddress(hComCtl32
,
2358 pCreatePropertySheetPageW
=
2359 (PCREATEPROPERTYSHEETPAGEW
)GetProcAddress(hComCtl32
,
2360 "CreatePropertySheetPageW");
2361 pDestroyPropertySheetPage
=
2362 (PDESTROYPROPERTYSHEETPAGE
)GetProcAddress(hComCtl32
,
2363 "DestroyPropertySheetPage");
2364 if (pPropertySheetW
== NULL
||
2365 pCreatePropertySheetPageW
== NULL
||
2366 pDestroyPropertySheetPage
== NULL
)
2371 if (lpDeviceID
== NULL
)
2373 /* find out how much size is needed for the device id */
2374 if (SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2380 DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n");
2384 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
2391 DevIdSize
= (DWORD
)wcslen(lpDeviceID
) + 1;
2394 if (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0')
2396 CONFIGRET cr
= CM_Connect_Machine(lpMachineName
,
2398 if (cr
!= CR_SUCCESS
)
2404 /* create the internal structure associated with the "General",
2405 "Driver", ... pages */
2406 DevAdvPropInfo
= HeapAlloc(GetProcessHeap(),
2408 FIELD_OFFSET(DEVADVPROP_INFO
,
2410 (DevIdSize
* sizeof(WCHAR
)));
2411 if (DevAdvPropInfo
== NULL
)
2413 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2417 if (lpDeviceID
== NULL
)
2419 /* read the device instance id */
2420 if (!SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2422 DevAdvPropInfo
->szDeviceID
,
2431 /* copy the device instance id supplied by the caller */
2432 wcscpy(DevAdvPropInfo
->szDeviceID
,
2436 DevAdvPropInfo
->DeviceInfoSet
= DeviceInfoSet
;
2437 DevAdvPropInfo
->DeviceInfoData
= *DeviceInfoData
;
2438 DevAdvPropInfo
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
2439 DevAdvPropInfo
->CurrentDeviceInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2441 DevAdvPropInfo
->ShowRemotePages
= (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0');
2442 DevAdvPropInfo
->hMachine
= hMachine
;
2443 DevAdvPropInfo
->lpMachineName
= lpMachineName
;
2444 DevAdvPropInfo
->szDevName
[0] = L
'\0';
2445 DevAdvPropInfo
->hComCtl32
= hComCtl32
;
2446 DevAdvPropInfo
->pCreatePropertySheetPageW
= pCreatePropertySheetPageW
;
2447 DevAdvPropInfo
->pDestroyPropertySheetPage
= pDestroyPropertySheetPage
;
2449 DevAdvPropInfo
->IsAdmin
= IsUserAdmin();
2450 DevAdvPropInfo
->DoDefaultDevAction
= ((dwFlags
& DPF_DEVICE_STATUS_ACTION
) != 0);
2452 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2453 psh
.dwFlags
= PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
2454 psh
.hwndParent
= hWndParent
;
2455 psh
.pszCaption
= DevAdvPropInfo
->szDevName
;
2457 DevAdvPropInfo
->PropertySheetType
= DevAdvPropInfo
->ShowRemotePages
?
2458 DIGCDP_FLAG_REMOTE_ADVANCED
:
2459 DIGCDP_FLAG_ADVANCED
;
2461 psh
.phpage
= HeapAlloc(GetProcessHeap(),
2463 1 * sizeof(HPROPSHEETPAGE
));
2464 if (psh
.phpage
== NULL
)
2469 /* add the "General" property sheet */
2470 pspGeneral
.dwSize
= sizeof(PROPSHEETPAGE
);
2471 pspGeneral
.dwFlags
= PSP_DEFAULT
;
2472 pspGeneral
.hInstance
= hDllInstance
;
2473 pspGeneral
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEGENERAL
);
2474 pspGeneral
.pfnDlgProc
= AdvPropGeneralDlgProc
;
2475 pspGeneral
.lParam
= (LPARAM
)DevAdvPropInfo
;
2476 psh
.phpage
[psh
.nPages
] = pCreatePropertySheetPageW(&pspGeneral
);
2477 if (psh
.phpage
[psh
.nPages
] != NULL
)
2482 DevAdvPropInfo
->nDevPropSheets
= psh
.nPages
;
2484 if (psh
.nPages
!= 0)
2486 Ret
= pPropertySheetW(&psh
);
2488 /* NOTE: no need to destroy the property sheets anymore! */
2495 /* in case of failure the property sheets must be destroyed */
2496 if (psh
.phpage
!= NULL
)
2502 if (psh
.phpage
[i
] != NULL
)
2504 pDestroyPropertySheetPage(psh
.phpage
[i
]);
2510 if (DevAdvPropInfo
!= NULL
)
2512 if (DevAdvPropInfo
->FreeDevPropSheets
)
2514 /* don't free the array if it's the one allocated in
2515 DisplayDeviceAdvancedProperties */
2516 HeapFree(GetProcessHeap(),
2518 DevAdvPropInfo
->DevPropSheets
);
2521 if (DevAdvPropInfo
->CloseDevInst
)
2523 /* close the device info set in case a new one was created */
2524 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->DeviceInfoSet
);
2527 if (DevAdvPropInfo
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
2529 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->CurrentDeviceInfoSet
);
2532 if (DevAdvPropInfo
->hDevIcon
!= NULL
)
2534 DestroyIcon(DevAdvPropInfo
->hDevIcon
);
2537 HeapFree(GetProcessHeap(),
2542 if (psh
.phpage
!= NULL
)
2544 HeapFree(GetProcessHeap(),
2549 if (hMachine
!= NULL
)
2551 CM_Disconnect_Machine(hMachine
);
2559 GetDeviceAndComputerName(LPWSTR lpString
,
2561 WCHAR szMachineName
[])
2565 szDeviceID
[0] = L
'\0';
2566 szMachineName
[0] = L
'\0';
2568 while (*lpString
!= L
'\0')
2570 if (*lpString
== L
'/')
2573 if(!_wcsnicmp(lpString
, L
"DeviceID", 8))
2576 if (*lpString
!= L
'\0')
2579 while ((*lpString
!= L
' ') &&
2580 (*lpString
!= L
'\0') &&
2581 (i
<= MAX_DEVICE_ID_LEN
))
2583 szDeviceID
[i
++] = *lpString
++;
2585 szDeviceID
[i
] = L
'\0';
2589 else if (!_wcsnicmp(lpString
, L
"MachineName", 11))
2592 if (*lpString
!= L
'\0')
2595 while ((*lpString
!= L
' ') &&
2596 (*lpString
!= L
'\0') &&
2597 (i
<= MAX_COMPUTERNAME_LENGTH
))
2599 szMachineName
[i
++] = *lpString
++;
2601 szMachineName
[i
] = L
'\0';
2604 /* knock the pointer back one and let the next
2605 * pointer deal with incrementing, otherwise we
2606 * go past the end of the string */
2616 /***************************************************************************
2618 * DeviceAdvancedPropertiesW
2621 * Invokes the device properties dialog, this version may add some property pages
2625 * hWndParent: Handle to the parent window
2626 * lpMachineName: Machine Name, NULL is the local machine
2627 * lpDeviceID: Specifies the device whose properties are to be shown
2630 * Always returns -1, a call to GetLastError returns 0 if successful
2636 DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL
,
2637 IN LPCWSTR lpMachineName OPTIONAL
,
2638 IN LPCWSTR lpDeviceID
)
2641 SP_DEVINFO_DATA DevInfoData
;
2642 HINSTANCE hComCtl32
;
2645 if (lpDeviceID
== NULL
)
2647 SetLastError(ERROR_INVALID_PARAMETER
);
2651 /* dynamically load comctl32 */
2652 hComCtl32
= LoadAndInitComctl32();
2653 if (hComCtl32
!= NULL
)
2655 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2659 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2661 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2662 if (SetupDiOpenDeviceInfo(hDevInfo
,
2668 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2677 SetupDiDestroyDeviceInfoList(hDevInfo
);
2680 FreeLibrary(hComCtl32
);
2687 /***************************************************************************
2689 * DeviceAdvancedPropertiesA
2692 * Invokes the device properties dialog, this version may add some property pages
2696 * hWndParent: Handle to the parent window
2697 * lpMachineName: Machine Name, NULL is the local machine
2698 * lpDeviceID: Specifies the device whose properties are to be shown
2701 * Always returns -1, a call to GetLastError returns 0 if successful
2707 DeviceAdvancedPropertiesA(IN HWND hWndParent OPTIONAL
,
2708 IN LPCSTR lpMachineName OPTIONAL
,
2709 IN LPCSTR lpDeviceID
)
2711 LPWSTR lpMachineNameW
= NULL
;
2712 LPWSTR lpDeviceIDW
= NULL
;
2715 if (lpMachineName
!= NULL
)
2717 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2723 if (lpDeviceID
!= NULL
)
2725 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2732 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
2737 if (lpMachineNameW
!= NULL
)
2739 HeapFree(GetProcessHeap(),
2743 if (lpDeviceIDW
!= NULL
)
2745 HeapFree(GetProcessHeap(),
2754 /***************************************************************************
2756 * DevicePropertiesExA
2759 * Invokes the extended device properties dialog
2762 * hWndParent: Handle to the parent window
2763 * lpMachineName: Machine Name, NULL is the local machine
2764 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2765 * bShowDevMgr is nonzero
2766 * dwFlags: This parameter can be a combination of the following flags:
2767 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2768 * the default device status action button
2769 * to be clicked (Troubleshoot, Enable
2771 * bShowDevMgr: If non-zero it displays the device manager instead of
2772 * the advanced device property dialog
2775 * 1: if bShowDevMgr is non-zero and no error occured
2776 * -1: a call to GetLastError returns 0 if successful
2782 DevicePropertiesExA(IN HWND hWndParent OPTIONAL
,
2783 IN LPCSTR lpMachineName OPTIONAL
,
2784 IN LPCSTR lpDeviceID OPTIONAL
,
2785 IN DWORD dwFlags OPTIONAL
,
2786 IN BOOL bShowDevMgr
)
2788 LPWSTR lpMachineNameW
= NULL
;
2789 LPWSTR lpDeviceIDW
= NULL
;
2792 if (lpMachineName
!= NULL
)
2794 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2800 if (lpDeviceID
!= NULL
)
2802 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2809 Ret
= DevicePropertiesExW(hWndParent
,
2816 if (lpMachineNameW
!= NULL
)
2818 HeapFree(GetProcessHeap(),
2822 if (lpDeviceIDW
!= NULL
)
2824 HeapFree(GetProcessHeap(),
2833 /***************************************************************************
2835 * DevicePropertiesExW
2838 * Invokes the extended device properties dialog
2841 * hWndParent: Handle to the parent window
2842 * lpMachineName: Machine Name, NULL is the local machine
2843 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2844 * bShowDevMgr is nonzero
2845 * dwFlags: This parameter can be a combination of the following flags:
2846 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2847 * the default device status action button
2848 * to be clicked (Troubleshoot, Enable
2850 * bShowDevMgr: If non-zero it displays the device manager instead of
2851 * the advanced device property dialog
2854 * 1: if bShowDevMgr is non-zero and no error occured
2855 * -1: a call to GetLastError returns 0 if successful
2861 DevicePropertiesExW(IN HWND hWndParent OPTIONAL
,
2862 IN LPCWSTR lpMachineName OPTIONAL
,
2863 IN LPCWSTR lpDeviceID OPTIONAL
,
2864 IN DWORD dwFlags OPTIONAL
,
2865 IN BOOL bShowDevMgr
)
2869 if (dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
))
2871 DPRINT1("DevPropertiesExW: Invalid flags: 0x%x\n",
2872 dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
));
2873 SetLastError(ERROR_INVALID_FLAGS
);
2879 DPRINT("DevPropertiesExW doesn't support bShowDevMgr!\n");
2880 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2885 SP_DEVINFO_DATA DevInfoData
;
2886 HINSTANCE hComCtl32
;
2888 if (lpDeviceID
== NULL
)
2890 SetLastError(ERROR_INVALID_PARAMETER
);
2894 /* dynamically load comctl32 */
2895 hComCtl32
= LoadAndInitComctl32();
2896 if (hComCtl32
!= NULL
)
2898 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2902 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2904 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2905 if (SetupDiOpenDeviceInfo(hDevInfo
,
2911 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2920 SetupDiDestroyDeviceInfoList(hDevInfo
);
2923 FreeLibrary(hComCtl32
);
2931 /***************************************************************************
2936 * Invokes the device properties dialog directly
2939 * hWndParent: Handle to the parent window
2940 * lpMachineName: Machine Name, NULL is the local machine
2941 * lpDeviceID: Specifies the device whose properties are to be shown
2942 * bShowDevMgr: If non-zero it displays the device manager instead of
2943 * the device property dialog
2946 * >=0: if no errors occured
2947 * -1: if errors occured
2955 DevicePropertiesA(HWND hWndParent
,
2956 LPCSTR lpMachineName
,
2960 return DevicePropertiesExA(hWndParent
,
2968 /***************************************************************************
2973 * Invokes the device properties dialog directly
2976 * hWndParent: Handle to the parent window
2977 * lpMachineName: Machine Name, NULL is the local machine
2978 * lpDeviceID: Specifies the device whose properties are to be shown
2979 * bShowDevMgr: If non-zero it displays the device manager instead of
2980 * the device property dialog
2983 * >=0: if no errors occured
2984 * -1: if errors occured
2992 DevicePropertiesW(HWND hWndParent
,
2993 LPCWSTR lpMachineName
,
2997 return DevicePropertiesExW(hWndParent
,
3005 /***************************************************************************
3007 * DeviceProperties_RunDLLA
3010 * Invokes the device properties dialog
3013 * hWndParent: Handle to the parent window
3014 * hInst: Handle to the application instance
3015 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3017 * nCmdShow: Specifies how the window should be shown
3024 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3025 * (/MachineName is optional). This function only parses this string and eventually
3026 * calls DeviceProperties().
3032 DeviceProperties_RunDLLA(HWND hWndParent
,
3037 LPWSTR lpDeviceCmdW
= NULL
;
3039 if (lpDeviceCmd
!= NULL
)
3041 if ((lpDeviceCmdW
= ConvertMultiByteToUnicode(lpDeviceCmd
,
3044 DeviceProperties_RunDLLW(hWndParent
,
3051 if (lpDeviceCmdW
!= NULL
)
3053 HeapFree(GetProcessHeap(),
3060 /***************************************************************************
3062 * DeviceProperties_RunDLLW
3065 * Invokes the device properties dialog
3068 * hWndParent: Handle to the parent window
3069 * hInst: Handle to the application instance
3070 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3072 * nCmdShow: Specifies how the window should be shown
3079 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3080 * (/MachineName is optional). This function only parses this string and eventually
3081 * calls DeviceProperties().
3087 DeviceProperties_RunDLLW(HWND hWndParent
,
3089 LPCWSTR lpDeviceCmd
,
3092 WCHAR szDeviceID
[MAX_DEVICE_ID_LEN
+1];
3093 WCHAR szMachineName
[MAX_COMPUTERNAME_LENGTH
+1];
3094 LPWSTR lpString
= (LPWSTR
)lpDeviceCmd
;
3096 if (!GetDeviceAndComputerName(lpString
,
3100 DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID
, szMachineName
);
3104 DevicePropertiesW(hWndParent
,