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>
34 typedef INT_PTR (WINAPI
*PPROPERTYSHEETW
)(LPCPROPSHEETHEADERW
);
35 typedef HPROPSHEETPAGE (WINAPI
*PCREATEPROPERTYSHEETPAGEW
)(LPCPROPSHEETPAGEW
);
36 typedef BOOL (WINAPI
*PDESTROYPROPERTYSHEETPAGE
)(HPROPSHEETPAGE
);
38 typedef struct _DEVADVPROP_INFO
42 WNDPROC ParentOldWndProc
;
45 HDEVINFO DeviceInfoSet
;
46 SP_DEVINFO_DATA DeviceInfoData
;
47 HDEVINFO CurrentDeviceInfoSet
;
48 SP_DEVINFO_DATA CurrentDeviceInfoData
;
49 DEVINST ParentDevInst
;
51 LPCWSTR lpMachineName
;
54 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
55 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
57 DWORD PropertySheetType
;
59 HPROPSHEETPAGE
*DevPropSheets
;
67 UINT FreeDevPropSheets
: 1;
69 UINT DeviceStarted
: 1;
70 UINT DeviceUsageChanged
: 1;
71 UINT CloseDevInst
: 1;
73 UINT DoDefaultDevAction
: 1;
74 UINT PageInitialized
: 1;
75 UINT ShowRemotePages
: 1;
76 UINT HasDriverPage
: 1;
77 UINT HasResourcePage
: 1;
78 UINT HasPowerPage
: 1;
85 /* struct may be dynamically expanded here! */
86 } DEVADVPROP_INFO
, *PDEVADVPROP_INFO
;
89 typedef struct _ENUMDRIVERFILES_CONTEXT
91 HWND hDriversListView
;
93 } ENUMDRIVERFILES_CONTEXT
, *PENUMDRIVERFILES_CONTEXT
;
95 #define PM_INITIALIZE (WM_APP + 0x101)
99 EnumDeviceDriverFilesCallback(IN PVOID Context
,
100 IN UINT Notification
,
105 PENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
= (PENUMDRIVERFILES_CONTEXT
)Context
;
107 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
108 li
.iItem
= EnumDriverFilesContext
->nCount
++;
110 li
.state
= (li
.iItem
== 0 ? LVIS_SELECTED
: 0);
111 li
.stateMask
= LVIS_SELECTED
;
112 li
.pszText
= (LPWSTR
)Param1
;
113 (void)ListView_InsertItem(EnumDriverFilesContext
->hDriversListView
,
120 UpdateDriverDetailsDlg(IN HWND hwndDlg
,
121 IN HWND hDriversListView
,
122 IN PDEVADVPROP_INFO dap
)
124 HDEVINFO DeviceInfoSet
;
125 PSP_DEVINFO_DATA DeviceInfoData
;
126 SP_DRVINFO_DATA DriverInfoData
;
127 ENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
;
129 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
131 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
132 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
136 DeviceInfoSet
= dap
->DeviceInfoSet
;
137 DeviceInfoData
= &dap
->DeviceInfoData
;
140 /* set the device image */
141 SendDlgItemMessage(hwndDlg
,
144 (WPARAM
)dap
->hDevIcon
,
147 /* set the device name edit control text */
148 SetDlgItemText(hwndDlg
,
152 /* fill the driver files list view */
153 EnumDriverFilesContext
.hDriversListView
= hDriversListView
;
154 EnumDriverFilesContext
.nCount
= 0;
156 (void)ListView_DeleteAllItems(EnumDriverFilesContext
.hDriversListView
);
157 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA
);
158 if (FindCurrentDriver(DeviceInfoSet
,
161 SetupDiSetSelectedDriver(DeviceInfoSet
,
165 HSPFILEQ queueHandle
;
167 queueHandle
= SetupOpenFileQueue();
168 if (queueHandle
!= (HSPFILEQ
)INVALID_HANDLE_VALUE
)
170 SP_DEVINSTALL_PARAMS DeviceInstallParams
= {0};
171 DeviceInstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS
);
172 if (SetupDiGetDeviceInstallParams(DeviceInfoSet
,
174 &DeviceInstallParams
))
176 DeviceInstallParams
.FileQueue
= queueHandle
;
177 DeviceInstallParams
.Flags
|= DI_NOVCP
;
179 if (SetupDiSetDeviceInstallParams(DeviceInfoSet
,
181 &DeviceInstallParams
) &&
182 SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES
,
190 /* enumerate the driver files */
191 SetupScanFileQueue(queueHandle
,
192 SPQ_SCAN_USE_CALLBACK
,
194 EnumDeviceDriverFilesCallback
,
195 &EnumDriverFilesContext
,
198 /* update the list view column width */
199 GetClientRect(hDriversListView
,
201 lvc
.mask
= LVCF_WIDTH
;
202 lvc
.cx
= rcClient
.right
;
203 (void)ListView_SetColumn(hDriversListView
,
207 /* highlight the first item from list */
208 if (ListView_GetSelectedCount(hDriversListView
) != 0)
210 ListView_SetItemState(hDriversListView
,
212 LVIS_FOCUSED
| LVIS_SELECTED
,
213 LVIS_FOCUSED
| LVIS_SELECTED
);
218 SetupCloseFileQueue(queueHandle
);
225 UpdateDriverVersionInfoDetails(IN HWND hwndDlg
,
226 IN LPCWSTR lpszDriverPath
)
230 LPVOID lpData
= NULL
;
234 WCHAR szLangInfo
[255];
235 WCHAR szLangPath
[MAX_PATH
];
236 LPWSTR lpCompanyName
= NULL
;
237 LPWSTR lpFileVersion
= NULL
;
238 LPWSTR lpLegalCopyright
= NULL
;
239 LPWSTR lpDigitalSigner
= NULL
;
241 WCHAR szNotAvailable
[255];
243 /* extract version info from selected file */
244 dwVerInfoSize
= GetFileVersionInfoSize(lpszDriverPath
,
249 lpData
= HeapAlloc(GetProcessHeap(),
255 if (!GetFileVersionInfo(lpszDriverPath
,
261 if (!VerQueryValue(lpData
,
262 L
"\\VarFileInfo\\Translation",
267 dwLangId
= *(LPDWORD
)lpInfo
;
268 swprintf(szLangInfo
, L
"\\StringFileInfo\\%04x%04x\\",
269 LOWORD(dwLangId
), HIWORD(dwLangId
));
271 /* read CompanyName */
272 wcscpy(szLangPath
, szLangInfo
);
273 wcscat(szLangPath
, L
"CompanyName");
275 VerQueryValue(lpData
,
277 (void **)&lpCompanyName
,
280 /* read FileVersion */
281 wcscpy(szLangPath
, szLangInfo
);
282 wcscat(szLangPath
, L
"FileVersion");
284 VerQueryValue(lpData
,
286 (void **)&lpFileVersion
,
289 /* read LegalTrademarks */
290 wcscpy(szLangPath
, szLangInfo
);
291 wcscat(szLangPath
, L
"LegalCopyright");
293 VerQueryValue(lpData
,
295 (void **)&lpLegalCopyright
,
298 /* TODO: read digital signer info */
301 if (!LoadString(hDllInstance
,
304 sizeof(szNotAvailable
) / sizeof(WCHAR
)))
306 wcscpy(szNotAvailable
, L
"n/a");
311 lpCompanyName
= szNotAvailable
;
312 SetDlgItemText(hwndDlg
,
317 lpFileVersion
= szNotAvailable
;
318 SetDlgItemText(hwndDlg
,
322 if (!lpLegalCopyright
)
323 lpLegalCopyright
= szNotAvailable
;
324 SetDlgItemText(hwndDlg
,
328 if (!lpDigitalSigner
)
329 lpDigitalSigner
= szNotAvailable
;
330 SetDlgItemText(hwndDlg
,
334 /* release version info */
336 HeapFree(GetProcessHeap(),
344 DriverDetailsDlgProc(IN HWND hwndDlg
,
349 PDEVADVPROP_INFO dap
;
352 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
355 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
361 switch (LOWORD(wParam
))
384 HWND hDriversListView
;
386 dap
= (PDEVADVPROP_INFO
)lParam
;
389 SetWindowLongPtr(hwndDlg
,
393 hDriversListView
= GetDlgItem(hwndDlg
,
396 /* add a column to the list view control */
397 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
398 lvc
.fmt
= LVCFMT_LEFT
;
400 (void)ListView_InsertColumn(hDriversListView
,
404 UpdateDriverDetailsDlg(hwndDlg
,
415 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
417 switch (pnmhdr
->code
)
419 case LVN_ITEMCHANGED
:
421 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
422 HWND hDriversListView
= GetDlgItem(hwndDlg
,
425 if (ListView_GetSelectedCount(hDriversListView
) == 0)
427 /* nothing is selected - empty the labels */
428 SetDlgItemText(hwndDlg
,
431 SetDlgItemText(hwndDlg
,
434 SetDlgItemText(hwndDlg
,
437 SetDlgItemText(hwndDlg
,
441 else if (pnmv
->uNewState
!= 0)
443 /* extract version info and update the labels */
444 WCHAR szDriverPath
[MAX_PATH
];
446 ListView_GetItemText(hDriversListView
,
452 UpdateDriverVersionInfoDetails(hwndDlg
,
467 UpdateDriverDlg(IN HWND hwndDlg
,
468 IN PDEVADVPROP_INFO dap
)
470 HDEVINFO DeviceInfoSet
;
471 PSP_DEVINFO_DATA DeviceInfoData
;
473 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
475 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
476 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
480 DeviceInfoSet
= dap
->DeviceInfoSet
;
481 DeviceInfoData
= &dap
->DeviceInfoData
;
484 /* set the device image */
485 SendDlgItemMessage(hwndDlg
,
488 (WPARAM
)dap
->hDevIcon
,
491 /* set the device name edit control text */
492 SetDlgItemText(hwndDlg
,
496 /* query the driver provider */
497 if (GetDriverProviderString(DeviceInfoSet
,
500 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
502 SetDlgItemText(hwndDlg
,
507 /* query the driver date */
508 if (GetDriverDateString(DeviceInfoSet
,
511 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
513 SetDlgItemText(hwndDlg
,
518 /* query the driver version */
519 if (GetDriverVersionString(DeviceInfoSet
,
522 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
524 SetDlgItemText(hwndDlg
,
533 AdvProcDriverDlgProc(IN HWND hwndDlg
,
538 PDEVADVPROP_INFO dap
;
541 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
544 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
550 switch (LOWORD(wParam
))
552 case IDC_DRIVERDETAILS
:
554 DialogBoxParam(hDllInstance
,
555 MAKEINTRESOURCE(IDD_DRIVERDETAILS
),
557 DriverDetailsDlgProc
,
561 case IDC_UPDATEDRIVER
:
563 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
566 if (DiShowUpdateDevice(hwndDlg
, dap
->CurrentDeviceInfoSet
, &dap
->CurrentDeviceInfoData
, 0, &NeedReboot
))
570 //FIXME: load text from resource file
571 if(MessageBoxW(hwndDlg
, L
"Reboot now?", L
"Reboot required", MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
574 TOKEN_PRIVILEGES Privileges
;
576 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
578 DPRINT("OpenProcessToken failed\n");
582 /* Get the LUID for the Shutdown privilege */
583 if (!LookupPrivilegeValueW(NULL
, SE_SHUTDOWN_NAME
, &Privileges
.Privileges
[0].Luid
))
585 DPRINT("LookupPrivilegeValue failed\n");
589 /* Assign the Shutdown privilege to our process */
590 Privileges
.PrivilegeCount
= 1;
591 Privileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
593 if (!AdjustTokenPrivileges(hToken
, FALSE
, &Privileges
, 0, NULL
, NULL
))
595 DPRINT("AdjustTokenPrivileges failed\n");
599 /* Finally shut down the system */
600 if(!ExitWindowsEx(EWX_REBOOT
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
| SHTDN_REASON_FLAG_PLANNED
))
602 DPRINT("ExitWindowsEx failed\n");
617 NMHDR
*hdr
= (NMHDR
*)lParam
;
628 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
631 SetWindowLongPtr(hwndDlg
,
635 UpdateDriverDlg(hwndDlg
,
649 SetListViewText(HWND hwnd
,
655 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
658 li
.state
= 0; //(li.iItem == 0 ? LVIS_SELECTED : 0);
659 li
.stateMask
= LVIS_SELECTED
;
661 (void)ListView_InsertItem(hwnd
,
667 UpdateDetailsDlg(IN HWND hwndDlg
,
668 IN PDEVADVPROP_INFO dap
)
679 IDS_PROP_HARDWAREIDS
,
680 IDS_PROP_COMPATIBLEIDS
,
681 IDS_PROP_MATCHINGDEVICEID
,
684 IDS_PROP_CAPABILITIES
,
685 IDS_PROP_DEVNODEFLAGS
,
686 IDS_PROP_CONFIGFLAGS
,
687 IDS_PROP_CSCONFIGFLAGS
,
688 IDS_PROP_EJECTIONRELATIONS
,
689 IDS_PROP_REMOVALRELATIONS
,
690 IDS_PROP_BUSRELATIONS
,
691 IDS_PROP_DEVUPPERFILTERS
,
692 IDS_PROP_DEVLOWERFILTERS
,
693 IDS_PROP_CLASSUPPERFILTERS
,
694 IDS_PROP_CLASSLOWERFILTERS
,
695 IDS_PROP_CLASSINSTALLER
,
696 IDS_PROP_CLASSCOINSTALLER
,
697 IDS_PROP_DEVICECOINSTALLER
,
698 IDS_PROP_FIRMWAREREVISION
,
699 IDS_PROP_CURRENTPOWERSTATE
,
700 IDS_PROP_POWERCAPABILITIES
,
701 IDS_PROP_POWERSTATEMAPPINGS
705 /* set the device image */
706 SendDlgItemMessage(hwndDlg
,
709 (WPARAM
)dap
->hDevIcon
,
712 /* set the device name edit control text */
713 SetDlgItemText(hwndDlg
,
718 hwndComboBox
= GetDlgItem(hwndDlg
,
719 IDC_DETAILSPROPNAME
);
721 hwndListView
= GetDlgItem(hwndDlg
,
722 IDC_DETAILSPROPVALUE
);
724 for (i
= 0; i
!= sizeof(Properties
) / sizeof(Properties
[0]); i
++)
726 /* fill in the device usage combo box */
727 if (LoadString(hDllInstance
,
730 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
732 SendMessage(hwndComboBox
,
735 (LPARAM
)dap
->szTemp
);
740 GetClientRect(hwndListView
,
743 /* add a column to the list view control */
744 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
745 lvc
.fmt
= LVCFMT_LEFT
;
746 lvc
.cx
= rcClient
.right
;
747 (void)ListView_InsertColumn(hwndListView
,
751 SendMessage(hwndComboBox
,
756 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
758 SetFocus(hwndComboBox
);
763 DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap
,
764 IN HWND hwndListView
,
767 HDEVINFO DeviceInfoSet
;
768 PSP_DEVINFO_DATA DeviceInfoData
;
777 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
779 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
780 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
784 DeviceInfoSet
= dap
->DeviceInfoSet
;
785 DeviceInfoData
= &dap
->DeviceInfoData
;
789 SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
798 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
800 swprintf(dap
->szTemp
, L
"Error: Getting the size failed! (Error: %ld)", GetLastError());
801 SetListViewText(hwndListView
, 0, dap
->szTemp
);
806 lpBuffer
= HeapAlloc(GetProcessHeap(),
809 if (lpBuffer
== NULL
)
811 SetListViewText(hwndListView
, 0, L
"Error: Allocating the buffer failed!");
815 if (SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
823 if (dwType
== REG_SZ
)
825 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
827 else if (dwType
== REG_MULTI_SZ
)
829 lpStr
= (LPWSTR
)lpBuffer
;
833 len
= wcslen(lpStr
) + 1;
835 SetListViewText(hwndListView
, index
, lpStr
);
841 else if (dwType
== REG_DWORD
)
843 dwValue
= *(DWORD
*) lpBuffer
;
847 case SPDRP_CAPABILITIES
:
849 if (dwValue
& CM_DEVCAP_LOCKSUPPORTED
)
850 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_LOCKSUPPORTED");
851 if (dwValue
& CM_DEVCAP_EJECTSUPPORTED
)
852 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_EJECTSUPPORTED");
853 if (dwValue
& CM_DEVCAP_REMOVABLE
)
854 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_REMOVABLE");
855 if (dwValue
& CM_DEVCAP_DOCKDEVICE
)
856 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_DOCKDEVICE");
857 if (dwValue
& CM_DEVCAP_UNIQUEID
)
858 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_UNIQUEID");
859 if (dwValue
& CM_DEVCAP_SILENTINSTALL
)
860 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SILENTINSTALL");
861 if (dwValue
& CM_DEVCAP_RAWDEVICEOK
)
862 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_RAWDEVICEOK");
863 if (dwValue
& CM_DEVCAP_SURPRISEREMOVALOK
)
864 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SURPRISEREMOVALOK");
865 if (dwValue
& CM_DEVCAP_HARDWAREDISABLED
)
866 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_HARDWAREDISABLED");
867 if (dwValue
& CM_DEVCAP_NONDYNAMIC
)
868 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_NONDYNAMIC");
871 case SPDRP_CONFIGFLAGS
:
873 if (dwValue
& CONFIGFLAG_DISABLED
)
874 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_DISABLED");
875 if (dwValue
& CONFIGFLAG_REMOVED
)
876 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REMOVED");
877 if (dwValue
& CONFIGFLAG_MANUAL_INSTALL
)
878 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_MANUAL_INSTALL");
879 if (dwValue
& CONFIGFLAG_IGNORE_BOOT_LC
)
880 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_IGNORE_BOOT_LC");
881 if (dwValue
& CONFIGFLAG_NET_BOOT
)
882 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NET_BOOT");
883 if (dwValue
& CONFIGFLAG_REINSTALL
)
884 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REINSTALL");
885 if (dwValue
& CONFIGFLAG_FAILEDINSTALL
)
886 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_FAILEDINSTALL");
887 if (dwValue
& CONFIGFLAG_CANTSTOPACHILD
)
888 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_CANTSTOPACHILD");
889 if (dwValue
& CONFIGFLAG_OKREMOVEROM
)
890 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_OKREMOVEROM");
891 if (dwValue
& CONFIGFLAG_NOREMOVEEXIT
)
892 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NOREMOVEEXIT");
896 swprintf(dap
->szTemp
, L
"0x%08lx", dwValue
);
897 SetListViewText(hwndListView
, 0, dap
->szTemp
);
903 SetListViewText(hwndListView
, 0, L
"Error: Unsupported value type!");
909 SetListViewText(hwndListView
, 0, L
"Error: Retrieving the value failed!");
912 HeapFree(GetProcessHeap(),
918 DisplayDevNodeFlags(IN PDEVADVPROP_INFO dap
,
919 IN HWND hwndListView
)
925 CM_Get_DevNode_Status_Ex(&dwStatus
,
927 dap
->DeviceInfoData
.DevInst
,
932 if (dwStatus
& DN_ROOT_ENUMERATED
)
933 SetListViewText(hwndListView
, index
++, L
"DN_ROOT_ENUMERATED");
934 if (dwStatus
& DN_DRIVER_LOADED
)
935 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_LOADED");
936 if (dwStatus
& DN_ENUM_LOADED
)
937 SetListViewText(hwndListView
, index
++, L
"DN_ENUM_LOADED");
938 if (dwStatus
& DN_STARTED
)
939 SetListViewText(hwndListView
, index
++, L
"DN_STARTED");
940 if (dwStatus
& DN_MANUAL
)
941 SetListViewText(hwndListView
, index
++, L
"DN_MANUAL");
942 if (dwStatus
& DN_NEED_TO_ENUM
)
943 SetListViewText(hwndListView
, index
++, L
"DN_NEED_TO_ENUM");
944 if (dwStatus
& DN_DRIVER_BLOCKED
)
945 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_BLOCKED");
946 if (dwStatus
& DN_HARDWARE_ENUM
)
947 SetListViewText(hwndListView
, index
++, L
"DN_HARDWARE_ENUM");
948 if (dwStatus
& DN_NEED_RESTART
)
949 SetListViewText(hwndListView
, index
++, L
"DN_NEED_RESTART");
950 if (dwStatus
& DN_CHILD_WITH_INVALID_ID
)
951 SetListViewText(hwndListView
, index
++, L
"DN_CHILD_WITH_INVALID_ID");
952 if (dwStatus
& DN_HAS_PROBLEM
)
953 SetListViewText(hwndListView
, index
++, L
"DN_HAS_PROBLEM");
954 if (dwStatus
& DN_FILTERED
)
955 SetListViewText(hwndListView
, index
++, L
"DN_FILTERED");
956 if (dwStatus
& DN_LEGACY_DRIVER
)
957 SetListViewText(hwndListView
, index
++, L
"DN_LEGACY_DRIVER");
958 if (dwStatus
& DN_DISABLEABLE
)
959 SetListViewText(hwndListView
, index
++, L
"DN_DISABLEABLE");
960 if (dwStatus
& DN_REMOVABLE
)
961 SetListViewText(hwndListView
, index
++, L
"DN_REMOVABLE");
962 if (dwStatus
& DN_PRIVATE_PROBLEM
)
963 SetListViewText(hwndListView
, index
++, L
"DN_PRIVATE_PROBLEM");
964 if (dwStatus
& DN_MF_PARENT
)
965 SetListViewText(hwndListView
, index
++, L
"DN_MF_PARENT");
966 if (dwStatus
& DN_MF_CHILD
)
967 SetListViewText(hwndListView
, index
++, L
"DN_MF_CHILD");
968 if (dwStatus
& DN_WILL_BE_REMOVED
)
969 SetListViewText(hwndListView
, index
++, L
"DN_WILL_BE_REMOVED");
971 if (dwStatus
& DN_NOT_FIRST_TIMEE
)
972 SetListViewText(hwndListView
, index
++, L
"DN_NOT_FIRST_TIMEE");
973 if (dwStatus
& DN_STOP_FREE_RES
)
974 SetListViewText(hwndListView
, index
++, L
"DN_STOP_FREE_RES");
975 if (dwStatus
& DN_REBAL_CANDIDATE
)
976 SetListViewText(hwndListView
, index
++, L
"DN_REBAL_CANDIDATE");
977 if (dwStatus
& DN_BAD_PARTIAL
)
978 SetListViewText(hwndListView
, index
++, L
"DN_BAD_PARTIAL");
979 if (dwStatus
& DN_NT_ENUMERATOR
)
980 SetListViewText(hwndListView
, index
++, L
"DN_NT_ENUMERATOR");
981 if (dwStatus
& DN_NT_DRIVER
)
982 SetListViewText(hwndListView
, index
++, L
"DN_NT_DRIVER");
984 if (dwStatus
& DN_NEEDS_LOCKING
)
985 SetListViewText(hwndListView
, index
++, L
"DN_NEEDS_LOCKING");
986 if (dwStatus
& DN_ARM_WAKEUP
)
987 SetListViewText(hwndListView
, index
++, L
"DN_ARM_WAKEUP");
988 if (dwStatus
& DN_APM_ENUMERATOR
)
989 SetListViewText(hwndListView
, index
++, L
"DN_APM_ENUMERATOR");
990 if (dwStatus
& DN_APM_DRIVER
)
991 SetListViewText(hwndListView
, index
++, L
"DN_APM_DRIVER");
992 if (dwStatus
& DN_SILENT_INSTALL
)
993 SetListViewText(hwndListView
, index
++, L
"DN_SILENT_INSTALL");
994 if (dwStatus
& DN_NO_SHOW_IN_DM
)
995 SetListViewText(hwndListView
, index
++, L
"DN_NO_SHOW_IN_DM");
996 if (dwStatus
& DN_BOOT_LOG_PROB
)
997 SetListViewText(hwndListView
, index
++, L
"DN_BOOT_LOG_PROB");
999 // swprintf(dap->szTemp, L"0x%08x", dwStatus);
1000 // SetListViewText(hwndListView, 0, dap->szTemp);
1005 DisplayDevNodeEnumerator(IN PDEVADVPROP_INFO dap
,
1006 IN HWND hwndListView
)
1008 PSP_DEVINFO_DATA DeviceInfoData
;
1011 WCHAR szBuffer
[256];
1012 DWORD dwSize
= 256 * sizeof(WCHAR
);
1014 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1016 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1020 DeviceInfoData
= &dap
->DeviceInfoData
;
1023 CM_Get_DevNode_Registry_Property_ExW(DeviceInfoData
->DevInst
,
1024 CM_DRP_ENUMERATOR_NAME
,
1031 SetListViewText(hwndListView
, 0, szBuffer
);
1036 DisplayCsFlags(IN PDEVADVPROP_INFO dap
,
1037 IN HWND hwndListView
)
1042 CM_Get_HW_Prof_Flags_Ex(dap
->szDevName
,
1043 0, /* current hardware profile */
1049 if (dwValue
& CSCONFIGFLAG_DISABLED
)
1050 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DISABLED");
1052 if (dwValue
& CSCONFIGFLAG_DO_NOT_CREATE
)
1053 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_CREATE");
1055 if (dwValue
& CSCONFIGFLAG_DO_NOT_START
)
1056 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_START");
1061 DisplayMatchingDeviceId(IN PDEVADVPROP_INFO dap
,
1062 IN HWND hwndListView
)
1064 HDEVINFO DeviceInfoSet
;
1065 PSP_DEVINFO_DATA DeviceInfoData
;
1066 WCHAR szBuffer
[256];
1071 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1073 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1074 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1078 DeviceInfoSet
= dap
->DeviceInfoSet
;
1079 DeviceInfoData
= &dap
->DeviceInfoData
;
1082 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1088 if (hKey
!= INVALID_HANDLE_VALUE
)
1090 dwSize
= 256 * sizeof(WCHAR
);
1091 if (RegQueryValueEx(hKey
,
1092 L
"MatchingDeviceId",
1096 &dwSize
) == ERROR_SUCCESS
)
1098 SetListViewText(hwndListView
, 0, szBuffer
);
1107 DisplayDeviceCoinstallers(IN PDEVADVPROP_INFO dap
,
1108 IN HWND hwndListView
)
1110 HDEVINFO DeviceInfoSet
;
1111 PSP_DEVINFO_DATA DeviceInfoData
;
1120 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1122 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1123 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1127 DeviceInfoSet
= dap
->DeviceInfoSet
;
1128 DeviceInfoData
= &dap
->DeviceInfoData
;
1131 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1137 if (hKey
!= INVALID_HANDLE_VALUE
)
1140 if (RegQueryValueEx(hKey
,
1145 &dwSize
) == ERROR_SUCCESS
&&
1149 lpBuffer
= HeapAlloc(GetProcessHeap(),
1153 RegQueryValueEx(hKey
,
1160 lpStr
= (LPWSTR
)lpBuffer
;
1164 len
= wcslen(lpStr
) + 1;
1166 SetListViewText(hwndListView
, index
, lpStr
);
1172 HeapFree(GetProcessHeap(),
1183 DisplayClassProperties(IN PDEVADVPROP_INFO dap
,
1184 IN HWND hwndListView
,
1185 IN LPWSTR lpProperty
)
1187 HDEVINFO DeviceInfoSet
;
1188 PSP_DEVINFO_DATA DeviceInfoData
;
1189 WCHAR szClassGuid
[45];
1199 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1201 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1202 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1206 DeviceInfoSet
= dap
->DeviceInfoSet
;
1207 DeviceInfoData
= &dap
->DeviceInfoData
;
1210 dwSize
= 45 * sizeof(WCHAR
);
1211 if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
1215 (LPBYTE
)szClassGuid
,
1220 pSetupGuidFromString(szClassGuid
,
1223 hKey
= SetupDiOpenClassRegKey(&ClassGuid
,
1225 if (hKey
!= INVALID_HANDLE_VALUE
)
1228 if (RegQueryValueEx(hKey
,
1233 &dwSize
) == ERROR_SUCCESS
&&
1236 lpBuffer
= HeapAlloc(GetProcessHeap(),
1240 RegQueryValueEx(hKey
,
1247 if (dwType
== REG_SZ
)
1249 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
1251 else if (dwType
== REG_MULTI_SZ
)
1253 lpStr
= (LPWSTR
)lpBuffer
;
1257 len
= wcslen(lpStr
) + 1;
1259 SetListViewText(hwndListView
, index
, lpStr
);
1266 HeapFree(GetProcessHeap(),
1277 DisplayDeviceProperties(IN PDEVADVPROP_INFO dap
,
1278 IN HWND hwndComboBox
,
1279 IN HWND hwndListView
)
1283 Index
= (INT
)SendMessage(hwndComboBox
,
1287 if (Index
== CB_ERR
)
1290 (void)ListView_DeleteAllItems(hwndListView
);
1295 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
1298 case 1: /* Hardware ID */
1299 DisplayDevicePropertyText(dap
,
1304 case 2: /* Compatible IDs */
1305 DisplayDevicePropertyText(dap
,
1307 SPDRP_COMPATIBLEIDS
);
1310 case 3: /* Matching ID */
1311 DisplayMatchingDeviceId(dap
,
1315 case 4: /* Service */
1316 DisplayDevicePropertyText(dap
,
1321 case 5: /* Enumerator */
1322 DisplayDevNodeEnumerator(dap
,
1326 case 6: /* Capabilities */
1327 DisplayDevicePropertyText(dap
,
1329 SPDRP_CAPABILITIES
);
1332 case 7: /* Devnode Flags */
1333 DisplayDevNodeFlags(dap
,
1337 case 8: /* Config Flags */
1338 DisplayDevicePropertyText(dap
,
1343 case 9: /* CSConfig Flags */
1349 case 10: /* Ejection relation */
1352 case 11: /* Removal relations */
1355 case 12: /* Bus relation */
1359 case 13: /* Device Upper Filters */
1360 DisplayDevicePropertyText(dap
,
1362 SPDRP_UPPERFILTERS
);
1365 case 14: /* Device Lower Filters */
1366 DisplayDevicePropertyText(dap
,
1368 SPDRP_LOWERFILTERS
);
1371 case 15: /* Class Upper Filters */
1372 DisplayClassProperties(dap
,
1377 case 16: /* Class Lower Filters */
1378 DisplayClassProperties(dap
,
1383 case 17: /* Class Installer */
1384 DisplayClassProperties(dap
,
1390 case 18: /* Class Coinstaller */
1394 case 19: /* Device Coinstaller */
1395 DisplayDeviceCoinstallers(dap
,
1400 case 20: /* Firmware Revision */
1403 case 21: /* Current Power State */
1406 case 20: /* Power Capabilities */
1409 case 21: /* Power State Mappings */
1414 SetListViewText(hwndListView
, 0, L
"<Not implemented yet>");
1422 AdvProcDetailsDlgProc(IN HWND hwndDlg
,
1427 PDEVADVPROP_INFO dap
;
1428 INT_PTR Ret
= FALSE
;
1430 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
1433 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
1439 switch (LOWORD(wParam
))
1441 case IDC_DETAILSPROPNAME
:
1442 if (HIWORD(wParam
) == CBN_SELCHANGE
)
1444 DisplayDeviceProperties(dap
,
1445 GetDlgItem(hwndDlg
, IDC_DETAILSPROPNAME
),
1446 GetDlgItem(hwndDlg
, IDC_DETAILSPROPVALUE
));
1455 NMHDR
*hdr
= (NMHDR
*)lParam
;
1466 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1469 SetWindowLongPtr(hwndDlg
,
1473 UpdateDetailsDlg(hwndDlg
,
1487 InitDevUsageActions(IN HWND hwndDlg
,
1489 IN PDEVADVPROP_INFO dap
)
1500 i
!= sizeof(Actions
) / sizeof(Actions
[0]);
1503 /* fill in the device usage combo box */
1504 if (LoadString(hDllInstance
,
1507 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1509 Index
= (INT
)SendMessage(hComboBox
,
1512 (LPARAM
)dap
->szTemp
);
1513 if (Index
!= CB_ERR
)
1515 SendMessage(hComboBox
,
1518 (LPARAM
)Actions
[i
]);
1522 case IDS_ENABLEDEVICE
:
1523 if (dap
->DeviceStarted
)
1525 SendMessage(hComboBox
,
1532 case IDS_DISABLEDEVICE
:
1533 if (!dap
->DeviceStarted
)
1535 SendMessage(hComboBox
,
1552 GetSelectedUsageAction(IN HWND hComboBox
)
1557 Index
= (INT
)SendMessage(hComboBox
,
1561 if (Index
!= CB_ERR
)
1563 INT iRet
= (INT
) SendMessage(hComboBox
,
1578 ApplyGeneralSettings(IN HWND hwndDlg
,
1579 IN PDEVADVPROP_INFO dap
)
1583 if (dap
->DeviceUsageChanged
&& dap
->IsAdmin
&& dap
->CanDisable
)
1585 UINT SelectedUsageAction
;
1586 BOOL NeedReboot
= FALSE
;
1588 SelectedUsageAction
= GetSelectedUsageAction(GetDlgItem(hwndDlg
,
1590 switch (SelectedUsageAction
)
1592 case IDS_ENABLEDEVICE
:
1593 if (!dap
->DeviceStarted
)
1595 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1596 &dap
->DeviceInfoData
,
1603 case IDS_DISABLEDEVICE
:
1604 if (dap
->DeviceStarted
)
1606 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1607 &dap
->DeviceInfoData
,
1622 /* make PropertySheet() return PSM_REBOOTSYSTEM */
1623 PropSheet_RebootSystem(hwndDlg
);
1628 /* FIXME - display an error message */
1629 DPRINT1("Failed to enable/disable device! LastError: %d\n",
1634 Ret
= !dap
->DeviceUsageChanged
;
1636 /* disable the apply button */
1637 PropSheet_UnChanged(GetParent(hwndDlg
),
1639 dap
->DeviceUsageChanged
= FALSE
;
1645 UpdateDevInfo(IN HWND hwndDlg
,
1646 IN PDEVADVPROP_INFO dap
,
1649 HWND hDevUsage
, hPropSheetDlg
, hDevProbBtn
;
1651 ULONG Status
, ProblemNumber
;
1652 SP_DEVINSTALL_PARAMS_W InstallParams
;
1653 UINT TroubleShootStrId
= IDS_TROUBLESHOOTDEV
;
1654 BOOL bFlag
, bDevActionAvailable
= TRUE
;
1655 BOOL bDrvInstalled
= FALSE
;
1657 HDEVINFO DeviceInfoSet
= NULL
;
1658 PSP_DEVINFO_DATA DeviceInfoData
= NULL
;
1659 PROPSHEETHEADER psh
;
1660 DWORD nDriverPages
= 0;
1661 BOOL RecalcPages
= FALSE
;
1663 hPropSheetDlg
= GetParent(hwndDlg
);
1665 if (dap
->PageInitialized
)
1667 /* switch to the General page */
1668 PropSheet_SetCurSelByID(hPropSheetDlg
,
1671 /* remove and destroy the existing device property sheet pages */
1672 if (dap
->DevPropSheets
!= NULL
)
1675 iPage
!= dap
->nDevPropSheets
;
1678 if (dap
->DevPropSheets
[iPage
] != NULL
)
1680 PropSheet_RemovePage(hPropSheetDlg
,
1682 dap
->DevPropSheets
[iPage
]);
1691 if (dap
->FreeDevPropSheets
)
1693 /* don't free the array if it's the one allocated in
1694 DisplayDeviceAdvancedProperties */
1695 HeapFree(GetProcessHeap(),
1697 dap
->DevPropSheets
);
1699 dap
->FreeDevPropSheets
= FALSE
;
1702 dap
->DevPropSheets
= NULL
;
1703 dap
->nDevPropSheets
= 0;
1707 /* create a new device info set and re-open the device */
1708 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1710 SetupDiDestroyDeviceInfoList(dap
->CurrentDeviceInfoSet
);
1713 dap
->ParentDevInst
= 0;
1714 dap
->CurrentDeviceInfoSet
= SetupDiCreateDeviceInfoListEx(NULL
,
1718 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1720 if (SetupDiOpenDeviceInfo(dap
->CurrentDeviceInfoSet
,
1724 &dap
->CurrentDeviceInfoData
))
1726 if (dap
->CloseDevInst
)
1728 SetupDiDestroyDeviceInfoList(dap
->DeviceInfoSet
);
1731 dap
->CloseDevInst
= TRUE
;
1732 dap
->DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1733 dap
->DeviceInfoData
= dap
->CurrentDeviceInfoData
;
1734 dap
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
1742 /* get the parent node from the initial devinst */
1743 CM_Get_Parent_Ex(&dap
->ParentDevInst
,
1744 dap
->DeviceInfoData
.DevInst
,
1749 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1751 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1752 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1756 DeviceInfoSet
= dap
->DeviceInfoSet
;
1757 DeviceInfoData
= &dap
->DeviceInfoData
;
1762 DeviceInfoSet
= dap
->DeviceInfoSet
;
1763 DeviceInfoData
= &dap
->DeviceInfoData
;
1766 dap
->HasDriverPage
= FALSE
;
1767 dap
->HasResourcePage
= FALSE
;
1768 dap
->HasPowerPage
= FALSE
;
1769 if (IsDriverInstalled(DeviceInfoData
->DevInst
,
1774 if (SetupDiCallClassInstaller((dap
->ShowRemotePages
?
1775 DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
:
1776 DIF_ADDPROPERTYPAGE_ADVANCED
),
1780 /* get install params */
1781 InstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
1782 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet
,
1786 /* zero the flags */
1787 InstallParams
.Flags
= 0;
1790 dap
->HasDriverPage
= !(InstallParams
.Flags
& DI_DRIVERPAGE_ADDED
);
1791 dap
->HasResourcePage
= !(InstallParams
.Flags
& DI_RESOURCEPAGE_ADDED
);
1792 dap
->HasPowerPage
= !(InstallParams
.Flags
& DI_FLAGSEX_POWERPAGE_ADDED
);
1796 /* get the device icon */
1797 if (dap
->hDevIcon
!= NULL
)
1799 DestroyIcon(dap
->hDevIcon
);
1800 dap
->hDevIcon
= NULL
;
1802 if (!SetupDiLoadClassIcon(&DeviceInfoData
->ClassGuid
,
1806 dap
->hDevIcon
= NULL
;
1809 /* get the device name */
1810 if (GetDeviceDescriptionString(DeviceInfoSet
,
1813 sizeof(dap
->szDevName
) / sizeof(dap
->szDevName
[0])))
1815 PropSheet_SetTitle(hPropSheetDlg
,
1820 /* set the device image */
1821 SendDlgItemMessage(hwndDlg
,
1824 (WPARAM
)dap
->hDevIcon
,
1827 /* set the device name edit control text */
1828 SetDlgItemText(hwndDlg
,
1832 /* set the device type edit control text */
1833 if (GetDeviceTypeString(DeviceInfoData
,
1835 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1837 SetDlgItemText(hwndDlg
,
1842 /* set the device manufacturer edit control text */
1843 if (GetDeviceManufacturerString(DeviceInfoSet
,
1846 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1848 SetDlgItemText(hwndDlg
,
1849 IDC_DEVMANUFACTURER
,
1853 /* set the device location edit control text */
1854 if (GetDeviceLocationString(DeviceInfoSet
,
1858 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1860 SetDlgItemText(hwndDlg
,
1865 /* set the device status edit control text */
1866 if (GetDeviceStatusString(DeviceInfoData
->DevInst
,
1869 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1871 SetDlgItemText(hwndDlg
,
1876 /* set the device troubleshoot button text and disable it if necessary */
1877 hDevProbBtn
= GetDlgItem(hwndDlg
,
1879 cr
= CM_Get_DevNode_Status_Ex(&Status
,
1881 DeviceInfoData
->DevInst
,
1884 if (cr
== CR_SUCCESS
&& (Status
& DN_HAS_PROBLEM
))
1886 switch (ProblemNumber
)
1888 case CM_PROB_DEVLOADER_FAILED
:
1890 /* FIXME - only if it's not a root bus devloader,
1891 disable the button otherwise */
1892 TroubleShootStrId
= IDS_UPDATEDRV
;
1896 case CM_PROB_OUT_OF_MEMORY
:
1897 case CM_PROB_ENTRY_IS_WRONG_TYPE
:
1898 case CM_PROB_LACKED_ARBITRATOR
:
1899 case CM_PROB_FAILED_START
:
1901 case CM_PROB_UNKNOWN_RESOURCE
:
1903 TroubleShootStrId
= IDS_UPDATEDRV
;
1907 case CM_PROB_BOOT_CONFIG_CONFLICT
:
1908 case CM_PROB_NORMAL_CONFLICT
:
1909 case CM_PROB_REENUMERATION
:
1911 /* FIXME - Troubleshoot conflict */
1915 case CM_PROB_FAILED_FILTER
:
1916 case CM_PROB_REINSTALL
:
1917 case CM_PROB_FAILED_INSTALL
:
1919 TroubleShootStrId
= IDS_REINSTALLDRV
;
1923 case CM_PROB_DEVLOADER_NOT_FOUND
:
1926 1) if it's a missing system devloader:
1927 - disable the button (Reinstall Driver)
1928 2) if it's not a system devloader but still missing:
1930 3) if it's not a system devloader but the file can be found:
1932 4) if it's a missing or empty software key
1938 case CM_PROB_INVALID_DATA
:
1939 case CM_PROB_PARTIAL_LOG_CONF
:
1940 case CM_PROB_NO_VALID_LOG_CONF
:
1941 case CM_PROB_HARDWARE_DISABLED
:
1942 case CM_PROB_CANT_SHARE_IRQ
:
1943 case CM_PROB_TRANSLATION_FAILED
:
1944 case CM_PROB_SYSTEM_SHUTDOWN
:
1945 case CM_PROB_PHANTOM
:
1946 bDevActionAvailable
= FALSE
;
1949 case CM_PROB_NOT_VERIFIED
:
1950 case CM_PROB_DEVICE_NOT_THERE
:
1951 /* FIXME - search hardware */
1954 case CM_PROB_NEED_RESTART
:
1955 case CM_PROB_WILL_BE_REMOVED
:
1957 case CM_PROB_TOO_EARLY
:
1958 case CM_PROB_DISABLED_SERVICE
:
1959 TroubleShootStrId
= IDS_REBOOT
;
1962 case CM_PROB_REGISTRY
:
1963 /* FIXME - check registry? */
1966 case CM_PROB_DISABLED
:
1967 /* if device was disabled by the user: */
1968 TroubleShootStrId
= IDS_ENABLEDEV
;
1969 /* FIXME - otherwise disable button because the device was
1970 disabled by the system*/
1973 case CM_PROB_DEVLOADER_NOT_READY
:
1974 /* FIXME - if it's a graphics adapter:
1975 - if it's a a secondary adapter and the main adapter
1985 case CM_PROB_FAILED_ADD
:
1986 TroubleShootStrId
= IDS_PROPERTIES
;
1991 if (LoadString(hDllInstance
,
1994 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])) != 0)
1996 SetWindowText(hDevProbBtn
,
1999 EnableWindow(hDevProbBtn
,
2000 dap
->IsAdmin
&& bDevActionAvailable
);
2002 /* check if the device can be enabled/disabled */
2003 hDevUsage
= GetDlgItem(hwndDlg
,
2006 dap
->CanDisable
= FALSE
;
2007 dap
->DeviceStarted
= FALSE
;
2009 if (CanDisableDevice(DeviceInfoData
->DevInst
,
2013 dap
->CanDisable
= bFlag
;
2016 if (IsDeviceStarted(DeviceInfoData
->DevInst
,
2020 dap
->DeviceStarted
= bFlag
;
2023 /* enable/disable the device usage controls */
2024 EnableWindow(GetDlgItem(hwndDlg
,
2026 dap
->CanDisable
&& dap
->IsAdmin
);
2027 EnableWindow(hDevUsage
,
2028 dap
->CanDisable
&& dap
->IsAdmin
);
2030 /* clear the combobox */
2031 SendMessage(hDevUsage
,
2035 if (dap
->CanDisable
)
2037 InitDevUsageActions(hwndDlg
,
2042 /* find out how many new device property sheets to add.
2043 fake a PROPSHEETHEADER structure, we don't plan to
2044 call PropertySheet again!*/
2045 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2049 /* get the number of device property sheets for the device */
2050 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2055 dap
->PropertySheetType
) &&
2056 nDriverPages
!= 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
2058 dap
->nDevPropSheets
+= nDriverPages
;
2065 /* include the driver page */
2066 if (dap
->HasDriverPage
)
2067 dap
->nDevPropSheets
++;
2069 /* include the details page */
2071 dap
->nDevPropSheets
++;
2073 /* add the device property sheets */
2074 if (dap
->nDevPropSheets
!= 0)
2076 dap
->DevPropSheets
= HeapAlloc(GetProcessHeap(),
2078 dap
->nDevPropSheets
* sizeof(HPROPSHEETPAGE
));
2079 if (dap
->DevPropSheets
!= NULL
)
2081 if (nDriverPages
!= 0)
2083 psh
.phpage
= dap
->DevPropSheets
;
2085 /* query the device property sheet pages to add */
2086 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2089 dap
->nDevPropSheets
,
2091 dap
->PropertySheetType
))
2093 /* add the property sheets */
2095 iPage
!= nDriverPages
;
2098 if (PropSheet_AddPage(hPropSheetDlg
,
2099 dap
->DevPropSheets
[iPage
]))
2105 dap
->FreeDevPropSheets
= TRUE
;
2109 /* cleanup, we were unable to get the device property sheets */
2110 iPage
= nDriverPages
;
2111 dap
->nDevPropSheets
-= nDriverPages
;
2118 /* add the driver page if necessary */
2119 if (dap
->HasDriverPage
)
2121 PROPSHEETPAGE pspDriver
= {0};
2122 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2123 pspDriver
.dwFlags
= PSP_DEFAULT
;
2124 pspDriver
.hInstance
= hDllInstance
;
2125 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDRIVER
);
2126 pspDriver
.pfnDlgProc
= AdvProcDriverDlgProc
;
2127 pspDriver
.lParam
= (LPARAM
)dap
;
2128 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2129 if (dap
->DevPropSheets
[iPage
] != NULL
)
2131 if (PropSheet_AddPage(hPropSheetDlg
,
2132 dap
->DevPropSheets
[iPage
]))
2139 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2140 dap
->DevPropSheets
[iPage
] = NULL
;
2147 /* Add the details page */
2148 PROPSHEETPAGE pspDetails
= {0};
2149 pspDetails
.dwSize
= sizeof(PROPSHEETPAGE
);
2150 pspDetails
.dwFlags
= PSP_DEFAULT
;
2151 pspDetails
.hInstance
= hDllInstance
;
2152 pspDetails
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDETAILS
);
2153 pspDetails
.pfnDlgProc
= AdvProcDetailsDlgProc
;
2154 pspDetails
.lParam
= (LPARAM
)dap
;
2155 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDetails
);
2156 if (dap
->DevPropSheets
[iPage
] != NULL
)
2158 if (PropSheet_AddPage(hPropSheetDlg
,
2159 dap
->DevPropSheets
[iPage
]))
2166 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2167 dap
->DevPropSheets
[iPage
] = NULL
;
2171 /* FIXME: Add the resources page */
2174 /* FIXME: Add the power page */
2177 dap
->nDevPropSheets
= 0;
2182 PropSheet_RecalcPageSizes(hPropSheetDlg
);
2185 /* finally, disable the apply button */
2186 PropSheet_UnChanged(hPropSheetDlg
,
2188 dap
->DeviceUsageChanged
= FALSE
;
2194 DlgParentSubWndProc(IN HWND hwnd
,
2199 PDEVADVPROP_INFO dap
;
2201 dap
= (PDEVADVPROP_INFO
)GetProp(hwnd
,
2202 L
"DevMgrDevChangeSub");
2205 if (uMsg
== WM_DEVICECHANGE
&& !IsWindowVisible(dap
->hWndGeneralPage
))
2207 SendMessage(dap
->hWndGeneralPage
,
2213 /* pass the message the the old window proc */
2214 return CallWindowProc(dap
->ParentOldWndProc
,
2222 /* this is not a good idea if the subclassed window was an ansi
2223 window, but we failed finding out the previous window proc
2224 so we can't use CallWindowProc. This should rarely - if ever -
2227 return DefWindowProc(hwnd
,
2237 AdvPropGeneralDlgProc(IN HWND hwndDlg
,
2242 PDEVADVPROP_INFO dap
;
2243 INT_PTR Ret
= FALSE
;
2245 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
2248 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
2254 switch (LOWORD(wParam
))
2258 if (HIWORD(wParam
) == CBN_SELCHANGE
)
2260 PropSheet_Changed(GetParent(hwndDlg
),
2262 dap
->DeviceUsageChanged
= TRUE
;
2267 case IDC_DEVPROBLEM
:
2271 /* display the device problem wizard */
2272 ShowDeviceProblemWizard(hwndDlg
,
2274 &dap
->DeviceInfoData
,
2285 NMHDR
*hdr
= (NMHDR
*)lParam
;
2289 ApplyGeneralSettings(hwndDlg
,
2298 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2303 dap
->hWndGeneralPage
= hwndDlg
;
2305 SetWindowLongPtr(hwndDlg
,
2309 /* subclass the parent window to always receive
2310 WM_DEVICECHANGE messages */
2311 hWndParent
= GetParent(hwndDlg
);
2312 if (hWndParent
!= NULL
)
2314 /* subclass the parent window. This is not safe
2315 if the parent window belongs to another thread! */
2316 dap
->ParentOldWndProc
= (WNDPROC
)SetWindowLongPtr(hWndParent
,
2318 (LONG_PTR
)DlgParentSubWndProc
);
2320 if (dap
->ParentOldWndProc
!= NULL
&&
2322 L
"DevMgrDevChangeSub",
2325 dap
->hWndParent
= hWndParent
;
2329 /* do not call UpdateDevInfo directly in here because it modifies
2330 the pages of the property sheet! */
2331 PostMessage(hwndDlg
,
2340 case WM_DEVICECHANGE
:
2342 /* FIXME - don't call UpdateDevInfo for all events */
2343 UpdateDevInfo(hwndDlg
,
2352 UpdateDevInfo(hwndDlg
,
2355 dap
->PageInitialized
= TRUE
;
2361 /* restore the old window proc of the subclassed parent window */
2362 if (dap
->hWndParent
!= NULL
&& dap
->ParentOldWndProc
!= NULL
)
2364 if (SetWindowLongPtr(dap
->hWndParent
,
2366 (LONG_PTR
)dap
->ParentOldWndProc
) == (LONG_PTR
)DlgParentSubWndProc
)
2368 RemoveProp(dap
->hWndParent
,
2369 L
"DevMgrDevChangeSub");
2382 DisplayDeviceAdvancedProperties(IN HWND hWndParent
,
2383 IN LPCWSTR lpDeviceID OPTIONAL
,
2384 IN HDEVINFO DeviceInfoSet
,
2385 IN PSP_DEVINFO_DATA DeviceInfoData
,
2386 IN HINSTANCE hComCtl32
,
2387 IN LPCWSTR lpMachineName
,
2390 PROPSHEETHEADER psh
= {0};
2391 PROPSHEETPAGE pspGeneral
= {0};
2392 PPROPERTYSHEETW pPropertySheetW
;
2393 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
2394 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
2395 PDEVADVPROP_INFO DevAdvPropInfo
;
2396 HMACHINE hMachine
= NULL
;
2397 DWORD DevIdSize
= 0;
2400 /* we don't want to statically link against comctl32, so find the
2401 functions we need dynamically */
2403 (PPROPERTYSHEETW
)GetProcAddress(hComCtl32
,
2405 pCreatePropertySheetPageW
=
2406 (PCREATEPROPERTYSHEETPAGEW
)GetProcAddress(hComCtl32
,
2407 "CreatePropertySheetPageW");
2408 pDestroyPropertySheetPage
=
2409 (PDESTROYPROPERTYSHEETPAGE
)GetProcAddress(hComCtl32
,
2410 "DestroyPropertySheetPage");
2411 if (pPropertySheetW
== NULL
||
2412 pCreatePropertySheetPageW
== NULL
||
2413 pDestroyPropertySheetPage
== NULL
)
2418 if (lpDeviceID
== NULL
)
2420 /* find out how much size is needed for the device id */
2421 if (SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2427 DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n");
2431 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
2438 DevIdSize
= (DWORD
)wcslen(lpDeviceID
) + 1;
2441 if (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0')
2443 CONFIGRET cr
= CM_Connect_Machine(lpMachineName
,
2445 if (cr
!= CR_SUCCESS
)
2451 /* create the internal structure associated with the "General",
2452 "Driver", ... pages */
2453 DevAdvPropInfo
= HeapAlloc(GetProcessHeap(),
2455 FIELD_OFFSET(DEVADVPROP_INFO
,
2457 (DevIdSize
* sizeof(WCHAR
)));
2458 if (DevAdvPropInfo
== NULL
)
2460 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2464 if (lpDeviceID
== NULL
)
2466 /* read the device instance id */
2467 if (!SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2469 DevAdvPropInfo
->szDeviceID
,
2478 /* copy the device instance id supplied by the caller */
2479 wcscpy(DevAdvPropInfo
->szDeviceID
,
2483 DevAdvPropInfo
->DeviceInfoSet
= DeviceInfoSet
;
2484 DevAdvPropInfo
->DeviceInfoData
= *DeviceInfoData
;
2485 DevAdvPropInfo
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
2486 DevAdvPropInfo
->CurrentDeviceInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2488 DevAdvPropInfo
->ShowRemotePages
= (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0');
2489 DevAdvPropInfo
->hMachine
= hMachine
;
2490 DevAdvPropInfo
->lpMachineName
= lpMachineName
;
2491 DevAdvPropInfo
->szDevName
[0] = L
'\0';
2492 DevAdvPropInfo
->hComCtl32
= hComCtl32
;
2493 DevAdvPropInfo
->pCreatePropertySheetPageW
= pCreatePropertySheetPageW
;
2494 DevAdvPropInfo
->pDestroyPropertySheetPage
= pDestroyPropertySheetPage
;
2496 DevAdvPropInfo
->IsAdmin
= IsUserAdmin();
2497 DevAdvPropInfo
->DoDefaultDevAction
= ((dwFlags
& DPF_DEVICE_STATUS_ACTION
) != 0);
2498 DevAdvPropInfo
->Extended
= ((dwFlags
& DPF_EXTENDED
) != 0);
2500 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2501 psh
.dwFlags
= PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
2502 psh
.hwndParent
= hWndParent
;
2503 psh
.pszCaption
= DevAdvPropInfo
->szDevName
;
2505 DevAdvPropInfo
->PropertySheetType
= DevAdvPropInfo
->ShowRemotePages
?
2506 DIGCDP_FLAG_REMOTE_ADVANCED
:
2507 DIGCDP_FLAG_ADVANCED
;
2509 psh
.phpage
= HeapAlloc(GetProcessHeap(),
2511 1 * sizeof(HPROPSHEETPAGE
));
2512 if (psh
.phpage
== NULL
)
2517 /* add the "General" property sheet */
2518 pspGeneral
.dwSize
= sizeof(PROPSHEETPAGE
);
2519 pspGeneral
.dwFlags
= PSP_DEFAULT
;
2520 pspGeneral
.hInstance
= hDllInstance
;
2521 pspGeneral
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEGENERAL
);
2522 pspGeneral
.pfnDlgProc
= AdvPropGeneralDlgProc
;
2523 pspGeneral
.lParam
= (LPARAM
)DevAdvPropInfo
;
2524 psh
.phpage
[psh
.nPages
] = pCreatePropertySheetPageW(&pspGeneral
);
2525 if (psh
.phpage
[psh
.nPages
] != NULL
)
2530 DevAdvPropInfo
->nDevPropSheets
= psh
.nPages
;
2532 if (psh
.nPages
!= 0)
2534 Ret
= pPropertySheetW(&psh
);
2536 /* NOTE: no need to destroy the property sheets anymore! */
2543 /* in case of failure the property sheets must be destroyed */
2544 if (psh
.phpage
!= NULL
)
2550 if (psh
.phpage
[i
] != NULL
)
2552 pDestroyPropertySheetPage(psh
.phpage
[i
]);
2558 if (DevAdvPropInfo
!= NULL
)
2560 if (DevAdvPropInfo
->FreeDevPropSheets
)
2562 /* don't free the array if it's the one allocated in
2563 DisplayDeviceAdvancedProperties */
2564 HeapFree(GetProcessHeap(),
2566 DevAdvPropInfo
->DevPropSheets
);
2569 if (DevAdvPropInfo
->CloseDevInst
)
2571 /* close the device info set in case a new one was created */
2572 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->DeviceInfoSet
);
2575 if (DevAdvPropInfo
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
2577 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->CurrentDeviceInfoSet
);
2580 if (DevAdvPropInfo
->hDevIcon
!= NULL
)
2582 DestroyIcon(DevAdvPropInfo
->hDevIcon
);
2585 HeapFree(GetProcessHeap(),
2590 if (psh
.phpage
!= NULL
)
2592 HeapFree(GetProcessHeap(),
2597 if (hMachine
!= NULL
)
2599 CM_Disconnect_Machine(hMachine
);
2607 GetDeviceAndComputerName(LPWSTR lpString
,
2609 WCHAR szMachineName
[])
2613 szDeviceID
[0] = L
'\0';
2614 szMachineName
[0] = L
'\0';
2616 while (*lpString
!= L
'\0')
2618 if (*lpString
== L
'/')
2621 if(!_wcsnicmp(lpString
, L
"DeviceID", 8))
2624 if (*lpString
!= L
'\0')
2627 while ((*lpString
!= L
' ') &&
2628 (*lpString
!= L
'\0') &&
2629 (i
<= MAX_DEVICE_ID_LEN
))
2631 szDeviceID
[i
++] = *lpString
++;
2633 szDeviceID
[i
] = L
'\0';
2637 else if (!_wcsnicmp(lpString
, L
"MachineName", 11))
2640 if (*lpString
!= L
'\0')
2643 while ((*lpString
!= L
' ') &&
2644 (*lpString
!= L
'\0') &&
2645 (i
<= MAX_COMPUTERNAME_LENGTH
))
2647 szMachineName
[i
++] = *lpString
++;
2649 szMachineName
[i
] = L
'\0';
2652 /* knock the pointer back one and let the next
2653 * pointer deal with incrementing, otherwise we
2654 * go past the end of the string */
2664 /***************************************************************************
2666 * DeviceAdvancedPropertiesW
2669 * Invokes the device properties dialog, this version may add some property pages
2673 * hWndParent: Handle to the parent window
2674 * lpMachineName: Machine Name, NULL is the local machine
2675 * lpDeviceID: Specifies the device whose properties are to be shown
2678 * Always returns -1, a call to GetLastError returns 0 if successful
2684 DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL
,
2685 IN LPCWSTR lpMachineName OPTIONAL
,
2686 IN LPCWSTR lpDeviceID
)
2689 SP_DEVINFO_DATA DevInfoData
;
2690 HINSTANCE hComCtl32
;
2693 if (lpDeviceID
== NULL
)
2695 SetLastError(ERROR_INVALID_PARAMETER
);
2699 /* dynamically load comctl32 */
2700 hComCtl32
= LoadAndInitComctl32();
2701 if (hComCtl32
!= NULL
)
2703 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2707 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2709 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2710 if (SetupDiOpenDeviceInfo(hDevInfo
,
2716 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2725 SetupDiDestroyDeviceInfoList(hDevInfo
);
2728 FreeLibrary(hComCtl32
);
2735 /***************************************************************************
2737 * DeviceAdvancedPropertiesA
2740 * Invokes the device properties dialog, this version may add some property pages
2744 * hWndParent: Handle to the parent window
2745 * lpMachineName: Machine Name, NULL is the local machine
2746 * lpDeviceID: Specifies the device whose properties are to be shown
2749 * Always returns -1, a call to GetLastError returns 0 if successful
2755 DeviceAdvancedPropertiesA(IN HWND hWndParent OPTIONAL
,
2756 IN LPCSTR lpMachineName OPTIONAL
,
2757 IN LPCSTR lpDeviceID
)
2759 LPWSTR lpMachineNameW
= NULL
;
2760 LPWSTR lpDeviceIDW
= NULL
;
2763 if (lpMachineName
!= NULL
)
2765 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2771 if (lpDeviceID
!= NULL
)
2773 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2780 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
2785 if (lpMachineNameW
!= NULL
)
2787 HeapFree(GetProcessHeap(),
2791 if (lpDeviceIDW
!= NULL
)
2793 HeapFree(GetProcessHeap(),
2802 /***************************************************************************
2804 * DevicePropertiesExA
2807 * Invokes the extended device properties dialog
2810 * hWndParent: Handle to the parent window
2811 * lpMachineName: Machine Name, NULL is the local machine
2812 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2813 * bShowDevMgr is nonzero
2814 * dwFlags: This parameter can be a combination of the following flags:
2815 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2816 * the default device status action button
2817 * to be clicked (Troubleshoot, Enable
2819 * bShowDevMgr: If non-zero it displays the device manager instead of
2820 * the advanced device property dialog
2823 * 1: if bShowDevMgr is non-zero and no error occured
2824 * -1: a call to GetLastError returns 0 if successful
2830 DevicePropertiesExA(IN HWND hWndParent OPTIONAL
,
2831 IN LPCSTR lpMachineName OPTIONAL
,
2832 IN LPCSTR lpDeviceID OPTIONAL
,
2833 IN DWORD dwFlags OPTIONAL
,
2834 IN BOOL bShowDevMgr
)
2836 LPWSTR lpMachineNameW
= NULL
;
2837 LPWSTR lpDeviceIDW
= NULL
;
2840 if (lpMachineName
!= NULL
)
2842 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2848 if (lpDeviceID
!= NULL
)
2850 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2857 Ret
= DevicePropertiesExW(hWndParent
,
2864 if (lpMachineNameW
!= NULL
)
2866 HeapFree(GetProcessHeap(),
2870 if (lpDeviceIDW
!= NULL
)
2872 HeapFree(GetProcessHeap(),
2881 /***************************************************************************
2883 * DevicePropertiesExW
2886 * Invokes the extended device properties dialog
2889 * hWndParent: Handle to the parent window
2890 * lpMachineName: Machine Name, NULL is the local machine
2891 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2892 * bShowDevMgr is nonzero
2893 * dwFlags: This parameter can be a combination of the following flags:
2894 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2895 * the default device status action button
2896 * to be clicked (Troubleshoot, Enable
2898 * bShowDevMgr: If non-zero it displays the device manager instead of
2899 * the advanced device property dialog
2902 * 1: if bShowDevMgr is non-zero and no error occured
2903 * -1: a call to GetLastError returns 0 if successful
2909 DevicePropertiesExW(IN HWND hWndParent OPTIONAL
,
2910 IN LPCWSTR lpMachineName OPTIONAL
,
2911 IN LPCWSTR lpDeviceID OPTIONAL
,
2912 IN DWORD dwFlags OPTIONAL
,
2913 IN BOOL bShowDevMgr
)
2917 if (dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
))
2919 DPRINT1("DevPropertiesExW: Invalid flags: 0x%x\n",
2920 dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
));
2921 SetLastError(ERROR_INVALID_FLAGS
);
2927 DPRINT("DevPropertiesExW doesn't support bShowDevMgr!\n");
2928 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2933 SP_DEVINFO_DATA DevInfoData
;
2934 HINSTANCE hComCtl32
;
2936 if (lpDeviceID
== NULL
)
2938 SetLastError(ERROR_INVALID_PARAMETER
);
2942 /* dynamically load comctl32 */
2943 hComCtl32
= LoadAndInitComctl32();
2944 if (hComCtl32
!= NULL
)
2946 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2950 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2952 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2953 if (SetupDiOpenDeviceInfo(hDevInfo
,
2959 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2968 SetupDiDestroyDeviceInfoList(hDevInfo
);
2971 FreeLibrary(hComCtl32
);
2979 /***************************************************************************
2984 * Invokes the device properties dialog directly
2987 * hWndParent: Handle to the parent window
2988 * lpMachineName: Machine Name, NULL is the local machine
2989 * lpDeviceID: Specifies the device whose properties are to be shown
2990 * bShowDevMgr: If non-zero it displays the device manager instead of
2991 * the device property dialog
2994 * >=0: if no errors occured
2995 * -1: if errors occured
3003 DevicePropertiesA(HWND hWndParent
,
3004 LPCSTR lpMachineName
,
3008 return DevicePropertiesExA(hWndParent
,
3016 /***************************************************************************
3021 * Invokes the device properties dialog directly
3024 * hWndParent: Handle to the parent window
3025 * lpMachineName: Machine Name, NULL is the local machine
3026 * lpDeviceID: Specifies the device whose properties are to be shown
3027 * bShowDevMgr: If non-zero it displays the device manager instead of
3028 * the device property dialog
3031 * >=0: if no errors occured
3032 * -1: if errors occured
3040 DevicePropertiesW(HWND hWndParent
,
3041 LPCWSTR lpMachineName
,
3045 return DevicePropertiesExW(hWndParent
,
3053 /***************************************************************************
3055 * DeviceProperties_RunDLLA
3058 * Invokes the device properties dialog
3061 * hWndParent: Handle to the parent window
3062 * hInst: Handle to the application instance
3063 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3065 * nCmdShow: Specifies how the window should be shown
3072 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3073 * (/MachineName is optional). This function only parses this string and eventually
3074 * calls DeviceProperties().
3080 DeviceProperties_RunDLLA(HWND hWndParent
,
3085 LPWSTR lpDeviceCmdW
= NULL
;
3087 if (lpDeviceCmd
!= NULL
)
3089 if ((lpDeviceCmdW
= ConvertMultiByteToUnicode(lpDeviceCmd
,
3092 DeviceProperties_RunDLLW(hWndParent
,
3099 if (lpDeviceCmdW
!= NULL
)
3101 HeapFree(GetProcessHeap(),
3108 /***************************************************************************
3110 * DeviceProperties_RunDLLW
3113 * Invokes the device properties dialog
3116 * hWndParent: Handle to the parent window
3117 * hInst: Handle to the application instance
3118 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3120 * nCmdShow: Specifies how the window should be shown
3127 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3128 * (/MachineName is optional). This function only parses this string and eventually
3129 * calls DeviceProperties().
3135 DeviceProperties_RunDLLW(HWND hWndParent
,
3137 LPCWSTR lpDeviceCmd
,
3140 WCHAR szDeviceID
[MAX_DEVICE_ID_LEN
+1];
3141 WCHAR szMachineName
[MAX_COMPUTERNAME_LENGTH
+1];
3142 LPWSTR lpString
= (LPWSTR
)lpDeviceCmd
;
3144 if (!GetDeviceAndComputerName(lpString
,
3148 DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID
, szMachineName
);
3152 DevicePropertiesW(hWndParent
,