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 PSP_DEVINFO_DATA DeviceInfoData
;
964 DWORD dwSize
= 256 * sizeof(WCHAR
);
966 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
968 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
972 DeviceInfoData
= &dap
->DeviceInfoData
;
975 CM_Get_DevNode_Registry_Property_ExW(DeviceInfoData
->DevInst
,
976 CM_DRP_ENUMERATOR_NAME
,
983 SetListViewText(hwndListView
, 0, szBuffer
);
988 DisplayCsFlags(IN PDEVADVPROP_INFO dap
,
989 IN HWND hwndListView
)
994 CM_Get_HW_Prof_Flags_Ex(dap
->szDevName
,
995 0, /* current hardware profile */
1001 if (dwValue
& CSCONFIGFLAG_DISABLED
)
1002 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DISABLED");
1004 if (dwValue
& CSCONFIGFLAG_DO_NOT_CREATE
)
1005 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_CREATE");
1007 if (dwValue
& CSCONFIGFLAG_DO_NOT_START
)
1008 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_START");
1013 DisplayMatchingDeviceId(IN PDEVADVPROP_INFO dap
,
1014 IN HWND hwndListView
)
1016 HDEVINFO DeviceInfoSet
;
1017 PSP_DEVINFO_DATA DeviceInfoData
;
1018 WCHAR szBuffer
[256];
1023 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1025 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1026 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1030 DeviceInfoSet
= dap
->DeviceInfoSet
;
1031 DeviceInfoData
= &dap
->DeviceInfoData
;
1034 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1040 if (hKey
!= INVALID_HANDLE_VALUE
)
1042 dwSize
= 256 * sizeof(WCHAR
);
1043 if (RegQueryValueEx(hKey
,
1044 L
"MatchingDeviceId",
1048 &dwSize
) == ERROR_SUCCESS
)
1050 SetListViewText(hwndListView
, 0, szBuffer
);
1059 DisplayDeviceCoinstallers(IN PDEVADVPROP_INFO dap
,
1060 IN HWND hwndListView
)
1062 HDEVINFO DeviceInfoSet
;
1063 PSP_DEVINFO_DATA DeviceInfoData
;
1072 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1074 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1075 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1079 DeviceInfoSet
= dap
->DeviceInfoSet
;
1080 DeviceInfoData
= &dap
->DeviceInfoData
;
1083 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1089 if (hKey
!= INVALID_HANDLE_VALUE
)
1092 if (RegQueryValueEx(hKey
,
1097 &dwSize
) == ERROR_SUCCESS
&&
1101 lpBuffer
= HeapAlloc(GetProcessHeap(),
1105 RegQueryValueEx(hKey
,
1112 lpStr
= (LPWSTR
)lpBuffer
;
1116 len
= wcslen(lpStr
) + 1;
1118 SetListViewText(hwndListView
, index
, lpStr
);
1124 HeapFree(GetProcessHeap(),
1135 DisplayClassProperties(IN PDEVADVPROP_INFO dap
,
1136 IN HWND hwndListView
,
1137 IN LPWSTR lpProperty
)
1139 HDEVINFO DeviceInfoSet
;
1140 PSP_DEVINFO_DATA DeviceInfoData
;
1141 WCHAR szClassGuid
[45];
1151 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1153 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1154 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1158 DeviceInfoSet
= dap
->DeviceInfoSet
;
1159 DeviceInfoData
= &dap
->DeviceInfoData
;
1162 dwSize
= 45 * sizeof(WCHAR
);
1163 if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
1167 (LPBYTE
)szClassGuid
,
1172 pSetupGuidFromString(szClassGuid
,
1175 hKey
= SetupDiOpenClassRegKey(&ClassGuid
,
1177 if (hKey
!= INVALID_HANDLE_VALUE
)
1180 if (RegQueryValueEx(hKey
,
1185 &dwSize
) == ERROR_SUCCESS
&&
1188 lpBuffer
= HeapAlloc(GetProcessHeap(),
1192 RegQueryValueEx(hKey
,
1199 if (dwType
== REG_SZ
)
1201 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
1203 else if (dwType
== REG_MULTI_SZ
)
1205 lpStr
= (LPWSTR
)lpBuffer
;
1209 len
= wcslen(lpStr
) + 1;
1211 SetListViewText(hwndListView
, index
, lpStr
);
1218 HeapFree(GetProcessHeap(),
1229 DisplayDeviceProperties(IN PDEVADVPROP_INFO dap
,
1230 IN HWND hwndComboBox
,
1231 IN HWND hwndListView
)
1235 Index
= (INT
)SendMessage(hwndComboBox
,
1239 if (Index
== CB_ERR
)
1242 (void)ListView_DeleteAllItems(hwndListView
);
1247 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
1250 case 1: /* Hardware ID */
1251 DisplayDevicePropertyText(dap
,
1256 case 2: /* Compatible IDs */
1257 DisplayDevicePropertyText(dap
,
1259 SPDRP_COMPATIBLEIDS
);
1262 case 3: /* Matching ID */
1263 DisplayMatchingDeviceId(dap
,
1267 case 4: /* Service */
1268 DisplayDevicePropertyText(dap
,
1273 case 5: /* Enumerator */
1274 DisplayDevNodeEnumerator(dap
,
1278 case 6: /* Capabilities */
1279 DisplayDevicePropertyText(dap
,
1281 SPDRP_CAPABILITIES
);
1284 case 7: /* Devnode Flags */
1285 DisplayDevNodeFlags(dap
,
1289 case 8: /* Config Flags */
1290 DisplayDevicePropertyText(dap
,
1295 case 9: /* CSConfig Flags */
1301 case 10: /* Ejection relation */
1304 case 11: /* Removal relations */
1307 case 12: /* Bus relation */
1311 case 13: /* Device Upper Filters */
1312 DisplayDevicePropertyText(dap
,
1314 SPDRP_UPPERFILTERS
);
1317 case 14: /* Device Lower Filters */
1318 DisplayDevicePropertyText(dap
,
1320 SPDRP_LOWERFILTERS
);
1323 case 15: /* Class Upper Filters */
1324 DisplayClassProperties(dap
,
1329 case 16: /* Class Lower Filters */
1330 DisplayClassProperties(dap
,
1335 case 17: /* Class Installer */
1336 DisplayClassProperties(dap
,
1342 case 18: /* Class Coinstaller */
1346 case 19: /* Device Coinstaller */
1347 DisplayDeviceCoinstallers(dap
,
1352 case 20: /* Firmware Revision */
1355 case 21: /* Current Power State */
1358 case 20: /* Power Capabilities */
1361 case 21: /* Power State Mappings */
1366 SetListViewText(hwndListView
, 0, L
"<Not implemented yet>");
1374 AdvProcDetailsDlgProc(IN HWND hwndDlg
,
1379 PDEVADVPROP_INFO dap
;
1380 INT_PTR Ret
= FALSE
;
1382 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
1385 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
1391 switch (LOWORD(wParam
))
1393 case IDC_DETAILSPROPNAME
:
1394 if (HIWORD(wParam
) == CBN_SELCHANGE
)
1396 DisplayDeviceProperties(dap
,
1397 GetDlgItem(hwndDlg
, IDC_DETAILSPROPNAME
),
1398 GetDlgItem(hwndDlg
, IDC_DETAILSPROPVALUE
));
1407 NMHDR
*hdr
= (NMHDR
*)lParam
;
1418 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1421 SetWindowLongPtr(hwndDlg
,
1425 UpdateDetailsDlg(hwndDlg
,
1439 InitDevUsageActions(IN HWND hwndDlg
,
1441 IN PDEVADVPROP_INFO dap
)
1452 i
!= sizeof(Actions
) / sizeof(Actions
[0]);
1455 /* fill in the device usage combo box */
1456 if (LoadString(hDllInstance
,
1459 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1461 Index
= (INT
)SendMessage(hComboBox
,
1464 (LPARAM
)dap
->szTemp
);
1465 if (Index
!= CB_ERR
)
1467 SendMessage(hComboBox
,
1470 (LPARAM
)Actions
[i
]);
1474 case IDS_ENABLEDEVICE
:
1475 if (dap
->DeviceStarted
)
1477 SendMessage(hComboBox
,
1484 case IDS_DISABLEDEVICE
:
1485 if (!dap
->DeviceStarted
)
1487 SendMessage(hComboBox
,
1504 GetSelectedUsageAction(IN HWND hComboBox
)
1509 Index
= (INT
)SendMessage(hComboBox
,
1513 if (Index
!= CB_ERR
)
1515 INT iRet
= (INT
) SendMessage(hComboBox
,
1530 ApplyGeneralSettings(IN HWND hwndDlg
,
1531 IN PDEVADVPROP_INFO dap
)
1535 if (dap
->DeviceUsageChanged
&& dap
->IsAdmin
&& dap
->CanDisable
)
1537 UINT SelectedUsageAction
;
1538 BOOL NeedReboot
= FALSE
;
1540 SelectedUsageAction
= GetSelectedUsageAction(GetDlgItem(hwndDlg
,
1542 switch (SelectedUsageAction
)
1544 case IDS_ENABLEDEVICE
:
1545 if (!dap
->DeviceStarted
)
1547 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1548 &dap
->DeviceInfoData
,
1555 case IDS_DISABLEDEVICE
:
1556 if (dap
->DeviceStarted
)
1558 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1559 &dap
->DeviceInfoData
,
1574 /* make PropertySheet() return PSM_REBOOTSYSTEM */
1575 PropSheet_RebootSystem(hwndDlg
);
1580 /* FIXME - display an error message */
1581 DPRINT1("Failed to enable/disable device! LastError: %d\n",
1586 Ret
= !dap
->DeviceUsageChanged
;
1588 /* disable the apply button */
1589 PropSheet_UnChanged(GetParent(hwndDlg
),
1591 dap
->DeviceUsageChanged
= FALSE
;
1597 UpdateDevInfo(IN HWND hwndDlg
,
1598 IN PDEVADVPROP_INFO dap
,
1601 HWND hDevUsage
, hPropSheetDlg
, hDevProbBtn
;
1603 ULONG Status
, ProblemNumber
;
1604 SP_DEVINSTALL_PARAMS_W InstallParams
;
1605 UINT TroubleShootStrId
= IDS_TROUBLESHOOTDEV
;
1606 BOOL bFlag
, bDevActionAvailable
= TRUE
;
1607 BOOL bDrvInstalled
= FALSE
;
1609 HDEVINFO DeviceInfoSet
= NULL
;
1610 PSP_DEVINFO_DATA DeviceInfoData
= NULL
;
1611 PROPSHEETHEADER psh
;
1612 DWORD nDriverPages
= 0;
1613 BOOL RecalcPages
= FALSE
;
1615 hPropSheetDlg
= GetParent(hwndDlg
);
1617 if (dap
->PageInitialized
)
1619 /* switch to the General page */
1620 PropSheet_SetCurSelByID(hPropSheetDlg
,
1623 /* remove and destroy the existing device property sheet pages */
1624 if (dap
->DevPropSheets
!= NULL
)
1627 iPage
!= dap
->nDevPropSheets
;
1630 if (dap
->DevPropSheets
[iPage
] != NULL
)
1632 PropSheet_RemovePage(hPropSheetDlg
,
1634 dap
->DevPropSheets
[iPage
]);
1643 if (dap
->FreeDevPropSheets
)
1645 /* don't free the array if it's the one allocated in
1646 DisplayDeviceAdvancedProperties */
1647 HeapFree(GetProcessHeap(),
1649 dap
->DevPropSheets
);
1651 dap
->FreeDevPropSheets
= FALSE
;
1654 dap
->DevPropSheets
= NULL
;
1655 dap
->nDevPropSheets
= 0;
1659 /* create a new device info set and re-open the device */
1660 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1662 SetupDiDestroyDeviceInfoList(dap
->CurrentDeviceInfoSet
);
1665 dap
->ParentDevInst
= 0;
1666 dap
->CurrentDeviceInfoSet
= SetupDiCreateDeviceInfoListEx(NULL
,
1670 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1672 if (SetupDiOpenDeviceInfo(dap
->CurrentDeviceInfoSet
,
1676 &dap
->CurrentDeviceInfoData
))
1678 if (dap
->CloseDevInst
)
1680 SetupDiDestroyDeviceInfoList(dap
->DeviceInfoSet
);
1683 dap
->CloseDevInst
= TRUE
;
1684 dap
->DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1685 dap
->DeviceInfoData
= dap
->CurrentDeviceInfoData
;
1686 dap
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
1694 /* get the parent node from the initial devinst */
1695 CM_Get_Parent_Ex(&dap
->ParentDevInst
,
1696 dap
->DeviceInfoData
.DevInst
,
1701 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1703 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1704 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1708 DeviceInfoSet
= dap
->DeviceInfoSet
;
1709 DeviceInfoData
= &dap
->DeviceInfoData
;
1714 DeviceInfoSet
= dap
->DeviceInfoSet
;
1715 DeviceInfoData
= &dap
->DeviceInfoData
;
1718 dap
->HasDriverPage
= FALSE
;
1719 dap
->HasResourcePage
= FALSE
;
1720 dap
->HasPowerPage
= FALSE
;
1721 if (IsDriverInstalled(DeviceInfoData
->DevInst
,
1726 if (SetupDiCallClassInstaller((dap
->ShowRemotePages
?
1727 DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
:
1728 DIF_ADDPROPERTYPAGE_ADVANCED
),
1732 /* get install params */
1733 InstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
1734 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet
,
1738 /* zero the flags */
1739 InstallParams
.Flags
= 0;
1742 dap
->HasDriverPage
= !(InstallParams
.Flags
& DI_DRIVERPAGE_ADDED
);
1743 dap
->HasResourcePage
= !(InstallParams
.Flags
& DI_RESOURCEPAGE_ADDED
);
1744 dap
->HasPowerPage
= !(InstallParams
.Flags
& DI_FLAGSEX_POWERPAGE_ADDED
);
1748 /* get the device icon */
1749 if (dap
->hDevIcon
!= NULL
)
1751 DestroyIcon(dap
->hDevIcon
);
1752 dap
->hDevIcon
= NULL
;
1754 if (!SetupDiLoadClassIcon(&DeviceInfoData
->ClassGuid
,
1758 dap
->hDevIcon
= NULL
;
1761 /* get the device name */
1762 if (GetDeviceDescriptionString(DeviceInfoSet
,
1765 sizeof(dap
->szDevName
) / sizeof(dap
->szDevName
[0])))
1767 PropSheet_SetTitle(hPropSheetDlg
,
1772 /* set the device image */
1773 SendDlgItemMessage(hwndDlg
,
1776 (WPARAM
)dap
->hDevIcon
,
1779 /* set the device name edit control text */
1780 SetDlgItemText(hwndDlg
,
1784 /* set the device type edit control text */
1785 if (GetDeviceTypeString(DeviceInfoData
,
1787 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1789 SetDlgItemText(hwndDlg
,
1794 /* set the device manufacturer edit control text */
1795 if (GetDeviceManufacturerString(DeviceInfoSet
,
1798 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1800 SetDlgItemText(hwndDlg
,
1801 IDC_DEVMANUFACTURER
,
1805 /* set the device location edit control text */
1806 if (GetDeviceLocationString(DeviceInfoSet
,
1810 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1812 SetDlgItemText(hwndDlg
,
1817 /* set the device status edit control text */
1818 if (GetDeviceStatusString(DeviceInfoData
->DevInst
,
1821 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1823 SetDlgItemText(hwndDlg
,
1828 /* set the device troubleshoot button text and disable it if necessary */
1829 hDevProbBtn
= GetDlgItem(hwndDlg
,
1831 cr
= CM_Get_DevNode_Status_Ex(&Status
,
1833 DeviceInfoData
->DevInst
,
1836 if (cr
== CR_SUCCESS
&& (Status
& DN_HAS_PROBLEM
))
1838 switch (ProblemNumber
)
1840 case CM_PROB_DEVLOADER_FAILED
:
1842 /* FIXME - only if it's not a root bus devloader,
1843 disable the button otherwise */
1844 TroubleShootStrId
= IDS_UPDATEDRV
;
1848 case CM_PROB_OUT_OF_MEMORY
:
1849 case CM_PROB_ENTRY_IS_WRONG_TYPE
:
1850 case CM_PROB_LACKED_ARBITRATOR
:
1851 case CM_PROB_FAILED_START
:
1853 case CM_PROB_UNKNOWN_RESOURCE
:
1855 TroubleShootStrId
= IDS_UPDATEDRV
;
1859 case CM_PROB_BOOT_CONFIG_CONFLICT
:
1860 case CM_PROB_NORMAL_CONFLICT
:
1861 case CM_PROB_REENUMERATION
:
1863 /* FIXME - Troubleshoot conflict */
1867 case CM_PROB_FAILED_FILTER
:
1868 case CM_PROB_REINSTALL
:
1869 case CM_PROB_FAILED_INSTALL
:
1871 TroubleShootStrId
= IDS_REINSTALLDRV
;
1875 case CM_PROB_DEVLOADER_NOT_FOUND
:
1878 1) if it's a missing system devloader:
1879 - disable the button (Reinstall Driver)
1880 2) if it's not a system devloader but still missing:
1882 3) if it's not a system devloader but the file can be found:
1884 4) if it's a missing or empty software key
1890 case CM_PROB_INVALID_DATA
:
1891 case CM_PROB_PARTIAL_LOG_CONF
:
1892 case CM_PROB_NO_VALID_LOG_CONF
:
1893 case CM_PROB_HARDWARE_DISABLED
:
1894 case CM_PROB_CANT_SHARE_IRQ
:
1895 case CM_PROB_TRANSLATION_FAILED
:
1896 case CM_PROB_SYSTEM_SHUTDOWN
:
1897 case CM_PROB_PHANTOM
:
1898 bDevActionAvailable
= FALSE
;
1901 case CM_PROB_NOT_VERIFIED
:
1902 case CM_PROB_DEVICE_NOT_THERE
:
1903 /* FIXME - search hardware */
1906 case CM_PROB_NEED_RESTART
:
1907 case CM_PROB_WILL_BE_REMOVED
:
1909 case CM_PROB_TOO_EARLY
:
1910 case CM_PROB_DISABLED_SERVICE
:
1911 TroubleShootStrId
= IDS_REBOOT
;
1914 case CM_PROB_REGISTRY
:
1915 /* FIXME - check registry? */
1918 case CM_PROB_DISABLED
:
1919 /* if device was disabled by the user: */
1920 TroubleShootStrId
= IDS_ENABLEDEV
;
1921 /* FIXME - otherwise disable button because the device was
1922 disabled by the system*/
1925 case CM_PROB_DEVLOADER_NOT_READY
:
1926 /* FIXME - if it's a graphics adapter:
1927 - if it's a a secondary adapter and the main adapter
1937 case CM_PROB_FAILED_ADD
:
1938 TroubleShootStrId
= IDS_PROPERTIES
;
1943 if (LoadString(hDllInstance
,
1946 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])) != 0)
1948 SetWindowText(hDevProbBtn
,
1951 EnableWindow(hDevProbBtn
,
1952 dap
->IsAdmin
&& bDevActionAvailable
);
1954 /* check if the device can be enabled/disabled */
1955 hDevUsage
= GetDlgItem(hwndDlg
,
1958 dap
->CanDisable
= FALSE
;
1959 dap
->DeviceStarted
= FALSE
;
1961 if (CanDisableDevice(DeviceInfoData
->DevInst
,
1965 dap
->CanDisable
= bFlag
;
1968 if (IsDeviceStarted(DeviceInfoData
->DevInst
,
1972 dap
->DeviceStarted
= bFlag
;
1975 /* enable/disable the device usage controls */
1976 EnableWindow(GetDlgItem(hwndDlg
,
1978 dap
->CanDisable
&& dap
->IsAdmin
);
1979 EnableWindow(hDevUsage
,
1980 dap
->CanDisable
&& dap
->IsAdmin
);
1982 /* clear the combobox */
1983 SendMessage(hDevUsage
,
1987 if (dap
->CanDisable
)
1989 InitDevUsageActions(hwndDlg
,
1994 /* find out how many new device property sheets to add.
1995 fake a PROPSHEETHEADER structure, we don't plan to
1996 call PropertySheet again!*/
1997 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2001 /* get the number of device property sheets for the device */
2002 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2007 dap
->PropertySheetType
) &&
2008 nDriverPages
!= 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
2010 dap
->nDevPropSheets
+= nDriverPages
;
2017 /* include the driver page */
2018 if (dap
->HasDriverPage
)
2019 dap
->nDevPropSheets
++;
2021 /* include the details page */
2022 dap
->nDevPropSheets
++;
2024 /* add the device property sheets */
2025 if (dap
->nDevPropSheets
!= 0)
2027 dap
->DevPropSheets
= HeapAlloc(GetProcessHeap(),
2029 dap
->nDevPropSheets
* sizeof(HPROPSHEETPAGE
));
2030 if (dap
->DevPropSheets
!= NULL
)
2032 if (nDriverPages
!= 0)
2034 psh
.phpage
= dap
->DevPropSheets
;
2036 /* query the device property sheet pages to add */
2037 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2040 dap
->nDevPropSheets
,
2042 dap
->PropertySheetType
))
2044 /* add the property sheets */
2046 iPage
!= nDriverPages
;
2049 if (PropSheet_AddPage(hPropSheetDlg
,
2050 dap
->DevPropSheets
[iPage
]))
2056 dap
->FreeDevPropSheets
= TRUE
;
2060 /* cleanup, we were unable to get the device property sheets */
2061 iPage
= nDriverPages
;
2062 dap
->nDevPropSheets
-= nDriverPages
;
2069 /* add the driver page if necessary */
2070 if (dap
->HasDriverPage
)
2072 PROPSHEETPAGE pspDriver
= {0};
2073 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2074 pspDriver
.dwFlags
= PSP_DEFAULT
;
2075 pspDriver
.hInstance
= hDllInstance
;
2076 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDRIVER
);
2077 pspDriver
.pfnDlgProc
= AdvProcDriverDlgProc
;
2078 pspDriver
.lParam
= (LPARAM
)dap
;
2079 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2080 if (dap
->DevPropSheets
[iPage
] != NULL
)
2082 if (PropSheet_AddPage(hPropSheetDlg
,
2083 dap
->DevPropSheets
[iPage
]))
2090 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2091 dap
->DevPropSheets
[iPage
] = NULL
;
2098 PROPSHEETPAGE pspDetails
= {0};
2099 pspDetails
.dwSize
= sizeof(PROPSHEETPAGE
);
2100 pspDetails
.dwFlags
= PSP_DEFAULT
;
2101 pspDetails
.hInstance
= hDllInstance
;
2102 pspDetails
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDETAILS
);
2103 pspDetails
.pfnDlgProc
= AdvProcDetailsDlgProc
;
2104 pspDetails
.lParam
= (LPARAM
)dap
;
2105 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDetails
);
2106 if (dap
->DevPropSheets
[iPage
] != NULL
)
2108 if (PropSheet_AddPage(hPropSheetDlg
,
2109 dap
->DevPropSheets
[iPage
]))
2116 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2117 dap
->DevPropSheets
[iPage
] = NULL
;
2122 /* FIXME: Add the resources page */
2124 /* FIXME: Add the power page */
2127 dap
->nDevPropSheets
= 0;
2132 PropSheet_RecalcPageSizes(hPropSheetDlg
);
2135 /* finally, disable the apply button */
2136 PropSheet_UnChanged(hPropSheetDlg
,
2138 dap
->DeviceUsageChanged
= FALSE
;
2144 DlgParentSubWndProc(IN HWND hwnd
,
2149 PDEVADVPROP_INFO dap
;
2151 dap
= (PDEVADVPROP_INFO
)GetProp(hwnd
,
2152 L
"DevMgrDevChangeSub");
2155 if (uMsg
== WM_DEVICECHANGE
&& !IsWindowVisible(dap
->hWndGeneralPage
))
2157 SendMessage(dap
->hWndGeneralPage
,
2163 /* pass the message the the old window proc */
2164 return CallWindowProc(dap
->ParentOldWndProc
,
2172 /* this is not a good idea if the subclassed window was an ansi
2173 window, but we failed finding out the previous window proc
2174 so we can't use CallWindowProc. This should rarely - if ever -
2177 return DefWindowProc(hwnd
,
2187 AdvPropGeneralDlgProc(IN HWND hwndDlg
,
2192 PDEVADVPROP_INFO dap
;
2193 INT_PTR Ret
= FALSE
;
2195 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
2198 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
2204 switch (LOWORD(wParam
))
2208 if (HIWORD(wParam
) == CBN_SELCHANGE
)
2210 PropSheet_Changed(GetParent(hwndDlg
),
2212 dap
->DeviceUsageChanged
= TRUE
;
2217 case IDC_DEVPROBLEM
:
2221 /* display the device problem wizard */
2222 ShowDeviceProblemWizard(hwndDlg
,
2224 &dap
->DeviceInfoData
,
2235 NMHDR
*hdr
= (NMHDR
*)lParam
;
2239 ApplyGeneralSettings(hwndDlg
,
2248 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2253 dap
->hWndGeneralPage
= hwndDlg
;
2255 SetWindowLongPtr(hwndDlg
,
2259 /* subclass the parent window to always receive
2260 WM_DEVICECHANGE messages */
2261 hWndParent
= GetParent(hwndDlg
);
2262 if (hWndParent
!= NULL
)
2264 /* subclass the parent window. This is not safe
2265 if the parent window belongs to another thread! */
2266 dap
->ParentOldWndProc
= (WNDPROC
)SetWindowLongPtr(hWndParent
,
2268 (LONG_PTR
)DlgParentSubWndProc
);
2270 if (dap
->ParentOldWndProc
!= NULL
&&
2272 L
"DevMgrDevChangeSub",
2275 dap
->hWndParent
= hWndParent
;
2279 /* do not call UpdateDevInfo directly in here because it modifies
2280 the pages of the property sheet! */
2281 PostMessage(hwndDlg
,
2290 case WM_DEVICECHANGE
:
2292 /* FIXME - don't call UpdateDevInfo for all events */
2293 UpdateDevInfo(hwndDlg
,
2302 UpdateDevInfo(hwndDlg
,
2305 dap
->PageInitialized
= TRUE
;
2311 /* restore the old window proc of the subclassed parent window */
2312 if (dap
->hWndParent
!= NULL
&& dap
->ParentOldWndProc
!= NULL
)
2314 if (SetWindowLongPtr(dap
->hWndParent
,
2316 (LONG_PTR
)dap
->ParentOldWndProc
) == (LONG_PTR
)DlgParentSubWndProc
)
2318 RemoveProp(dap
->hWndParent
,
2319 L
"DevMgrDevChangeSub");
2332 DisplayDeviceAdvancedProperties(IN HWND hWndParent
,
2333 IN LPCWSTR lpDeviceID OPTIONAL
,
2334 IN HDEVINFO DeviceInfoSet
,
2335 IN PSP_DEVINFO_DATA DeviceInfoData
,
2336 IN HINSTANCE hComCtl32
,
2337 IN LPCWSTR lpMachineName
,
2340 PROPSHEETHEADER psh
= {0};
2341 PROPSHEETPAGE pspGeneral
= {0};
2342 PPROPERTYSHEETW pPropertySheetW
;
2343 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
2344 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
2345 PDEVADVPROP_INFO DevAdvPropInfo
;
2346 HMACHINE hMachine
= NULL
;
2347 DWORD DevIdSize
= 0;
2350 /* we don't want to statically link against comctl32, so find the
2351 functions we need dynamically */
2353 (PPROPERTYSHEETW
)GetProcAddress(hComCtl32
,
2355 pCreatePropertySheetPageW
=
2356 (PCREATEPROPERTYSHEETPAGEW
)GetProcAddress(hComCtl32
,
2357 "CreatePropertySheetPageW");
2358 pDestroyPropertySheetPage
=
2359 (PDESTROYPROPERTYSHEETPAGE
)GetProcAddress(hComCtl32
,
2360 "DestroyPropertySheetPage");
2361 if (pPropertySheetW
== NULL
||
2362 pCreatePropertySheetPageW
== NULL
||
2363 pDestroyPropertySheetPage
== NULL
)
2368 if (lpDeviceID
== NULL
)
2370 /* find out how much size is needed for the device id */
2371 if (SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2377 DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n");
2381 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
2388 DevIdSize
= (DWORD
)wcslen(lpDeviceID
) + 1;
2391 if (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0')
2393 CONFIGRET cr
= CM_Connect_Machine(lpMachineName
,
2395 if (cr
!= CR_SUCCESS
)
2401 /* create the internal structure associated with the "General",
2402 "Driver", ... pages */
2403 DevAdvPropInfo
= HeapAlloc(GetProcessHeap(),
2405 FIELD_OFFSET(DEVADVPROP_INFO
,
2407 (DevIdSize
* sizeof(WCHAR
)));
2408 if (DevAdvPropInfo
== NULL
)
2410 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2414 if (lpDeviceID
== NULL
)
2416 /* read the device instance id */
2417 if (!SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2419 DevAdvPropInfo
->szDeviceID
,
2428 /* copy the device instance id supplied by the caller */
2429 wcscpy(DevAdvPropInfo
->szDeviceID
,
2433 DevAdvPropInfo
->DeviceInfoSet
= DeviceInfoSet
;
2434 DevAdvPropInfo
->DeviceInfoData
= *DeviceInfoData
;
2435 DevAdvPropInfo
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
2436 DevAdvPropInfo
->CurrentDeviceInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2438 DevAdvPropInfo
->ShowRemotePages
= (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0');
2439 DevAdvPropInfo
->hMachine
= hMachine
;
2440 DevAdvPropInfo
->lpMachineName
= lpMachineName
;
2441 DevAdvPropInfo
->szDevName
[0] = L
'\0';
2442 DevAdvPropInfo
->hComCtl32
= hComCtl32
;
2443 DevAdvPropInfo
->pCreatePropertySheetPageW
= pCreatePropertySheetPageW
;
2444 DevAdvPropInfo
->pDestroyPropertySheetPage
= pDestroyPropertySheetPage
;
2446 DevAdvPropInfo
->IsAdmin
= IsUserAdmin();
2447 DevAdvPropInfo
->DoDefaultDevAction
= ((dwFlags
& DPF_DEVICE_STATUS_ACTION
) != 0);
2449 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2450 psh
.dwFlags
= PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
2451 psh
.hwndParent
= hWndParent
;
2452 psh
.pszCaption
= DevAdvPropInfo
->szDevName
;
2454 DevAdvPropInfo
->PropertySheetType
= DevAdvPropInfo
->ShowRemotePages
?
2455 DIGCDP_FLAG_REMOTE_ADVANCED
:
2456 DIGCDP_FLAG_ADVANCED
;
2458 psh
.phpage
= HeapAlloc(GetProcessHeap(),
2460 1 * sizeof(HPROPSHEETPAGE
));
2461 if (psh
.phpage
== NULL
)
2466 /* add the "General" property sheet */
2467 pspGeneral
.dwSize
= sizeof(PROPSHEETPAGE
);
2468 pspGeneral
.dwFlags
= PSP_DEFAULT
;
2469 pspGeneral
.hInstance
= hDllInstance
;
2470 pspGeneral
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEGENERAL
);
2471 pspGeneral
.pfnDlgProc
= AdvPropGeneralDlgProc
;
2472 pspGeneral
.lParam
= (LPARAM
)DevAdvPropInfo
;
2473 psh
.phpage
[psh
.nPages
] = pCreatePropertySheetPageW(&pspGeneral
);
2474 if (psh
.phpage
[psh
.nPages
] != NULL
)
2479 DevAdvPropInfo
->nDevPropSheets
= psh
.nPages
;
2481 if (psh
.nPages
!= 0)
2483 Ret
= pPropertySheetW(&psh
);
2485 /* NOTE: no need to destroy the property sheets anymore! */
2492 /* in case of failure the property sheets must be destroyed */
2493 if (psh
.phpage
!= NULL
)
2499 if (psh
.phpage
[i
] != NULL
)
2501 pDestroyPropertySheetPage(psh
.phpage
[i
]);
2507 if (DevAdvPropInfo
!= NULL
)
2509 if (DevAdvPropInfo
->FreeDevPropSheets
)
2511 /* don't free the array if it's the one allocated in
2512 DisplayDeviceAdvancedProperties */
2513 HeapFree(GetProcessHeap(),
2515 DevAdvPropInfo
->DevPropSheets
);
2518 if (DevAdvPropInfo
->CloseDevInst
)
2520 /* close the device info set in case a new one was created */
2521 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->DeviceInfoSet
);
2524 if (DevAdvPropInfo
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
2526 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->CurrentDeviceInfoSet
);
2529 if (DevAdvPropInfo
->hDevIcon
!= NULL
)
2531 DestroyIcon(DevAdvPropInfo
->hDevIcon
);
2534 HeapFree(GetProcessHeap(),
2539 if (psh
.phpage
!= NULL
)
2541 HeapFree(GetProcessHeap(),
2546 if (hMachine
!= NULL
)
2548 CM_Disconnect_Machine(hMachine
);
2556 GetDeviceAndComputerName(LPWSTR lpString
,
2558 WCHAR szMachineName
[])
2562 szDeviceID
[0] = L
'\0';
2563 szMachineName
[0] = L
'\0';
2565 while (*lpString
!= L
'\0')
2567 if (*lpString
== L
'/')
2570 if(!_wcsnicmp(lpString
, L
"DeviceID", 8))
2573 if (*lpString
!= L
'\0')
2576 while ((*lpString
!= L
' ') &&
2577 (*lpString
!= L
'\0') &&
2578 (i
<= MAX_DEVICE_ID_LEN
))
2580 szDeviceID
[i
++] = *lpString
++;
2582 szDeviceID
[i
] = L
'\0';
2586 else if (!_wcsnicmp(lpString
, L
"MachineName", 11))
2589 if (*lpString
!= L
'\0')
2592 while ((*lpString
!= L
' ') &&
2593 (*lpString
!= L
'\0') &&
2594 (i
<= MAX_COMPUTERNAME_LENGTH
))
2596 szMachineName
[i
++] = *lpString
++;
2598 szMachineName
[i
] = L
'\0';
2601 /* knock the pointer back one and let the next
2602 * pointer deal with incrementing, otherwise we
2603 * go past the end of the string */
2613 /***************************************************************************
2615 * DeviceAdvancedPropertiesW
2618 * Invokes the device properties dialog, this version may add some property pages
2622 * hWndParent: Handle to the parent window
2623 * lpMachineName: Machine Name, NULL is the local machine
2624 * lpDeviceID: Specifies the device whose properties are to be shown
2627 * Always returns -1, a call to GetLastError returns 0 if successful
2633 DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL
,
2634 IN LPCWSTR lpMachineName OPTIONAL
,
2635 IN LPCWSTR lpDeviceID
)
2638 SP_DEVINFO_DATA DevInfoData
;
2639 HINSTANCE hComCtl32
;
2642 if (lpDeviceID
== NULL
)
2644 SetLastError(ERROR_INVALID_PARAMETER
);
2648 /* dynamically load comctl32 */
2649 hComCtl32
= LoadAndInitComctl32();
2650 if (hComCtl32
!= NULL
)
2652 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2656 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2658 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2659 if (SetupDiOpenDeviceInfo(hDevInfo
,
2665 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2674 SetupDiDestroyDeviceInfoList(hDevInfo
);
2677 FreeLibrary(hComCtl32
);
2684 /***************************************************************************
2686 * DeviceAdvancedPropertiesA
2689 * Invokes the device properties dialog, this version may add some property pages
2693 * hWndParent: Handle to the parent window
2694 * lpMachineName: Machine Name, NULL is the local machine
2695 * lpDeviceID: Specifies the device whose properties are to be shown
2698 * Always returns -1, a call to GetLastError returns 0 if successful
2704 DeviceAdvancedPropertiesA(IN HWND hWndParent OPTIONAL
,
2705 IN LPCSTR lpMachineName OPTIONAL
,
2706 IN LPCSTR lpDeviceID
)
2708 LPWSTR lpMachineNameW
= NULL
;
2709 LPWSTR lpDeviceIDW
= NULL
;
2712 if (lpMachineName
!= NULL
)
2714 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2720 if (lpDeviceID
!= NULL
)
2722 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2729 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
2734 if (lpMachineNameW
!= NULL
)
2736 HeapFree(GetProcessHeap(),
2740 if (lpDeviceIDW
!= NULL
)
2742 HeapFree(GetProcessHeap(),
2751 /***************************************************************************
2753 * DevicePropertiesExA
2756 * Invokes the extended device properties dialog
2759 * hWndParent: Handle to the parent window
2760 * lpMachineName: Machine Name, NULL is the local machine
2761 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2762 * bShowDevMgr is nonzero
2763 * dwFlags: This parameter can be a combination of the following flags:
2764 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2765 * the default device status action button
2766 * to be clicked (Troubleshoot, Enable
2768 * bShowDevMgr: If non-zero it displays the device manager instead of
2769 * the advanced device property dialog
2772 * 1: if bShowDevMgr is non-zero and no error occured
2773 * -1: a call to GetLastError returns 0 if successful
2779 DevicePropertiesExA(IN HWND hWndParent OPTIONAL
,
2780 IN LPCSTR lpMachineName OPTIONAL
,
2781 IN LPCSTR lpDeviceID OPTIONAL
,
2782 IN DWORD dwFlags OPTIONAL
,
2783 IN BOOL bShowDevMgr
)
2785 LPWSTR lpMachineNameW
= NULL
;
2786 LPWSTR lpDeviceIDW
= NULL
;
2789 if (lpMachineName
!= NULL
)
2791 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2797 if (lpDeviceID
!= NULL
)
2799 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2806 Ret
= DevicePropertiesExW(hWndParent
,
2813 if (lpMachineNameW
!= NULL
)
2815 HeapFree(GetProcessHeap(),
2819 if (lpDeviceIDW
!= NULL
)
2821 HeapFree(GetProcessHeap(),
2830 /***************************************************************************
2832 * DevicePropertiesExW
2835 * Invokes the extended device properties dialog
2838 * hWndParent: Handle to the parent window
2839 * lpMachineName: Machine Name, NULL is the local machine
2840 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2841 * bShowDevMgr is nonzero
2842 * dwFlags: This parameter can be a combination of the following flags:
2843 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2844 * the default device status action button
2845 * to be clicked (Troubleshoot, Enable
2847 * bShowDevMgr: If non-zero it displays the device manager instead of
2848 * the advanced device property dialog
2851 * 1: if bShowDevMgr is non-zero and no error occured
2852 * -1: a call to GetLastError returns 0 if successful
2858 DevicePropertiesExW(IN HWND hWndParent OPTIONAL
,
2859 IN LPCWSTR lpMachineName OPTIONAL
,
2860 IN LPCWSTR lpDeviceID OPTIONAL
,
2861 IN DWORD dwFlags OPTIONAL
,
2862 IN BOOL bShowDevMgr
)
2866 if (dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
))
2868 DPRINT1("DevPropertiesExW: Invalid flags: 0x%x\n",
2869 dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
));
2870 SetLastError(ERROR_INVALID_FLAGS
);
2876 DPRINT("DevPropertiesExW doesn't support bShowDevMgr!\n");
2877 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2882 SP_DEVINFO_DATA DevInfoData
;
2883 HINSTANCE hComCtl32
;
2885 if (lpDeviceID
== NULL
)
2887 SetLastError(ERROR_INVALID_PARAMETER
);
2891 /* dynamically load comctl32 */
2892 hComCtl32
= LoadAndInitComctl32();
2893 if (hComCtl32
!= NULL
)
2895 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2899 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2901 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2902 if (SetupDiOpenDeviceInfo(hDevInfo
,
2908 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2917 SetupDiDestroyDeviceInfoList(hDevInfo
);
2920 FreeLibrary(hComCtl32
);
2928 /***************************************************************************
2933 * Invokes the device properties dialog directly
2936 * hWndParent: Handle to the parent window
2937 * lpMachineName: Machine Name, NULL is the local machine
2938 * lpDeviceID: Specifies the device whose properties are to be shown
2939 * bShowDevMgr: If non-zero it displays the device manager instead of
2940 * the device property dialog
2943 * >=0: if no errors occured
2944 * -1: if errors occured
2952 DevicePropertiesA(HWND hWndParent
,
2953 LPCSTR lpMachineName
,
2957 return DevicePropertiesExA(hWndParent
,
2965 /***************************************************************************
2970 * Invokes the device properties dialog directly
2973 * hWndParent: Handle to the parent window
2974 * lpMachineName: Machine Name, NULL is the local machine
2975 * lpDeviceID: Specifies the device whose properties are to be shown
2976 * bShowDevMgr: If non-zero it displays the device manager instead of
2977 * the device property dialog
2980 * >=0: if no errors occured
2981 * -1: if errors occured
2989 DevicePropertiesW(HWND hWndParent
,
2990 LPCWSTR lpMachineName
,
2994 return DevicePropertiesExW(hWndParent
,
3002 /***************************************************************************
3004 * DeviceProperties_RunDLLA
3007 * Invokes the device properties dialog
3010 * hWndParent: Handle to the parent window
3011 * hInst: Handle to the application instance
3012 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3014 * nCmdShow: Specifies how the window should be shown
3021 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3022 * (/MachineName is optional). This function only parses this string and eventually
3023 * calls DeviceProperties().
3029 DeviceProperties_RunDLLA(HWND hWndParent
,
3034 LPWSTR lpDeviceCmdW
= NULL
;
3036 if (lpDeviceCmd
!= NULL
)
3038 if ((lpDeviceCmdW
= ConvertMultiByteToUnicode(lpDeviceCmd
,
3041 DeviceProperties_RunDLLW(hWndParent
,
3048 if (lpDeviceCmdW
!= NULL
)
3050 HeapFree(GetProcessHeap(),
3057 /***************************************************************************
3059 * DeviceProperties_RunDLLW
3062 * Invokes the device properties dialog
3065 * hWndParent: Handle to the parent window
3066 * hInst: Handle to the application instance
3067 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3069 * nCmdShow: Specifies how the window should be shown
3076 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3077 * (/MachineName is optional). This function only parses this string and eventually
3078 * calls DeviceProperties().
3084 DeviceProperties_RunDLLW(HWND hWndParent
,
3086 LPCWSTR lpDeviceCmd
,
3089 WCHAR szDeviceID
[MAX_DEVICE_ID_LEN
+1];
3090 WCHAR szMachineName
[MAX_COMPUTERNAME_LENGTH
+1];
3091 LPWSTR lpString
= (LPWSTR
)lpDeviceCmd
;
3093 if (!GetDeviceAndComputerName(lpString
,
3097 DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID
, szMachineName
);
3101 DevicePropertiesW(hWndParent
,