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
;
70 UINT FreeDevPropSheets
: 1;
72 UINT DeviceStarted
: 1;
73 UINT DeviceUsageChanged
: 1;
74 UINT CloseDevInst
: 1;
76 UINT DoDefaultDevAction
: 1;
77 UINT PageInitialized
: 1;
78 UINT ShowRemotePages
: 1;
79 UINT HasDriverPage
: 1;
80 UINT HasResourcePage
: 1;
81 UINT HasPowerPage
: 1;
88 /* struct may be dynamically expanded here! */
89 } DEVADVPROP_INFO
, *PDEVADVPROP_INFO
;
92 typedef struct _ENUMDRIVERFILES_CONTEXT
94 HWND hDriversListView
;
96 } ENUMDRIVERFILES_CONTEXT
, *PENUMDRIVERFILES_CONTEXT
;
98 #define PM_INITIALIZE (WM_APP + 0x101)
102 EnumDeviceDriverFilesCallback(IN PVOID Context
,
103 IN UINT Notification
,
108 PENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
= (PENUMDRIVERFILES_CONTEXT
)Context
;
110 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
111 li
.iItem
= EnumDriverFilesContext
->nCount
++;
113 li
.state
= (li
.iItem
== 0 ? LVIS_SELECTED
: 0);
114 li
.stateMask
= LVIS_SELECTED
;
115 li
.pszText
= (LPWSTR
)Param1
;
116 (void)ListView_InsertItem(EnumDriverFilesContext
->hDriversListView
,
123 UpdateDriverDetailsDlg(IN HWND hwndDlg
,
124 IN HWND hDriversListView
,
125 IN PDEVADVPROP_INFO dap
)
127 HDEVINFO DeviceInfoSet
;
128 PSP_DEVINFO_DATA DeviceInfoData
;
129 SP_DRVINFO_DATA DriverInfoData
;
130 ENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
;
132 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
134 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
135 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
139 DeviceInfoSet
= dap
->DeviceInfoSet
;
140 DeviceInfoData
= &dap
->DeviceInfoData
;
143 /* set the device image */
144 SendDlgItemMessage(hwndDlg
,
147 (WPARAM
)dap
->hDevIcon
,
150 /* set the device name edit control text */
151 SetDlgItemText(hwndDlg
,
155 /* fill the driver files list view */
156 EnumDriverFilesContext
.hDriversListView
= hDriversListView
;
157 EnumDriverFilesContext
.nCount
= 0;
159 (void)ListView_DeleteAllItems(EnumDriverFilesContext
.hDriversListView
);
160 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA
);
161 if (FindCurrentDriver(DeviceInfoSet
,
164 SetupDiSetSelectedDriver(DeviceInfoSet
,
168 HSPFILEQ queueHandle
;
170 queueHandle
= SetupOpenFileQueue();
171 if (queueHandle
!= (HSPFILEQ
)INVALID_HANDLE_VALUE
)
173 SP_DEVINSTALL_PARAMS DeviceInstallParams
= {0};
174 DeviceInstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS
);
175 if (SetupDiGetDeviceInstallParams(DeviceInfoSet
,
177 &DeviceInstallParams
))
179 DeviceInstallParams
.FileQueue
= queueHandle
;
180 DeviceInstallParams
.Flags
|= DI_NOVCP
;
182 if (SetupDiSetDeviceInstallParams(DeviceInfoSet
,
184 &DeviceInstallParams
) &&
185 SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES
,
193 /* enumerate the driver files */
194 SetupScanFileQueue(queueHandle
,
195 SPQ_SCAN_USE_CALLBACK
,
197 EnumDeviceDriverFilesCallback
,
198 &EnumDriverFilesContext
,
201 /* update the list view column width */
202 GetClientRect(hDriversListView
,
204 lvc
.mask
= LVCF_WIDTH
;
205 lvc
.cx
= rcClient
.right
;
206 (void)ListView_SetColumn(hDriversListView
,
210 /* highlight the first item from list */
211 if (ListView_GetSelectedCount(hDriversListView
) != 0)
213 ListView_SetItemState(hDriversListView
,
215 LVIS_FOCUSED
| LVIS_SELECTED
,
216 LVIS_FOCUSED
| LVIS_SELECTED
);
221 SetupCloseFileQueue(queueHandle
);
228 UpdateDriverVersionInfoDetails(IN HWND hwndDlg
,
229 IN LPCWSTR lpszDriverPath
)
233 LPVOID lpData
= NULL
;
237 WCHAR szLangInfo
[255];
238 WCHAR szLangPath
[MAX_PATH
];
239 LPWSTR lpCompanyName
= NULL
;
240 LPWSTR lpFileVersion
= NULL
;
241 LPWSTR lpLegalCopyright
= NULL
;
242 LPWSTR lpDigitalSigner
= NULL
;
244 WCHAR szNotAvailable
[255];
246 /* extract version info from selected file */
247 dwVerInfoSize
= GetFileVersionInfoSize(lpszDriverPath
,
252 lpData
= HeapAlloc(GetProcessHeap(),
258 if (!GetFileVersionInfo(lpszDriverPath
,
264 if (!VerQueryValue(lpData
,
265 L
"\\VarFileInfo\\Translation",
270 dwLangId
= *(LPDWORD
)lpInfo
;
271 swprintf(szLangInfo
, L
"\\StringFileInfo\\%04x%04x\\",
272 LOWORD(dwLangId
), HIWORD(dwLangId
));
274 /* read CompanyName */
275 wcscpy(szLangPath
, szLangInfo
);
276 wcscat(szLangPath
, L
"CompanyName");
278 VerQueryValue(lpData
,
280 (void **)&lpCompanyName
,
283 /* read FileVersion */
284 wcscpy(szLangPath
, szLangInfo
);
285 wcscat(szLangPath
, L
"FileVersion");
287 VerQueryValue(lpData
,
289 (void **)&lpFileVersion
,
292 /* read LegalTrademarks */
293 wcscpy(szLangPath
, szLangInfo
);
294 wcscat(szLangPath
, L
"LegalCopyright");
296 VerQueryValue(lpData
,
298 (void **)&lpLegalCopyright
,
301 /* TODO: read digital signer info */
304 if (!LoadString(hDllInstance
,
307 sizeof(szNotAvailable
) / sizeof(WCHAR
)))
309 wcscpy(szNotAvailable
, L
"n/a");
314 lpCompanyName
= szNotAvailable
;
315 SetDlgItemText(hwndDlg
,
320 lpFileVersion
= szNotAvailable
;
321 SetDlgItemText(hwndDlg
,
325 if (!lpLegalCopyright
)
326 lpLegalCopyright
= szNotAvailable
;
327 SetDlgItemText(hwndDlg
,
331 if (!lpDigitalSigner
)
332 lpDigitalSigner
= szNotAvailable
;
333 SetDlgItemText(hwndDlg
,
337 /* release version info */
339 HeapFree(GetProcessHeap(),
347 DriverDetailsDlgProc(IN HWND hwndDlg
,
352 PDEVADVPROP_INFO dap
;
355 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
358 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
364 switch (LOWORD(wParam
))
387 HWND hDriversListView
;
389 dap
= (PDEVADVPROP_INFO
)lParam
;
392 SetWindowLongPtr(hwndDlg
,
396 hDriversListView
= GetDlgItem(hwndDlg
,
399 /* add a column to the list view control */
400 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
401 lvc
.fmt
= LVCFMT_LEFT
;
403 (void)ListView_InsertColumn(hDriversListView
,
407 UpdateDriverDetailsDlg(hwndDlg
,
418 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
420 switch (pnmhdr
->code
)
422 case LVN_ITEMCHANGED
:
424 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
425 HWND hDriversListView
= GetDlgItem(hwndDlg
,
428 if (ListView_GetSelectedCount(hDriversListView
) == 0)
430 /* nothing is selected - empty the labels */
431 SetDlgItemText(hwndDlg
,
434 SetDlgItemText(hwndDlg
,
437 SetDlgItemText(hwndDlg
,
440 SetDlgItemText(hwndDlg
,
444 else if (pnmv
->uNewState
!= 0)
446 /* extract version info and update the labels */
447 WCHAR szDriverPath
[MAX_PATH
];
449 ListView_GetItemText(hDriversListView
,
455 UpdateDriverVersionInfoDetails(hwndDlg
,
470 UpdateDriverDlg(IN HWND hwndDlg
,
471 IN PDEVADVPROP_INFO dap
)
473 HDEVINFO DeviceInfoSet
;
474 PSP_DEVINFO_DATA DeviceInfoData
;
476 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
478 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
479 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
483 DeviceInfoSet
= dap
->DeviceInfoSet
;
484 DeviceInfoData
= &dap
->DeviceInfoData
;
487 /* set the device image */
488 SendDlgItemMessage(hwndDlg
,
491 (WPARAM
)dap
->hDevIcon
,
494 /* set the device name edit control text */
495 SetDlgItemText(hwndDlg
,
499 /* query the driver provider */
500 if (GetDriverProviderString(DeviceInfoSet
,
503 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
505 SetDlgItemText(hwndDlg
,
510 /* query the driver date */
511 if (GetDriverDateString(DeviceInfoSet
,
514 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
516 SetDlgItemText(hwndDlg
,
521 /* query the driver version */
522 if (GetDriverVersionString(DeviceInfoSet
,
525 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
527 SetDlgItemText(hwndDlg
,
536 AdvProcDriverDlgProc(IN HWND hwndDlg
,
541 PDEVADVPROP_INFO dap
;
544 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
547 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
553 switch (LOWORD(wParam
))
555 case IDC_DRIVERDETAILS
:
557 DialogBoxParam(hDllInstance
,
558 MAKEINTRESOURCE(IDD_DRIVERDETAILS
),
560 DriverDetailsDlgProc
,
570 NMHDR
*hdr
= (NMHDR
*)lParam
;
581 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
584 SetWindowLongPtr(hwndDlg
,
588 UpdateDriverDlg(hwndDlg
,
602 SetListViewText(HWND hwnd
,
608 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
611 li
.state
= 0; //(li.iItem == 0 ? LVIS_SELECTED : 0);
612 li
.stateMask
= LVIS_SELECTED
;
614 (void)ListView_InsertItem(hwnd
,
620 UpdateDetailsDlg(IN HWND hwndDlg
,
621 IN PDEVADVPROP_INFO dap
)
632 IDS_PROP_HARDWAREIDS
,
633 IDS_PROP_COMPATIBLEIDS
,
634 IDS_PROP_MATCHINGDEVICEID
,
637 IDS_PROP_CAPABILITIES
,
638 IDS_PROP_DEVNODEFLAGS
,
639 IDS_PROP_CONFIGFLAGS
,
640 IDS_PROP_CSCONFIGFLAGS
,
641 IDS_PROP_EJECTIONRELATIONS
,
642 IDS_PROP_REMOVALRELATIONS
,
643 IDS_PROP_BUSRELATIONS
,
644 IDS_PROP_DEVUPPERFILTERS
,
645 IDS_PROP_DEVLOWERFILTERS
,
646 IDS_PROP_CLASSUPPERFILTERS
,
647 IDS_PROP_CLASSLOWERFILTERS
,
648 IDS_PROP_CLASSINSTALLER
,
649 IDS_PROP_CLASSCOINSTALLER
,
650 IDS_PROP_DEVICECOINSTALLER
,
651 IDS_PROP_FIRMWAREREVISION
,
652 IDS_PROP_CURRENTPOWERSTATE
,
653 IDS_PROP_POWERCAPABILITIES
,
654 IDS_PROP_POWERSTATEMAPPINGS
658 /* set the device image */
659 SendDlgItemMessage(hwndDlg
,
662 (WPARAM
)dap
->hDevIcon
,
665 /* set the device name edit control text */
666 SetDlgItemText(hwndDlg
,
671 hwndComboBox
= GetDlgItem(hwndDlg
,
672 IDC_DETAILSPROPNAME
);
674 hwndListView
= GetDlgItem(hwndDlg
,
675 IDC_DETAILSPROPVALUE
);
677 for (i
= 0; i
!= sizeof(Properties
) / sizeof(Properties
[0]); i
++)
679 /* fill in the device usage combo box */
680 if (LoadString(hDllInstance
,
683 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
685 SendMessage(hwndComboBox
,
688 (LPARAM
)dap
->szTemp
);
693 GetClientRect(hwndListView
,
696 /* add a column to the list view control */
697 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
698 lvc
.fmt
= LVCFMT_LEFT
;
699 lvc
.cx
= rcClient
.right
;
700 (void)ListView_InsertColumn(hwndListView
,
704 SendMessage(hwndComboBox
,
709 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
711 SetFocus(hwndComboBox
);
716 DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap
,
717 IN HWND hwndListView
,
720 HDEVINFO DeviceInfoSet
;
721 PSP_DEVINFO_DATA DeviceInfoData
;
730 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
732 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
733 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
737 DeviceInfoSet
= dap
->DeviceInfoSet
;
738 DeviceInfoData
= &dap
->DeviceInfoData
;
742 SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
751 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
753 swprintf(dap
->szTemp
, L
"Error: Getting the size failed! (Error: %ld)", GetLastError());
754 SetListViewText(hwndListView
, 0, dap
->szTemp
);
759 lpBuffer
= HeapAlloc(GetProcessHeap(),
762 if (lpBuffer
== NULL
)
764 SetListViewText(hwndListView
, 0, L
"Error: Allocating the buffer failed!");
768 if (SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
776 if (dwType
== REG_SZ
)
778 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
780 else if (dwType
== REG_MULTI_SZ
)
782 lpStr
= (LPWSTR
)lpBuffer
;
786 len
= wcslen(lpStr
) + 1;
788 SetListViewText(hwndListView
, index
, lpStr
);
794 else if (dwType
== REG_DWORD
)
796 dwValue
= *(DWORD
*) lpBuffer
;
800 case SPDRP_CAPABILITIES
:
802 if (dwValue
& CM_DEVCAP_LOCKSUPPORTED
)
803 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_LOCKSUPPORTED");
804 if (dwValue
& CM_DEVCAP_EJECTSUPPORTED
)
805 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_EJECTSUPPORTED");
806 if (dwValue
& CM_DEVCAP_REMOVABLE
)
807 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_REMOVABLE");
808 if (dwValue
& CM_DEVCAP_DOCKDEVICE
)
809 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_DOCKDEVICE");
810 if (dwValue
& CM_DEVCAP_UNIQUEID
)
811 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_UNIQUEID");
812 if (dwValue
& CM_DEVCAP_SILENTINSTALL
)
813 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SILENTINSTALL");
814 if (dwValue
& CM_DEVCAP_RAWDEVICEOK
)
815 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_RAWDEVICEOK");
816 if (dwValue
& CM_DEVCAP_SURPRISEREMOVALOK
)
817 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SURPRISEREMOVALOK");
818 if (dwValue
& CM_DEVCAP_HARDWAREDISABLED
)
819 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_HARDWAREDISABLED");
820 if (dwValue
& CM_DEVCAP_NONDYNAMIC
)
821 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_NONDYNAMIC");
824 case SPDRP_CONFIGFLAGS
:
826 if (dwValue
& CONFIGFLAG_DISABLED
)
827 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_DISABLED");
828 if (dwValue
& CONFIGFLAG_REMOVED
)
829 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REMOVED");
830 if (dwValue
& CONFIGFLAG_MANUAL_INSTALL
)
831 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_MANUAL_INSTALL");
832 if (dwValue
& CONFIGFLAG_IGNORE_BOOT_LC
)
833 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_IGNORE_BOOT_LC");
834 if (dwValue
& CONFIGFLAG_NET_BOOT
)
835 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NET_BOOT");
836 if (dwValue
& CONFIGFLAG_REINSTALL
)
837 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REINSTALL");
838 if (dwValue
& CONFIGFLAG_FAILEDINSTALL
)
839 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_FAILEDINSTALL");
840 if (dwValue
& CONFIGFLAG_CANTSTOPACHILD
)
841 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_CANTSTOPACHILD");
842 if (dwValue
& CONFIGFLAG_OKREMOVEROM
)
843 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_OKREMOVEROM");
844 if (dwValue
& CONFIGFLAG_NOREMOVEEXIT
)
845 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NOREMOVEEXIT");
849 swprintf(dap
->szTemp
, L
"0x%08lx", dwValue
);
850 SetListViewText(hwndListView
, 0, dap
->szTemp
);
856 SetListViewText(hwndListView
, 0, L
"Error: Unsupported value type!");
862 SetListViewText(hwndListView
, 0, L
"Error: Retrieving the value failed!");
865 HeapFree(GetProcessHeap(),
871 DisplayDevNodeFlags(IN PDEVADVPROP_INFO dap
,
872 IN HWND hwndListView
)
878 CM_Get_DevNode_Status_Ex(&dwStatus
,
880 dap
->DeviceInfoData
.DevInst
,
885 if (dwStatus
& DN_ROOT_ENUMERATED
)
886 SetListViewText(hwndListView
, index
++, L
"DN_ROOT_ENUMERATED");
887 if (dwStatus
& DN_DRIVER_LOADED
)
888 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_LOADED");
889 if (dwStatus
& DN_ENUM_LOADED
)
890 SetListViewText(hwndListView
, index
++, L
"DN_ENUM_LOADED");
891 if (dwStatus
& DN_STARTED
)
892 SetListViewText(hwndListView
, index
++, L
"DN_STARTED");
893 if (dwStatus
& DN_MANUAL
)
894 SetListViewText(hwndListView
, index
++, L
"DN_MANUAL");
895 if (dwStatus
& DN_NEED_TO_ENUM
)
896 SetListViewText(hwndListView
, index
++, L
"DN_NEED_TO_ENUM");
897 if (dwStatus
& DN_DRIVER_BLOCKED
)
898 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_BLOCKED");
899 if (dwStatus
& DN_HARDWARE_ENUM
)
900 SetListViewText(hwndListView
, index
++, L
"DN_HARDWARE_ENUM");
901 if (dwStatus
& DN_NEED_RESTART
)
902 SetListViewText(hwndListView
, index
++, L
"DN_NEED_RESTART");
903 if (dwStatus
& DN_CHILD_WITH_INVALID_ID
)
904 SetListViewText(hwndListView
, index
++, L
"DN_CHILD_WITH_INVALID_ID");
905 if (dwStatus
& DN_HAS_PROBLEM
)
906 SetListViewText(hwndListView
, index
++, L
"DN_HAS_PROBLEM");
907 if (dwStatus
& DN_FILTERED
)
908 SetListViewText(hwndListView
, index
++, L
"DN_FILTERED");
909 if (dwStatus
& DN_LEGACY_DRIVER
)
910 SetListViewText(hwndListView
, index
++, L
"DN_LEGACY_DRIVER");
911 if (dwStatus
& DN_DISABLEABLE
)
912 SetListViewText(hwndListView
, index
++, L
"DN_DISABLEABLE");
913 if (dwStatus
& DN_REMOVABLE
)
914 SetListViewText(hwndListView
, index
++, L
"DN_REMOVABLE");
915 if (dwStatus
& DN_PRIVATE_PROBLEM
)
916 SetListViewText(hwndListView
, index
++, L
"DN_PRIVATE_PROBLEM");
917 if (dwStatus
& DN_MF_PARENT
)
918 SetListViewText(hwndListView
, index
++, L
"DN_MF_PARENT");
919 if (dwStatus
& DN_MF_CHILD
)
920 SetListViewText(hwndListView
, index
++, L
"DN_MF_CHILD");
921 if (dwStatus
& DN_WILL_BE_REMOVED
)
922 SetListViewText(hwndListView
, index
++, L
"DN_WILL_BE_REMOVED");
924 if (dwStatus
& DN_NOT_FIRST_TIMEE
)
925 SetListViewText(hwndListView
, index
++, L
"DN_NOT_FIRST_TIMEE");
926 if (dwStatus
& DN_STOP_FREE_RES
)
927 SetListViewText(hwndListView
, index
++, L
"DN_STOP_FREE_RES");
928 if (dwStatus
& DN_REBAL_CANDIDATE
)
929 SetListViewText(hwndListView
, index
++, L
"DN_REBAL_CANDIDATE");
930 if (dwStatus
& DN_BAD_PARTIAL
)
931 SetListViewText(hwndListView
, index
++, L
"DN_BAD_PARTIAL");
932 if (dwStatus
& DN_NT_ENUMERATOR
)
933 SetListViewText(hwndListView
, index
++, L
"DN_NT_ENUMERATOR");
934 if (dwStatus
& DN_NT_DRIVER
)
935 SetListViewText(hwndListView
, index
++, L
"DN_NT_DRIVER");
937 if (dwStatus
& DN_NEEDS_LOCKING
)
938 SetListViewText(hwndListView
, index
++, L
"DN_NEEDS_LOCKING");
939 if (dwStatus
& DN_ARM_WAKEUP
)
940 SetListViewText(hwndListView
, index
++, L
"DN_ARM_WAKEUP");
941 if (dwStatus
& DN_APM_ENUMERATOR
)
942 SetListViewText(hwndListView
, index
++, L
"DN_APM_ENUMERATOR");
943 if (dwStatus
& DN_APM_DRIVER
)
944 SetListViewText(hwndListView
, index
++, L
"DN_APM_DRIVER");
945 if (dwStatus
& DN_SILENT_INSTALL
)
946 SetListViewText(hwndListView
, index
++, L
"DN_SILENT_INSTALL");
947 if (dwStatus
& DN_NO_SHOW_IN_DM
)
948 SetListViewText(hwndListView
, index
++, L
"DN_NO_SHOW_IN_DM");
949 if (dwStatus
& DN_BOOT_LOG_PROB
)
950 SetListViewText(hwndListView
, index
++, L
"DN_BOOT_LOG_PROB");
952 // swprintf(dap->szTemp, L"0x%08x", dwStatus);
953 // SetListViewText(hwndListView, 0, dap->szTemp);
958 DisplayDevNodeEnumerator(IN PDEVADVPROP_INFO dap
,
959 IN HWND hwndListView
)
961 PSP_DEVINFO_DATA DeviceInfoData
;
965 DWORD dwSize
= 256 * sizeof(WCHAR
);
967 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
969 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
973 DeviceInfoData
= &dap
->DeviceInfoData
;
976 CM_Get_DevNode_Registry_Property_ExW(DeviceInfoData
->DevInst
,
977 CM_DRP_ENUMERATOR_NAME
,
984 SetListViewText(hwndListView
, 0, szBuffer
);
989 DisplayCsFlags(IN PDEVADVPROP_INFO dap
,
990 IN HWND hwndListView
)
995 CM_Get_HW_Prof_Flags_Ex(dap
->szDevName
,
996 0, /* current hardware profile */
1002 if (dwValue
& CSCONFIGFLAG_DISABLED
)
1003 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DISABLED");
1005 if (dwValue
& CSCONFIGFLAG_DO_NOT_CREATE
)
1006 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_CREATE");
1008 if (dwValue
& CSCONFIGFLAG_DO_NOT_START
)
1009 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_START");
1014 DisplayMatchingDeviceId(IN PDEVADVPROP_INFO dap
,
1015 IN HWND hwndListView
)
1017 HDEVINFO DeviceInfoSet
;
1018 PSP_DEVINFO_DATA DeviceInfoData
;
1019 WCHAR szBuffer
[256];
1024 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1026 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1027 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1031 DeviceInfoSet
= dap
->DeviceInfoSet
;
1032 DeviceInfoData
= &dap
->DeviceInfoData
;
1035 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1041 if (hKey
!= INVALID_HANDLE_VALUE
)
1043 dwSize
= 256 * sizeof(WCHAR
);
1044 if (RegQueryValueEx(hKey
,
1045 L
"MatchingDeviceId",
1049 &dwSize
) == ERROR_SUCCESS
)
1051 SetListViewText(hwndListView
, 0, szBuffer
);
1060 DisplayDeviceCoinstallers(IN PDEVADVPROP_INFO dap
,
1061 IN HWND hwndListView
)
1063 HDEVINFO DeviceInfoSet
;
1064 PSP_DEVINFO_DATA DeviceInfoData
;
1073 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1075 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1076 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1080 DeviceInfoSet
= dap
->DeviceInfoSet
;
1081 DeviceInfoData
= &dap
->DeviceInfoData
;
1084 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1090 if (hKey
!= INVALID_HANDLE_VALUE
)
1093 if (RegQueryValueEx(hKey
,
1098 &dwSize
) == ERROR_SUCCESS
&&
1102 lpBuffer
= HeapAlloc(GetProcessHeap(),
1106 RegQueryValueEx(hKey
,
1113 lpStr
= (LPWSTR
)lpBuffer
;
1117 len
= wcslen(lpStr
) + 1;
1119 SetListViewText(hwndListView
, index
, lpStr
);
1125 HeapFree(GetProcessHeap(),
1136 DisplayClassProperties(IN PDEVADVPROP_INFO dap
,
1137 IN HWND hwndListView
,
1138 IN LPWSTR lpProperty
)
1140 HDEVINFO DeviceInfoSet
;
1141 PSP_DEVINFO_DATA DeviceInfoData
;
1142 WCHAR szClassGuid
[45];
1152 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1154 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1155 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1159 DeviceInfoSet
= dap
->DeviceInfoSet
;
1160 DeviceInfoData
= &dap
->DeviceInfoData
;
1163 dwSize
= 45 * sizeof(WCHAR
);
1164 if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
1168 (LPBYTE
)szClassGuid
,
1173 pSetupGuidFromString(szClassGuid
,
1176 hKey
= SetupDiOpenClassRegKey(&ClassGuid
,
1178 if (hKey
!= INVALID_HANDLE_VALUE
)
1181 if (RegQueryValueEx(hKey
,
1186 &dwSize
) == ERROR_SUCCESS
&&
1189 lpBuffer
= HeapAlloc(GetProcessHeap(),
1193 RegQueryValueEx(hKey
,
1200 if (dwType
== REG_SZ
)
1202 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
1204 else if (dwType
== REG_MULTI_SZ
)
1206 lpStr
= (LPWSTR
)lpBuffer
;
1210 len
= wcslen(lpStr
) + 1;
1212 SetListViewText(hwndListView
, index
, lpStr
);
1219 HeapFree(GetProcessHeap(),
1230 DisplayDeviceProperties(IN PDEVADVPROP_INFO dap
,
1231 IN HWND hwndComboBox
,
1232 IN HWND hwndListView
)
1236 Index
= (INT
)SendMessage(hwndComboBox
,
1240 if (Index
== CB_ERR
)
1243 (void)ListView_DeleteAllItems(hwndListView
);
1248 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
1251 case 1: /* Hardware ID */
1252 DisplayDevicePropertyText(dap
,
1257 case 2: /* Compatible IDs */
1258 DisplayDevicePropertyText(dap
,
1260 SPDRP_COMPATIBLEIDS
);
1263 case 3: /* Matching ID */
1264 DisplayMatchingDeviceId(dap
,
1268 case 4: /* Service */
1269 DisplayDevicePropertyText(dap
,
1274 case 5: /* Enumerator */
1275 DisplayDevNodeEnumerator(dap
,
1279 case 6: /* Capabilities */
1280 DisplayDevicePropertyText(dap
,
1282 SPDRP_CAPABILITIES
);
1285 case 7: /* Devnode Flags */
1286 DisplayDevNodeFlags(dap
,
1290 case 8: /* Config Flags */
1291 DisplayDevicePropertyText(dap
,
1296 case 9: /* CSConfig Flags */
1302 case 10: /* Ejection relation */
1305 case 11: /* Removal relations */
1308 case 12: /* Bus relation */
1312 case 13: /* Device Upper Filters */
1313 DisplayDevicePropertyText(dap
,
1315 SPDRP_UPPERFILTERS
);
1318 case 14: /* Device Lower Filters */
1319 DisplayDevicePropertyText(dap
,
1321 SPDRP_LOWERFILTERS
);
1324 case 15: /* Class Upper Filters */
1325 DisplayClassProperties(dap
,
1330 case 16: /* Class Lower Filters */
1331 DisplayClassProperties(dap
,
1336 case 17: /* Class Installer */
1337 DisplayClassProperties(dap
,
1343 case 18: /* Class Coinstaller */
1347 case 19: /* Device Coinstaller */
1348 DisplayDeviceCoinstallers(dap
,
1353 case 20: /* Firmware Revision */
1356 case 21: /* Current Power State */
1359 case 20: /* Power Capabilities */
1362 case 21: /* Power State Mappings */
1367 SetListViewText(hwndListView
, 0, L
"<Not implemented yet>");
1375 AdvProcDetailsDlgProc(IN HWND hwndDlg
,
1380 PDEVADVPROP_INFO dap
;
1381 INT_PTR Ret
= FALSE
;
1383 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
1386 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
1392 switch (LOWORD(wParam
))
1394 case IDC_DETAILSPROPNAME
:
1395 if (HIWORD(wParam
) == CBN_SELCHANGE
)
1397 DisplayDeviceProperties(dap
,
1398 GetDlgItem(hwndDlg
, IDC_DETAILSPROPNAME
),
1399 GetDlgItem(hwndDlg
, IDC_DETAILSPROPVALUE
));
1408 NMHDR
*hdr
= (NMHDR
*)lParam
;
1419 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1422 SetWindowLongPtr(hwndDlg
,
1426 UpdateDetailsDlg(hwndDlg
,
1440 InitDevUsageActions(IN HWND hwndDlg
,
1442 IN PDEVADVPROP_INFO dap
)
1453 i
!= sizeof(Actions
) / sizeof(Actions
[0]);
1456 /* fill in the device usage combo box */
1457 if (LoadString(hDllInstance
,
1460 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1462 Index
= (INT
)SendMessage(hComboBox
,
1465 (LPARAM
)dap
->szTemp
);
1466 if (Index
!= CB_ERR
)
1468 SendMessage(hComboBox
,
1471 (LPARAM
)Actions
[i
]);
1475 case IDS_ENABLEDEVICE
:
1476 if (dap
->DeviceStarted
)
1478 SendMessage(hComboBox
,
1485 case IDS_DISABLEDEVICE
:
1486 if (!dap
->DeviceStarted
)
1488 SendMessage(hComboBox
,
1505 GetSelectedUsageAction(IN HWND hComboBox
)
1510 Index
= (INT
)SendMessage(hComboBox
,
1514 if (Index
!= CB_ERR
)
1516 INT iRet
= (INT
) SendMessage(hComboBox
,
1531 ApplyGeneralSettings(IN HWND hwndDlg
,
1532 IN PDEVADVPROP_INFO dap
)
1536 if (dap
->DeviceUsageChanged
&& dap
->IsAdmin
&& dap
->CanDisable
)
1538 UINT SelectedUsageAction
;
1539 BOOL NeedReboot
= FALSE
;
1541 SelectedUsageAction
= GetSelectedUsageAction(GetDlgItem(hwndDlg
,
1543 switch (SelectedUsageAction
)
1545 case IDS_ENABLEDEVICE
:
1546 if (!dap
->DeviceStarted
)
1548 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1549 &dap
->DeviceInfoData
,
1556 case IDS_DISABLEDEVICE
:
1557 if (dap
->DeviceStarted
)
1559 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1560 &dap
->DeviceInfoData
,
1575 /* make PropertySheet() return PSM_REBOOTSYSTEM */
1576 PropSheet_RebootSystem(hwndDlg
);
1581 /* FIXME - display an error message */
1582 DPRINT1("Failed to enable/disable device! LastError: %d\n",
1587 Ret
= !dap
->DeviceUsageChanged
;
1589 /* disable the apply button */
1590 PropSheet_UnChanged(GetParent(hwndDlg
),
1592 dap
->DeviceUsageChanged
= FALSE
;
1598 UpdateDevInfo(IN HWND hwndDlg
,
1599 IN PDEVADVPROP_INFO dap
,
1602 HWND hDevUsage
, hPropSheetDlg
, hDevProbBtn
;
1604 ULONG Status
, ProblemNumber
;
1605 SP_DEVINSTALL_PARAMS_W InstallParams
;
1606 UINT TroubleShootStrId
= IDS_TROUBLESHOOTDEV
;
1607 BOOL bFlag
, bDevActionAvailable
= TRUE
;
1608 BOOL bDrvInstalled
= FALSE
;
1610 HDEVINFO DeviceInfoSet
= NULL
;
1611 PSP_DEVINFO_DATA DeviceInfoData
= NULL
;
1612 PROPSHEETHEADER psh
;
1613 DWORD nDriverPages
= 0;
1614 BOOL RecalcPages
= FALSE
;
1616 hPropSheetDlg
= GetParent(hwndDlg
);
1618 if (dap
->PageInitialized
)
1620 /* switch to the General page */
1621 PropSheet_SetCurSelByID(hPropSheetDlg
,
1624 /* remove and destroy the existing device property sheet pages */
1625 if (dap
->DevPropSheets
!= NULL
)
1628 iPage
!= dap
->nDevPropSheets
;
1631 if (dap
->DevPropSheets
[iPage
] != NULL
)
1633 PropSheet_RemovePage(hPropSheetDlg
,
1635 dap
->DevPropSheets
[iPage
]);
1644 if (dap
->FreeDevPropSheets
)
1646 /* don't free the array if it's the one allocated in
1647 DisplayDeviceAdvancedProperties */
1648 HeapFree(GetProcessHeap(),
1650 dap
->DevPropSheets
);
1652 dap
->FreeDevPropSheets
= FALSE
;
1655 dap
->DevPropSheets
= NULL
;
1656 dap
->nDevPropSheets
= 0;
1660 /* create a new device info set and re-open the device */
1661 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1663 SetupDiDestroyDeviceInfoList(dap
->CurrentDeviceInfoSet
);
1666 dap
->ParentDevInst
= 0;
1667 dap
->CurrentDeviceInfoSet
= SetupDiCreateDeviceInfoListEx(NULL
,
1671 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1673 if (SetupDiOpenDeviceInfo(dap
->CurrentDeviceInfoSet
,
1677 &dap
->CurrentDeviceInfoData
))
1679 if (dap
->CloseDevInst
)
1681 SetupDiDestroyDeviceInfoList(dap
->DeviceInfoSet
);
1684 dap
->CloseDevInst
= TRUE
;
1685 dap
->DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1686 dap
->DeviceInfoData
= dap
->CurrentDeviceInfoData
;
1687 dap
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
1695 /* get the parent node from the initial devinst */
1696 CM_Get_Parent_Ex(&dap
->ParentDevInst
,
1697 dap
->DeviceInfoData
.DevInst
,
1702 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1704 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1705 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1709 DeviceInfoSet
= dap
->DeviceInfoSet
;
1710 DeviceInfoData
= &dap
->DeviceInfoData
;
1715 DeviceInfoSet
= dap
->DeviceInfoSet
;
1716 DeviceInfoData
= &dap
->DeviceInfoData
;
1719 dap
->HasDriverPage
= FALSE
;
1720 dap
->HasResourcePage
= FALSE
;
1721 dap
->HasPowerPage
= FALSE
;
1722 if (IsDriverInstalled(DeviceInfoData
->DevInst
,
1727 if (SetupDiCallClassInstaller((dap
->ShowRemotePages
?
1728 DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
:
1729 DIF_ADDPROPERTYPAGE_ADVANCED
),
1733 /* get install params */
1734 InstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
1735 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet
,
1739 /* zero the flags */
1740 InstallParams
.Flags
= 0;
1743 dap
->HasDriverPage
= !(InstallParams
.Flags
& DI_DRIVERPAGE_ADDED
);
1744 dap
->HasResourcePage
= !(InstallParams
.Flags
& DI_RESOURCEPAGE_ADDED
);
1745 dap
->HasPowerPage
= !(InstallParams
.Flags
& DI_FLAGSEX_POWERPAGE_ADDED
);
1749 /* get the device icon */
1750 if (dap
->hDevIcon
!= NULL
)
1752 DestroyIcon(dap
->hDevIcon
);
1753 dap
->hDevIcon
= NULL
;
1755 if (!SetupDiLoadClassIcon(&DeviceInfoData
->ClassGuid
,
1759 dap
->hDevIcon
= NULL
;
1762 /* get the device name */
1763 if (GetDeviceDescriptionString(DeviceInfoSet
,
1766 sizeof(dap
->szDevName
) / sizeof(dap
->szDevName
[0])))
1768 PropSheet_SetTitle(hPropSheetDlg
,
1773 /* set the device image */
1774 SendDlgItemMessage(hwndDlg
,
1777 (WPARAM
)dap
->hDevIcon
,
1780 /* set the device name edit control text */
1781 SetDlgItemText(hwndDlg
,
1785 /* set the device type edit control text */
1786 if (GetDeviceTypeString(DeviceInfoData
,
1788 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1790 SetDlgItemText(hwndDlg
,
1795 /* set the device manufacturer edit control text */
1796 if (GetDeviceManufacturerString(DeviceInfoSet
,
1799 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1801 SetDlgItemText(hwndDlg
,
1802 IDC_DEVMANUFACTURER
,
1806 /* set the device location edit control text */
1807 if (GetDeviceLocationString(DeviceInfoSet
,
1811 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1813 SetDlgItemText(hwndDlg
,
1818 /* set the device status edit control text */
1819 if (GetDeviceStatusString(DeviceInfoData
->DevInst
,
1822 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1824 SetDlgItemText(hwndDlg
,
1829 /* set the device troubleshoot button text and disable it if necessary */
1830 hDevProbBtn
= GetDlgItem(hwndDlg
,
1832 cr
= CM_Get_DevNode_Status_Ex(&Status
,
1834 DeviceInfoData
->DevInst
,
1837 if (cr
== CR_SUCCESS
&& (Status
& DN_HAS_PROBLEM
))
1839 switch (ProblemNumber
)
1841 case CM_PROB_DEVLOADER_FAILED
:
1843 /* FIXME - only if it's not a root bus devloader,
1844 disable the button otherwise */
1845 TroubleShootStrId
= IDS_UPDATEDRV
;
1849 case CM_PROB_OUT_OF_MEMORY
:
1850 case CM_PROB_ENTRY_IS_WRONG_TYPE
:
1851 case CM_PROB_LACKED_ARBITRATOR
:
1852 case CM_PROB_FAILED_START
:
1854 case CM_PROB_UNKNOWN_RESOURCE
:
1856 TroubleShootStrId
= IDS_UPDATEDRV
;
1860 case CM_PROB_BOOT_CONFIG_CONFLICT
:
1861 case CM_PROB_NORMAL_CONFLICT
:
1862 case CM_PROB_REENUMERATION
:
1864 /* FIXME - Troubleshoot conflict */
1868 case CM_PROB_FAILED_FILTER
:
1869 case CM_PROB_REINSTALL
:
1870 case CM_PROB_FAILED_INSTALL
:
1872 TroubleShootStrId
= IDS_REINSTALLDRV
;
1876 case CM_PROB_DEVLOADER_NOT_FOUND
:
1879 1) if it's a missing system devloader:
1880 - disable the button (Reinstall Driver)
1881 2) if it's not a system devloader but still missing:
1883 3) if it's not a system devloader but the file can be found:
1885 4) if it's a missing or empty software key
1891 case CM_PROB_INVALID_DATA
:
1892 case CM_PROB_PARTIAL_LOG_CONF
:
1893 case CM_PROB_NO_VALID_LOG_CONF
:
1894 case CM_PROB_HARDWARE_DISABLED
:
1895 case CM_PROB_CANT_SHARE_IRQ
:
1896 case CM_PROB_TRANSLATION_FAILED
:
1897 case CM_PROB_SYSTEM_SHUTDOWN
:
1898 case CM_PROB_PHANTOM
:
1899 bDevActionAvailable
= FALSE
;
1902 case CM_PROB_NOT_VERIFIED
:
1903 case CM_PROB_DEVICE_NOT_THERE
:
1904 /* FIXME - search hardware */
1907 case CM_PROB_NEED_RESTART
:
1908 case CM_PROB_WILL_BE_REMOVED
:
1910 case CM_PROB_TOO_EARLY
:
1911 case CM_PROB_DISABLED_SERVICE
:
1912 TroubleShootStrId
= IDS_REBOOT
;
1915 case CM_PROB_REGISTRY
:
1916 /* FIXME - check registry? */
1919 case CM_PROB_DISABLED
:
1920 /* if device was disabled by the user: */
1921 TroubleShootStrId
= IDS_ENABLEDEV
;
1922 /* FIXME - otherwise disable button because the device was
1923 disabled by the system*/
1926 case CM_PROB_DEVLOADER_NOT_READY
:
1927 /* FIXME - if it's a graphics adapter:
1928 - if it's a a secondary adapter and the main adapter
1938 case CM_PROB_FAILED_ADD
:
1939 TroubleShootStrId
= IDS_PROPERTIES
;
1944 if (LoadString(hDllInstance
,
1947 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])) != 0)
1949 SetWindowText(hDevProbBtn
,
1952 EnableWindow(hDevProbBtn
,
1953 dap
->IsAdmin
&& bDevActionAvailable
);
1955 /* check if the device can be enabled/disabled */
1956 hDevUsage
= GetDlgItem(hwndDlg
,
1959 dap
->CanDisable
= FALSE
;
1960 dap
->DeviceStarted
= FALSE
;
1962 if (CanDisableDevice(DeviceInfoData
->DevInst
,
1966 dap
->CanDisable
= bFlag
;
1969 if (IsDeviceStarted(DeviceInfoData
->DevInst
,
1973 dap
->DeviceStarted
= bFlag
;
1976 /* enable/disable the device usage controls */
1977 EnableWindow(GetDlgItem(hwndDlg
,
1979 dap
->CanDisable
&& dap
->IsAdmin
);
1980 EnableWindow(hDevUsage
,
1981 dap
->CanDisable
&& dap
->IsAdmin
);
1983 /* clear the combobox */
1984 SendMessage(hDevUsage
,
1988 if (dap
->CanDisable
)
1990 InitDevUsageActions(hwndDlg
,
1995 /* find out how many new device property sheets to add.
1996 fake a PROPSHEETHEADER structure, we don't plan to
1997 call PropertySheet again!*/
1998 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2002 /* get the number of device property sheets for the device */
2003 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2008 dap
->PropertySheetType
) &&
2009 nDriverPages
!= 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
2011 dap
->nDevPropSheets
+= nDriverPages
;
2018 /* include the driver page */
2019 if (dap
->HasDriverPage
)
2020 dap
->nDevPropSheets
++;
2022 /* include the details page */
2024 dap
->nDevPropSheets
++;
2026 /* add the device property sheets */
2027 if (dap
->nDevPropSheets
!= 0)
2029 dap
->DevPropSheets
= HeapAlloc(GetProcessHeap(),
2031 dap
->nDevPropSheets
* sizeof(HPROPSHEETPAGE
));
2032 if (dap
->DevPropSheets
!= NULL
)
2034 if (nDriverPages
!= 0)
2036 psh
.phpage
= dap
->DevPropSheets
;
2038 /* query the device property sheet pages to add */
2039 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2042 dap
->nDevPropSheets
,
2044 dap
->PropertySheetType
))
2046 /* add the property sheets */
2048 iPage
!= nDriverPages
;
2051 if (PropSheet_AddPage(hPropSheetDlg
,
2052 dap
->DevPropSheets
[iPage
]))
2058 dap
->FreeDevPropSheets
= TRUE
;
2062 /* cleanup, we were unable to get the device property sheets */
2063 iPage
= nDriverPages
;
2064 dap
->nDevPropSheets
-= nDriverPages
;
2071 /* add the driver page if necessary */
2072 if (dap
->HasDriverPage
)
2074 PROPSHEETPAGE pspDriver
= {0};
2075 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2076 pspDriver
.dwFlags
= PSP_DEFAULT
;
2077 pspDriver
.hInstance
= hDllInstance
;
2078 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDRIVER
);
2079 pspDriver
.pfnDlgProc
= AdvProcDriverDlgProc
;
2080 pspDriver
.lParam
= (LPARAM
)dap
;
2081 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2082 if (dap
->DevPropSheets
[iPage
] != NULL
)
2084 if (PropSheet_AddPage(hPropSheetDlg
,
2085 dap
->DevPropSheets
[iPage
]))
2092 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2093 dap
->DevPropSheets
[iPage
] = NULL
;
2100 /* Add the details page */
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
;
2124 /* 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);
2451 DevAdvPropInfo
->Extended
= ((dwFlags
& DPF_EXTENDED
) != 0);
2453 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2454 psh
.dwFlags
= PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
2455 psh
.hwndParent
= hWndParent
;
2456 psh
.pszCaption
= DevAdvPropInfo
->szDevName
;
2458 DevAdvPropInfo
->PropertySheetType
= DevAdvPropInfo
->ShowRemotePages
?
2459 DIGCDP_FLAG_REMOTE_ADVANCED
:
2460 DIGCDP_FLAG_ADVANCED
;
2462 psh
.phpage
= HeapAlloc(GetProcessHeap(),
2464 1 * sizeof(HPROPSHEETPAGE
));
2465 if (psh
.phpage
== NULL
)
2470 /* add the "General" property sheet */
2471 pspGeneral
.dwSize
= sizeof(PROPSHEETPAGE
);
2472 pspGeneral
.dwFlags
= PSP_DEFAULT
;
2473 pspGeneral
.hInstance
= hDllInstance
;
2474 pspGeneral
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEGENERAL
);
2475 pspGeneral
.pfnDlgProc
= AdvPropGeneralDlgProc
;
2476 pspGeneral
.lParam
= (LPARAM
)DevAdvPropInfo
;
2477 psh
.phpage
[psh
.nPages
] = pCreatePropertySheetPageW(&pspGeneral
);
2478 if (psh
.phpage
[psh
.nPages
] != NULL
)
2483 DevAdvPropInfo
->nDevPropSheets
= psh
.nPages
;
2485 if (psh
.nPages
!= 0)
2487 Ret
= pPropertySheetW(&psh
);
2489 /* NOTE: no need to destroy the property sheets anymore! */
2496 /* in case of failure the property sheets must be destroyed */
2497 if (psh
.phpage
!= NULL
)
2503 if (psh
.phpage
[i
] != NULL
)
2505 pDestroyPropertySheetPage(psh
.phpage
[i
]);
2511 if (DevAdvPropInfo
!= NULL
)
2513 if (DevAdvPropInfo
->FreeDevPropSheets
)
2515 /* don't free the array if it's the one allocated in
2516 DisplayDeviceAdvancedProperties */
2517 HeapFree(GetProcessHeap(),
2519 DevAdvPropInfo
->DevPropSheets
);
2522 if (DevAdvPropInfo
->CloseDevInst
)
2524 /* close the device info set in case a new one was created */
2525 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->DeviceInfoSet
);
2528 if (DevAdvPropInfo
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
2530 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->CurrentDeviceInfoSet
);
2533 if (DevAdvPropInfo
->hDevIcon
!= NULL
)
2535 DestroyIcon(DevAdvPropInfo
->hDevIcon
);
2538 HeapFree(GetProcessHeap(),
2543 if (psh
.phpage
!= NULL
)
2545 HeapFree(GetProcessHeap(),
2550 if (hMachine
!= NULL
)
2552 CM_Disconnect_Machine(hMachine
);
2560 GetDeviceAndComputerName(LPWSTR lpString
,
2562 WCHAR szMachineName
[])
2566 szDeviceID
[0] = L
'\0';
2567 szMachineName
[0] = L
'\0';
2569 while (*lpString
!= L
'\0')
2571 if (*lpString
== L
'/')
2574 if(!_wcsnicmp(lpString
, L
"DeviceID", 8))
2577 if (*lpString
!= L
'\0')
2580 while ((*lpString
!= L
' ') &&
2581 (*lpString
!= L
'\0') &&
2582 (i
<= MAX_DEVICE_ID_LEN
))
2584 szDeviceID
[i
++] = *lpString
++;
2586 szDeviceID
[i
] = L
'\0';
2590 else if (!_wcsnicmp(lpString
, L
"MachineName", 11))
2593 if (*lpString
!= L
'\0')
2596 while ((*lpString
!= L
' ') &&
2597 (*lpString
!= L
'\0') &&
2598 (i
<= MAX_COMPUTERNAME_LENGTH
))
2600 szMachineName
[i
++] = *lpString
++;
2602 szMachineName
[i
] = L
'\0';
2605 /* knock the pointer back one and let the next
2606 * pointer deal with incrementing, otherwise we
2607 * go past the end of the string */
2617 /***************************************************************************
2619 * DeviceAdvancedPropertiesW
2622 * Invokes the device properties dialog, this version may add some property pages
2626 * hWndParent: Handle to the parent window
2627 * lpMachineName: Machine Name, NULL is the local machine
2628 * lpDeviceID: Specifies the device whose properties are to be shown
2631 * Always returns -1, a call to GetLastError returns 0 if successful
2637 DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL
,
2638 IN LPCWSTR lpMachineName OPTIONAL
,
2639 IN LPCWSTR lpDeviceID
)
2642 SP_DEVINFO_DATA DevInfoData
;
2643 HINSTANCE hComCtl32
;
2646 if (lpDeviceID
== NULL
)
2648 SetLastError(ERROR_INVALID_PARAMETER
);
2652 /* dynamically load comctl32 */
2653 hComCtl32
= LoadAndInitComctl32();
2654 if (hComCtl32
!= NULL
)
2656 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2660 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2662 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2663 if (SetupDiOpenDeviceInfo(hDevInfo
,
2669 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2678 SetupDiDestroyDeviceInfoList(hDevInfo
);
2681 FreeLibrary(hComCtl32
);
2688 /***************************************************************************
2690 * DeviceAdvancedPropertiesA
2693 * Invokes the device properties dialog, this version may add some property pages
2697 * hWndParent: Handle to the parent window
2698 * lpMachineName: Machine Name, NULL is the local machine
2699 * lpDeviceID: Specifies the device whose properties are to be shown
2702 * Always returns -1, a call to GetLastError returns 0 if successful
2708 DeviceAdvancedPropertiesA(IN HWND hWndParent OPTIONAL
,
2709 IN LPCSTR lpMachineName OPTIONAL
,
2710 IN LPCSTR lpDeviceID
)
2712 LPWSTR lpMachineNameW
= NULL
;
2713 LPWSTR lpDeviceIDW
= NULL
;
2716 if (lpMachineName
!= NULL
)
2718 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2724 if (lpDeviceID
!= NULL
)
2726 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2733 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
2738 if (lpMachineNameW
!= NULL
)
2740 HeapFree(GetProcessHeap(),
2744 if (lpDeviceIDW
!= NULL
)
2746 HeapFree(GetProcessHeap(),
2755 /***************************************************************************
2757 * DevicePropertiesExA
2760 * Invokes the extended device properties dialog
2763 * hWndParent: Handle to the parent window
2764 * lpMachineName: Machine Name, NULL is the local machine
2765 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2766 * bShowDevMgr is nonzero
2767 * dwFlags: This parameter can be a combination of the following flags:
2768 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2769 * the default device status action button
2770 * to be clicked (Troubleshoot, Enable
2772 * bShowDevMgr: If non-zero it displays the device manager instead of
2773 * the advanced device property dialog
2776 * 1: if bShowDevMgr is non-zero and no error occured
2777 * -1: a call to GetLastError returns 0 if successful
2783 DevicePropertiesExA(IN HWND hWndParent OPTIONAL
,
2784 IN LPCSTR lpMachineName OPTIONAL
,
2785 IN LPCSTR lpDeviceID OPTIONAL
,
2786 IN DWORD dwFlags OPTIONAL
,
2787 IN BOOL bShowDevMgr
)
2789 LPWSTR lpMachineNameW
= NULL
;
2790 LPWSTR lpDeviceIDW
= NULL
;
2793 if (lpMachineName
!= NULL
)
2795 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2801 if (lpDeviceID
!= NULL
)
2803 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2810 Ret
= DevicePropertiesExW(hWndParent
,
2817 if (lpMachineNameW
!= NULL
)
2819 HeapFree(GetProcessHeap(),
2823 if (lpDeviceIDW
!= NULL
)
2825 HeapFree(GetProcessHeap(),
2834 /***************************************************************************
2836 * DevicePropertiesExW
2839 * Invokes the extended device properties dialog
2842 * hWndParent: Handle to the parent window
2843 * lpMachineName: Machine Name, NULL is the local machine
2844 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2845 * bShowDevMgr is nonzero
2846 * dwFlags: This parameter can be a combination of the following flags:
2847 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2848 * the default device status action button
2849 * to be clicked (Troubleshoot, Enable
2851 * bShowDevMgr: If non-zero it displays the device manager instead of
2852 * the advanced device property dialog
2855 * 1: if bShowDevMgr is non-zero and no error occured
2856 * -1: a call to GetLastError returns 0 if successful
2862 DevicePropertiesExW(IN HWND hWndParent OPTIONAL
,
2863 IN LPCWSTR lpMachineName OPTIONAL
,
2864 IN LPCWSTR lpDeviceID OPTIONAL
,
2865 IN DWORD dwFlags OPTIONAL
,
2866 IN BOOL bShowDevMgr
)
2870 if (dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
))
2872 DPRINT1("DevPropertiesExW: Invalid flags: 0x%x\n",
2873 dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
));
2874 SetLastError(ERROR_INVALID_FLAGS
);
2880 DPRINT("DevPropertiesExW doesn't support bShowDevMgr!\n");
2881 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2886 SP_DEVINFO_DATA DevInfoData
;
2887 HINSTANCE hComCtl32
;
2889 if (lpDeviceID
== NULL
)
2891 SetLastError(ERROR_INVALID_PARAMETER
);
2895 /* dynamically load comctl32 */
2896 hComCtl32
= LoadAndInitComctl32();
2897 if (hComCtl32
!= NULL
)
2899 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2903 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2905 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2906 if (SetupDiOpenDeviceInfo(hDevInfo
,
2912 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2921 SetupDiDestroyDeviceInfoList(hDevInfo
);
2924 FreeLibrary(hComCtl32
);
2932 /***************************************************************************
2937 * Invokes the device properties dialog directly
2940 * hWndParent: Handle to the parent window
2941 * lpMachineName: Machine Name, NULL is the local machine
2942 * lpDeviceID: Specifies the device whose properties are to be shown
2943 * bShowDevMgr: If non-zero it displays the device manager instead of
2944 * the device property dialog
2947 * >=0: if no errors occured
2948 * -1: if errors occured
2956 DevicePropertiesA(HWND hWndParent
,
2957 LPCSTR lpMachineName
,
2961 return DevicePropertiesExA(hWndParent
,
2969 /***************************************************************************
2974 * Invokes the device properties dialog directly
2977 * hWndParent: Handle to the parent window
2978 * lpMachineName: Machine Name, NULL is the local machine
2979 * lpDeviceID: Specifies the device whose properties are to be shown
2980 * bShowDevMgr: If non-zero it displays the device manager instead of
2981 * the device property dialog
2984 * >=0: if no errors occured
2985 * -1: if errors occured
2993 DevicePropertiesW(HWND hWndParent
,
2994 LPCWSTR lpMachineName
,
2998 return DevicePropertiesExW(hWndParent
,
3006 /***************************************************************************
3008 * DeviceProperties_RunDLLA
3011 * Invokes the device properties dialog
3014 * hWndParent: Handle to the parent window
3015 * hInst: Handle to the application instance
3016 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3018 * nCmdShow: Specifies how the window should be shown
3025 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3026 * (/MachineName is optional). This function only parses this string and eventually
3027 * calls DeviceProperties().
3033 DeviceProperties_RunDLLA(HWND hWndParent
,
3038 LPWSTR lpDeviceCmdW
= NULL
;
3040 if (lpDeviceCmd
!= NULL
)
3042 if ((lpDeviceCmdW
= ConvertMultiByteToUnicode(lpDeviceCmd
,
3045 DeviceProperties_RunDLLW(hWndParent
,
3052 if (lpDeviceCmdW
!= NULL
)
3054 HeapFree(GetProcessHeap(),
3061 /***************************************************************************
3063 * DeviceProperties_RunDLLW
3066 * Invokes the device properties dialog
3069 * hWndParent: Handle to the parent window
3070 * hInst: Handle to the application instance
3071 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3073 * nCmdShow: Specifies how the window should be shown
3080 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3081 * (/MachineName is optional). This function only parses this string and eventually
3082 * calls DeviceProperties().
3088 DeviceProperties_RunDLLW(HWND hWndParent
,
3090 LPCWSTR lpDeviceCmd
,
3093 WCHAR szDeviceID
[MAX_DEVICE_ID_LEN
+1];
3094 WCHAR szMachineName
[MAX_COMPUTERNAME_LENGTH
+1];
3095 LPWSTR lpString
= (LPWSTR
)lpDeviceCmd
;
3097 if (!GetDeviceAndComputerName(lpString
,
3101 DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID
, szMachineName
);
3105 DevicePropertiesW(hWndParent
,