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 EnumDeviceDriverFilesCallback(IN PVOID Context
,
41 PENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
= (PENUMDRIVERFILES_CONTEXT
)Context
;
43 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
44 li
.iItem
= EnumDriverFilesContext
->nCount
++;
46 li
.state
= (li
.iItem
== 0 ? LVIS_SELECTED
: 0);
47 li
.stateMask
= LVIS_SELECTED
;
48 li
.pszText
= (LPWSTR
)Param1
;
49 (void)ListView_InsertItem(EnumDriverFilesContext
->hDriversListView
,
56 UpdateDriverDetailsDlg(IN HWND hwndDlg
,
57 IN HWND hDriversListView
,
58 IN PDEVADVPROP_INFO dap
)
60 HDEVINFO DeviceInfoSet
;
61 PSP_DEVINFO_DATA DeviceInfoData
;
62 SP_DRVINFO_DATA DriverInfoData
;
63 ENUMDRIVERFILES_CONTEXT EnumDriverFilesContext
;
65 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
67 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
68 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
72 DeviceInfoSet
= dap
->DeviceInfoSet
;
73 DeviceInfoData
= &dap
->DeviceInfoData
;
76 /* set the device image */
77 SendDlgItemMessage(hwndDlg
,
80 (WPARAM
)dap
->hDevIcon
,
83 /* set the device name edit control text */
84 SetDlgItemText(hwndDlg
,
88 /* fill the driver files list view */
89 EnumDriverFilesContext
.hDriversListView
= hDriversListView
;
90 EnumDriverFilesContext
.nCount
= 0;
92 (void)ListView_DeleteAllItems(EnumDriverFilesContext
.hDriversListView
);
93 DriverInfoData
.cbSize
= sizeof(SP_DRVINFO_DATA
);
94 if (FindCurrentDriver(DeviceInfoSet
,
97 SetupDiSetSelectedDriver(DeviceInfoSet
,
101 HSPFILEQ queueHandle
;
103 queueHandle
= SetupOpenFileQueue();
104 if (queueHandle
!= (HSPFILEQ
)INVALID_HANDLE_VALUE
)
106 SP_DEVINSTALL_PARAMS DeviceInstallParams
= {0};
107 DeviceInstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS
);
108 if (SetupDiGetDeviceInstallParams(DeviceInfoSet
,
110 &DeviceInstallParams
))
112 DeviceInstallParams
.FileQueue
= queueHandle
;
113 DeviceInstallParams
.Flags
|= DI_NOVCP
;
115 if (SetupDiSetDeviceInstallParams(DeviceInfoSet
,
117 &DeviceInstallParams
) &&
118 SetupDiCallClassInstaller(DIF_INSTALLDEVICEFILES
,
126 /* enumerate the driver files */
127 SetupScanFileQueue(queueHandle
,
128 SPQ_SCAN_USE_CALLBACK
,
130 EnumDeviceDriverFilesCallback
,
131 &EnumDriverFilesContext
,
134 /* update the list view column width */
135 GetClientRect(hDriversListView
,
137 lvc
.mask
= LVCF_WIDTH
;
138 lvc
.cx
= rcClient
.right
;
139 (void)ListView_SetColumn(hDriversListView
,
143 /* highlight the first item from list */
144 if (ListView_GetSelectedCount(hDriversListView
) != 0)
146 ListView_SetItemState(hDriversListView
,
148 LVIS_FOCUSED
| LVIS_SELECTED
,
149 LVIS_FOCUSED
| LVIS_SELECTED
);
154 SetupCloseFileQueue(queueHandle
);
161 UpdateDriverVersionInfoDetails(IN HWND hwndDlg
,
162 IN LPCWSTR lpszDriverPath
)
166 LPVOID lpData
= NULL
;
170 WCHAR szLangInfo
[255];
171 WCHAR szLangPath
[MAX_PATH
];
172 LPWSTR lpCompanyName
= NULL
;
173 LPWSTR lpFileVersion
= NULL
;
174 LPWSTR lpLegalCopyright
= NULL
;
175 LPWSTR lpDigitalSigner
= NULL
;
177 WCHAR szNotAvailable
[255];
179 /* extract version info from selected file */
180 dwVerInfoSize
= GetFileVersionInfoSize(lpszDriverPath
,
185 lpData
= HeapAlloc(GetProcessHeap(),
191 if (!GetFileVersionInfo(lpszDriverPath
,
197 if (!VerQueryValue(lpData
,
198 L
"\\VarFileInfo\\Translation",
203 dwLangId
= *(LPDWORD
)lpInfo
;
204 swprintf(szLangInfo
, L
"\\StringFileInfo\\%04x%04x\\",
205 LOWORD(dwLangId
), HIWORD(dwLangId
));
207 /* read CompanyName */
208 wcscpy(szLangPath
, szLangInfo
);
209 wcscat(szLangPath
, L
"CompanyName");
211 VerQueryValue(lpData
,
213 (void **)&lpCompanyName
,
216 /* read FileVersion */
217 wcscpy(szLangPath
, szLangInfo
);
218 wcscat(szLangPath
, L
"FileVersion");
220 VerQueryValue(lpData
,
222 (void **)&lpFileVersion
,
225 /* read LegalTrademarks */
226 wcscpy(szLangPath
, szLangInfo
);
227 wcscat(szLangPath
, L
"LegalCopyright");
229 VerQueryValue(lpData
,
231 (void **)&lpLegalCopyright
,
234 /* TODO: read digital signer info */
237 if (!LoadString(hDllInstance
,
240 sizeof(szNotAvailable
) / sizeof(WCHAR
)))
242 wcscpy(szNotAvailable
, L
"n/a");
247 lpCompanyName
= szNotAvailable
;
248 SetDlgItemText(hwndDlg
,
253 lpFileVersion
= szNotAvailable
;
254 SetDlgItemText(hwndDlg
,
258 if (!lpLegalCopyright
)
259 lpLegalCopyright
= szNotAvailable
;
260 SetDlgItemText(hwndDlg
,
264 if (!lpDigitalSigner
)
265 lpDigitalSigner
= szNotAvailable
;
266 SetDlgItemText(hwndDlg
,
270 /* release version info */
272 HeapFree(GetProcessHeap(),
280 DriverDetailsDlgProc(IN HWND hwndDlg
,
285 PDEVADVPROP_INFO dap
;
288 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
291 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
297 switch (LOWORD(wParam
))
320 HWND hDriversListView
;
322 dap
= (PDEVADVPROP_INFO
)lParam
;
325 SetWindowLongPtr(hwndDlg
,
329 hDriversListView
= GetDlgItem(hwndDlg
,
332 /* add a column to the list view control */
333 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
334 lvc
.fmt
= LVCFMT_LEFT
;
336 (void)ListView_InsertColumn(hDriversListView
,
340 UpdateDriverDetailsDlg(hwndDlg
,
351 LPNMHDR pnmhdr
= (LPNMHDR
)lParam
;
353 switch (pnmhdr
->code
)
355 case LVN_ITEMCHANGED
:
357 LPNMLISTVIEW pnmv
= (LPNMLISTVIEW
)lParam
;
358 HWND hDriversListView
= GetDlgItem(hwndDlg
,
361 if (ListView_GetSelectedCount(hDriversListView
) == 0)
363 /* nothing is selected - empty the labels */
364 SetDlgItemText(hwndDlg
,
367 SetDlgItemText(hwndDlg
,
370 SetDlgItemText(hwndDlg
,
373 SetDlgItemText(hwndDlg
,
377 else if (pnmv
->uNewState
!= 0)
379 /* extract version info and update the labels */
380 WCHAR szDriverPath
[MAX_PATH
];
382 ListView_GetItemText(hDriversListView
,
388 UpdateDriverVersionInfoDetails(hwndDlg
,
403 UpdateDriverDlg(IN HWND hwndDlg
,
404 IN PDEVADVPROP_INFO dap
)
406 HDEVINFO DeviceInfoSet
;
407 PSP_DEVINFO_DATA DeviceInfoData
;
409 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
411 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
412 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
416 DeviceInfoSet
= dap
->DeviceInfoSet
;
417 DeviceInfoData
= &dap
->DeviceInfoData
;
420 /* set the device image */
421 SendDlgItemMessage(hwndDlg
,
424 (WPARAM
)dap
->hDevIcon
,
427 /* set the device name edit control text */
428 SetDlgItemText(hwndDlg
,
432 /* query the driver provider */
433 if (GetDriverProviderString(DeviceInfoSet
,
436 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
438 SetDlgItemText(hwndDlg
,
443 /* query the driver date */
444 if (GetDriverDateString(DeviceInfoSet
,
447 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
449 SetDlgItemText(hwndDlg
,
454 /* query the driver version */
455 if (GetDriverVersionString(DeviceInfoSet
,
458 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
460 SetDlgItemText(hwndDlg
,
469 AdvProcDriverDlgProc(IN HWND hwndDlg
,
474 PDEVADVPROP_INFO dap
;
477 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
480 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
486 switch (LOWORD(wParam
))
488 case IDC_DRIVERDETAILS
:
490 DialogBoxParam(hDllInstance
,
491 MAKEINTRESOURCE(IDD_DRIVERDETAILS
),
493 DriverDetailsDlgProc
,
497 case IDC_UPDATEDRIVER
:
499 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
502 if (DiShowUpdateDevice(hwndDlg
, dap
->CurrentDeviceInfoSet
, &dap
->CurrentDeviceInfoData
, 0, &NeedReboot
))
506 //FIXME: load text from resource file
507 if(MessageBoxW(hwndDlg
, L
"Reboot now?", L
"Reboot required", MB_YESNO
| MB_ICONQUESTION
) == IDYES
)
510 TOKEN_PRIVILEGES Privileges
;
512 if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
, &hToken
))
514 DPRINT("OpenProcessToken failed\n");
518 /* Get the LUID for the Shutdown privilege */
519 if (!LookupPrivilegeValueW(NULL
, SE_SHUTDOWN_NAME
, &Privileges
.Privileges
[0].Luid
))
521 DPRINT("LookupPrivilegeValue failed\n");
525 /* Assign the Shutdown privilege to our process */
526 Privileges
.PrivilegeCount
= 1;
527 Privileges
.Privileges
[0].Attributes
= SE_PRIVILEGE_ENABLED
;
529 if (!AdjustTokenPrivileges(hToken
, FALSE
, &Privileges
, 0, NULL
, NULL
))
531 DPRINT("AdjustTokenPrivileges failed\n");
535 /* Finally shut down the system */
536 if(!ExitWindowsEx(EWX_REBOOT
, SHTDN_REASON_MAJOR_OTHER
| SHTDN_REASON_MINOR_OTHER
| SHTDN_REASON_FLAG_PLANNED
))
538 DPRINT("ExitWindowsEx failed\n");
553 NMHDR
*hdr
= (NMHDR
*)lParam
;
564 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
567 SetWindowLongPtr(hwndDlg
,
571 UpdateDriverDlg(hwndDlg
,
585 SetListViewText(HWND hwnd
,
591 li
.mask
= LVIF_TEXT
| LVIF_STATE
;
594 li
.state
= 0; //(li.iItem == 0 ? LVIS_SELECTED : 0);
595 li
.stateMask
= LVIS_SELECTED
;
597 (void)ListView_InsertItem(hwnd
,
603 UpdateDetailsDlg(IN HWND hwndDlg
,
604 IN PDEVADVPROP_INFO dap
)
615 IDS_PROP_HARDWAREIDS
,
616 IDS_PROP_COMPATIBLEIDS
,
617 IDS_PROP_MATCHINGDEVICEID
,
620 IDS_PROP_CAPABILITIES
,
621 IDS_PROP_DEVNODEFLAGS
,
622 IDS_PROP_CONFIGFLAGS
,
623 IDS_PROP_CSCONFIGFLAGS
,
624 IDS_PROP_EJECTIONRELATIONS
,
625 IDS_PROP_REMOVALRELATIONS
,
626 IDS_PROP_BUSRELATIONS
,
627 IDS_PROP_DEVUPPERFILTERS
,
628 IDS_PROP_DEVLOWERFILTERS
,
629 IDS_PROP_CLASSUPPERFILTERS
,
630 IDS_PROP_CLASSLOWERFILTERS
,
631 IDS_PROP_CLASSINSTALLER
,
632 IDS_PROP_CLASSCOINSTALLER
,
633 IDS_PROP_DEVICECOINSTALLER
,
634 IDS_PROP_FIRMWAREREVISION
,
635 IDS_PROP_CURRENTPOWERSTATE
,
636 IDS_PROP_POWERCAPABILITIES
,
637 IDS_PROP_POWERSTATEMAPPINGS
641 /* set the device image */
642 SendDlgItemMessage(hwndDlg
,
645 (WPARAM
)dap
->hDevIcon
,
648 /* set the device name edit control text */
649 SetDlgItemText(hwndDlg
,
654 hwndComboBox
= GetDlgItem(hwndDlg
,
655 IDC_DETAILSPROPNAME
);
657 hwndListView
= GetDlgItem(hwndDlg
,
658 IDC_DETAILSPROPVALUE
);
660 for (i
= 0; i
!= sizeof(Properties
) / sizeof(Properties
[0]); i
++)
662 /* fill in the device usage combo box */
663 if (LoadString(hDllInstance
,
666 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
668 SendMessage(hwndComboBox
,
671 (LPARAM
)dap
->szTemp
);
676 GetClientRect(hwndListView
,
679 /* add a column to the list view control */
680 lvc
.mask
= LVCF_FMT
| LVCF_WIDTH
;
681 lvc
.fmt
= LVCFMT_LEFT
;
682 lvc
.cx
= rcClient
.right
;
683 (void)ListView_InsertColumn(hwndListView
,
687 SendMessage(hwndComboBox
,
692 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
694 SetFocus(hwndComboBox
);
699 DisplayDevicePropertyText(IN PDEVADVPROP_INFO dap
,
700 IN HWND hwndListView
,
703 HDEVINFO DeviceInfoSet
;
704 PSP_DEVINFO_DATA DeviceInfoData
;
713 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
715 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
716 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
720 DeviceInfoSet
= dap
->DeviceInfoSet
;
721 DeviceInfoData
= &dap
->DeviceInfoData
;
725 SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
734 if (GetLastError() != ERROR_FILE_NOT_FOUND
)
736 swprintf(dap
->szTemp
, L
"Error: Getting the size failed! (Error: %ld)", GetLastError());
737 SetListViewText(hwndListView
, 0, dap
->szTemp
);
742 lpBuffer
= HeapAlloc(GetProcessHeap(),
745 if (lpBuffer
== NULL
)
747 SetListViewText(hwndListView
, 0, L
"Error: Allocating the buffer failed!");
751 if (SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
759 if (dwType
== REG_SZ
)
761 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
763 else if (dwType
== REG_MULTI_SZ
)
765 lpStr
= (LPWSTR
)lpBuffer
;
769 len
= wcslen(lpStr
) + 1;
771 SetListViewText(hwndListView
, index
, lpStr
);
777 else if (dwType
== REG_DWORD
)
779 dwValue
= *(DWORD
*) lpBuffer
;
783 case SPDRP_CAPABILITIES
:
785 if (dwValue
& CM_DEVCAP_LOCKSUPPORTED
)
786 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_LOCKSUPPORTED");
787 if (dwValue
& CM_DEVCAP_EJECTSUPPORTED
)
788 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_EJECTSUPPORTED");
789 if (dwValue
& CM_DEVCAP_REMOVABLE
)
790 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_REMOVABLE");
791 if (dwValue
& CM_DEVCAP_DOCKDEVICE
)
792 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_DOCKDEVICE");
793 if (dwValue
& CM_DEVCAP_UNIQUEID
)
794 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_UNIQUEID");
795 if (dwValue
& CM_DEVCAP_SILENTINSTALL
)
796 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SILENTINSTALL");
797 if (dwValue
& CM_DEVCAP_RAWDEVICEOK
)
798 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_RAWDEVICEOK");
799 if (dwValue
& CM_DEVCAP_SURPRISEREMOVALOK
)
800 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_SURPRISEREMOVALOK");
801 if (dwValue
& CM_DEVCAP_HARDWAREDISABLED
)
802 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_HARDWAREDISABLED");
803 if (dwValue
& CM_DEVCAP_NONDYNAMIC
)
804 SetListViewText(hwndListView
, index
++, L
"CM_DEVCAP_NONDYNAMIC");
807 case SPDRP_CONFIGFLAGS
:
809 if (dwValue
& CONFIGFLAG_DISABLED
)
810 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_DISABLED");
811 if (dwValue
& CONFIGFLAG_REMOVED
)
812 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REMOVED");
813 if (dwValue
& CONFIGFLAG_MANUAL_INSTALL
)
814 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_MANUAL_INSTALL");
815 if (dwValue
& CONFIGFLAG_IGNORE_BOOT_LC
)
816 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_IGNORE_BOOT_LC");
817 if (dwValue
& CONFIGFLAG_NET_BOOT
)
818 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NET_BOOT");
819 if (dwValue
& CONFIGFLAG_REINSTALL
)
820 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_REINSTALL");
821 if (dwValue
& CONFIGFLAG_FAILEDINSTALL
)
822 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_FAILEDINSTALL");
823 if (dwValue
& CONFIGFLAG_CANTSTOPACHILD
)
824 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_CANTSTOPACHILD");
825 if (dwValue
& CONFIGFLAG_OKREMOVEROM
)
826 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_OKREMOVEROM");
827 if (dwValue
& CONFIGFLAG_NOREMOVEEXIT
)
828 SetListViewText(hwndListView
, index
++, L
"CONFIGFLAG_NOREMOVEEXIT");
832 swprintf(dap
->szTemp
, L
"0x%08lx", dwValue
);
833 SetListViewText(hwndListView
, 0, dap
->szTemp
);
839 SetListViewText(hwndListView
, 0, L
"Error: Unsupported value type!");
845 SetListViewText(hwndListView
, 0, L
"Error: Retrieving the value failed!");
848 HeapFree(GetProcessHeap(),
854 DisplayDevNodeFlags(IN PDEVADVPROP_INFO dap
,
855 IN HWND hwndListView
)
861 CM_Get_DevNode_Status_Ex(&dwStatus
,
863 dap
->DeviceInfoData
.DevInst
,
868 if (dwStatus
& DN_ROOT_ENUMERATED
)
869 SetListViewText(hwndListView
, index
++, L
"DN_ROOT_ENUMERATED");
870 if (dwStatus
& DN_DRIVER_LOADED
)
871 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_LOADED");
872 if (dwStatus
& DN_ENUM_LOADED
)
873 SetListViewText(hwndListView
, index
++, L
"DN_ENUM_LOADED");
874 if (dwStatus
& DN_STARTED
)
875 SetListViewText(hwndListView
, index
++, L
"DN_STARTED");
876 if (dwStatus
& DN_MANUAL
)
877 SetListViewText(hwndListView
, index
++, L
"DN_MANUAL");
878 if (dwStatus
& DN_NEED_TO_ENUM
)
879 SetListViewText(hwndListView
, index
++, L
"DN_NEED_TO_ENUM");
880 if (dwStatus
& DN_DRIVER_BLOCKED
)
881 SetListViewText(hwndListView
, index
++, L
"DN_DRIVER_BLOCKED");
882 if (dwStatus
& DN_HARDWARE_ENUM
)
883 SetListViewText(hwndListView
, index
++, L
"DN_HARDWARE_ENUM");
884 if (dwStatus
& DN_NEED_RESTART
)
885 SetListViewText(hwndListView
, index
++, L
"DN_NEED_RESTART");
886 if (dwStatus
& DN_CHILD_WITH_INVALID_ID
)
887 SetListViewText(hwndListView
, index
++, L
"DN_CHILD_WITH_INVALID_ID");
888 if (dwStatus
& DN_HAS_PROBLEM
)
889 SetListViewText(hwndListView
, index
++, L
"DN_HAS_PROBLEM");
890 if (dwStatus
& DN_FILTERED
)
891 SetListViewText(hwndListView
, index
++, L
"DN_FILTERED");
892 if (dwStatus
& DN_LEGACY_DRIVER
)
893 SetListViewText(hwndListView
, index
++, L
"DN_LEGACY_DRIVER");
894 if (dwStatus
& DN_DISABLEABLE
)
895 SetListViewText(hwndListView
, index
++, L
"DN_DISABLEABLE");
896 if (dwStatus
& DN_REMOVABLE
)
897 SetListViewText(hwndListView
, index
++, L
"DN_REMOVABLE");
898 if (dwStatus
& DN_PRIVATE_PROBLEM
)
899 SetListViewText(hwndListView
, index
++, L
"DN_PRIVATE_PROBLEM");
900 if (dwStatus
& DN_MF_PARENT
)
901 SetListViewText(hwndListView
, index
++, L
"DN_MF_PARENT");
902 if (dwStatus
& DN_MF_CHILD
)
903 SetListViewText(hwndListView
, index
++, L
"DN_MF_CHILD");
904 if (dwStatus
& DN_WILL_BE_REMOVED
)
905 SetListViewText(hwndListView
, index
++, L
"DN_WILL_BE_REMOVED");
907 if (dwStatus
& DN_NOT_FIRST_TIMEE
)
908 SetListViewText(hwndListView
, index
++, L
"DN_NOT_FIRST_TIMEE");
909 if (dwStatus
& DN_STOP_FREE_RES
)
910 SetListViewText(hwndListView
, index
++, L
"DN_STOP_FREE_RES");
911 if (dwStatus
& DN_REBAL_CANDIDATE
)
912 SetListViewText(hwndListView
, index
++, L
"DN_REBAL_CANDIDATE");
913 if (dwStatus
& DN_BAD_PARTIAL
)
914 SetListViewText(hwndListView
, index
++, L
"DN_BAD_PARTIAL");
915 if (dwStatus
& DN_NT_ENUMERATOR
)
916 SetListViewText(hwndListView
, index
++, L
"DN_NT_ENUMERATOR");
917 if (dwStatus
& DN_NT_DRIVER
)
918 SetListViewText(hwndListView
, index
++, L
"DN_NT_DRIVER");
920 if (dwStatus
& DN_NEEDS_LOCKING
)
921 SetListViewText(hwndListView
, index
++, L
"DN_NEEDS_LOCKING");
922 if (dwStatus
& DN_ARM_WAKEUP
)
923 SetListViewText(hwndListView
, index
++, L
"DN_ARM_WAKEUP");
924 if (dwStatus
& DN_APM_ENUMERATOR
)
925 SetListViewText(hwndListView
, index
++, L
"DN_APM_ENUMERATOR");
926 if (dwStatus
& DN_APM_DRIVER
)
927 SetListViewText(hwndListView
, index
++, L
"DN_APM_DRIVER");
928 if (dwStatus
& DN_SILENT_INSTALL
)
929 SetListViewText(hwndListView
, index
++, L
"DN_SILENT_INSTALL");
930 if (dwStatus
& DN_NO_SHOW_IN_DM
)
931 SetListViewText(hwndListView
, index
++, L
"DN_NO_SHOW_IN_DM");
932 if (dwStatus
& DN_BOOT_LOG_PROB
)
933 SetListViewText(hwndListView
, index
++, L
"DN_BOOT_LOG_PROB");
935 // swprintf(dap->szTemp, L"0x%08x", dwStatus);
936 // SetListViewText(hwndListView, 0, dap->szTemp);
941 DisplayDevNodeEnumerator(IN PDEVADVPROP_INFO dap
,
942 IN HWND hwndListView
)
944 PSP_DEVINFO_DATA DeviceInfoData
;
948 DWORD dwSize
= 256 * sizeof(WCHAR
);
950 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
952 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
956 DeviceInfoData
= &dap
->DeviceInfoData
;
959 CM_Get_DevNode_Registry_Property_ExW(DeviceInfoData
->DevInst
,
960 CM_DRP_ENUMERATOR_NAME
,
967 SetListViewText(hwndListView
, 0, szBuffer
);
972 DisplayCsFlags(IN PDEVADVPROP_INFO dap
,
973 IN HWND hwndListView
)
978 CM_Get_HW_Prof_Flags_Ex(dap
->szDevName
,
979 0, /* current hardware profile */
985 if (dwValue
& CSCONFIGFLAG_DISABLED
)
986 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DISABLED");
988 if (dwValue
& CSCONFIGFLAG_DO_NOT_CREATE
)
989 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_CREATE");
991 if (dwValue
& CSCONFIGFLAG_DO_NOT_START
)
992 SetListViewText(hwndListView
, index
++, L
"CSCONFIGFLAG_DO_NOT_START");
997 DisplayMatchingDeviceId(IN PDEVADVPROP_INFO dap
,
998 IN HWND hwndListView
)
1000 HDEVINFO DeviceInfoSet
;
1001 PSP_DEVINFO_DATA DeviceInfoData
;
1002 WCHAR szBuffer
[256];
1007 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1009 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1010 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1014 DeviceInfoSet
= dap
->DeviceInfoSet
;
1015 DeviceInfoData
= &dap
->DeviceInfoData
;
1018 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1024 if (hKey
!= INVALID_HANDLE_VALUE
)
1026 dwSize
= 256 * sizeof(WCHAR
);
1027 if (RegQueryValueEx(hKey
,
1028 L
"MatchingDeviceId",
1032 &dwSize
) == ERROR_SUCCESS
)
1034 SetListViewText(hwndListView
, 0, szBuffer
);
1043 DisplayDeviceCoinstallers(IN PDEVADVPROP_INFO dap
,
1044 IN HWND hwndListView
)
1046 HDEVINFO DeviceInfoSet
;
1047 PSP_DEVINFO_DATA DeviceInfoData
;
1056 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1058 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1059 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1063 DeviceInfoSet
= dap
->DeviceInfoSet
;
1064 DeviceInfoData
= &dap
->DeviceInfoData
;
1067 hKey
= SetupDiOpenDevRegKey(DeviceInfoSet
,
1073 if (hKey
!= INVALID_HANDLE_VALUE
)
1076 if (RegQueryValueEx(hKey
,
1081 &dwSize
) == ERROR_SUCCESS
&&
1085 lpBuffer
= HeapAlloc(GetProcessHeap(),
1089 RegQueryValueEx(hKey
,
1096 lpStr
= (LPWSTR
)lpBuffer
;
1100 len
= wcslen(lpStr
) + 1;
1102 SetListViewText(hwndListView
, index
, lpStr
);
1108 HeapFree(GetProcessHeap(),
1119 DisplayClassProperties(IN PDEVADVPROP_INFO dap
,
1120 IN HWND hwndListView
,
1121 IN LPWSTR lpProperty
)
1123 HDEVINFO DeviceInfoSet
;
1124 PSP_DEVINFO_DATA DeviceInfoData
;
1125 WCHAR szClassGuid
[45];
1135 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1137 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1138 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1142 DeviceInfoSet
= dap
->DeviceInfoSet
;
1143 DeviceInfoData
= &dap
->DeviceInfoData
;
1146 dwSize
= 45 * sizeof(WCHAR
);
1147 if (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet
,
1151 (LPBYTE
)szClassGuid
,
1156 pSetupGuidFromString(szClassGuid
,
1159 hKey
= SetupDiOpenClassRegKey(&ClassGuid
,
1161 if (hKey
!= INVALID_HANDLE_VALUE
)
1164 if (RegQueryValueEx(hKey
,
1169 &dwSize
) == ERROR_SUCCESS
&&
1172 lpBuffer
= HeapAlloc(GetProcessHeap(),
1176 RegQueryValueEx(hKey
,
1183 if (dwType
== REG_SZ
)
1185 SetListViewText(hwndListView
, 0, (LPWSTR
)lpBuffer
);
1187 else if (dwType
== REG_MULTI_SZ
)
1189 lpStr
= (LPWSTR
)lpBuffer
;
1193 len
= wcslen(lpStr
) + 1;
1195 SetListViewText(hwndListView
, index
, lpStr
);
1202 HeapFree(GetProcessHeap(),
1213 DisplayDeviceProperties(IN PDEVADVPROP_INFO dap
,
1214 IN HWND hwndComboBox
,
1215 IN HWND hwndListView
)
1219 Index
= (INT
)SendMessage(hwndComboBox
,
1223 if (Index
== CB_ERR
)
1226 (void)ListView_DeleteAllItems(hwndListView
);
1231 SetListViewText(hwndListView
, 0, dap
->szDeviceID
);
1234 case 1: /* Hardware ID */
1235 DisplayDevicePropertyText(dap
,
1240 case 2: /* Compatible IDs */
1241 DisplayDevicePropertyText(dap
,
1243 SPDRP_COMPATIBLEIDS
);
1246 case 3: /* Matching ID */
1247 DisplayMatchingDeviceId(dap
,
1251 case 4: /* Service */
1252 DisplayDevicePropertyText(dap
,
1257 case 5: /* Enumerator */
1258 DisplayDevNodeEnumerator(dap
,
1262 case 6: /* Capabilities */
1263 DisplayDevicePropertyText(dap
,
1265 SPDRP_CAPABILITIES
);
1268 case 7: /* Devnode Flags */
1269 DisplayDevNodeFlags(dap
,
1273 case 8: /* Config Flags */
1274 DisplayDevicePropertyText(dap
,
1279 case 9: /* CSConfig Flags */
1285 case 10: /* Ejection relation */
1288 case 11: /* Removal relations */
1291 case 12: /* Bus relation */
1295 case 13: /* Device Upper Filters */
1296 DisplayDevicePropertyText(dap
,
1298 SPDRP_UPPERFILTERS
);
1301 case 14: /* Device Lower Filters */
1302 DisplayDevicePropertyText(dap
,
1304 SPDRP_LOWERFILTERS
);
1307 case 15: /* Class Upper Filters */
1308 DisplayClassProperties(dap
,
1313 case 16: /* Class Lower Filters */
1314 DisplayClassProperties(dap
,
1319 case 17: /* Class Installer */
1320 DisplayClassProperties(dap
,
1326 case 18: /* Class Coinstaller */
1330 case 19: /* Device Coinstaller */
1331 DisplayDeviceCoinstallers(dap
,
1336 case 20: /* Firmware Revision */
1339 case 21: /* Current Power State */
1342 case 20: /* Power Capabilities */
1345 case 21: /* Power State Mappings */
1350 SetListViewText(hwndListView
, 0, L
"<Not implemented yet>");
1358 AdvProcDetailsDlgProc(IN HWND hwndDlg
,
1363 PDEVADVPROP_INFO dap
;
1364 INT_PTR Ret
= FALSE
;
1366 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
1369 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
1375 switch (LOWORD(wParam
))
1377 case IDC_DETAILSPROPNAME
:
1378 if (HIWORD(wParam
) == CBN_SELCHANGE
)
1380 DisplayDeviceProperties(dap
,
1381 GetDlgItem(hwndDlg
, IDC_DETAILSPROPNAME
),
1382 GetDlgItem(hwndDlg
, IDC_DETAILSPROPVALUE
));
1391 NMHDR
*hdr
= (NMHDR
*)lParam
;
1402 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
1405 SetWindowLongPtr(hwndDlg
,
1409 UpdateDetailsDlg(hwndDlg
,
1423 InitDevUsageActions(IN HWND hwndDlg
,
1425 IN PDEVADVPROP_INFO dap
)
1436 i
!= sizeof(Actions
) / sizeof(Actions
[0]);
1439 /* fill in the device usage combo box */
1440 if (LoadString(hDllInstance
,
1443 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1445 Index
= (INT
)SendMessage(hComboBox
,
1448 (LPARAM
)dap
->szTemp
);
1449 if (Index
!= CB_ERR
)
1451 SendMessage(hComboBox
,
1454 (LPARAM
)Actions
[i
]);
1458 case IDS_ENABLEDEVICE
:
1459 if (dap
->DeviceStarted
)
1461 SendMessage(hComboBox
,
1468 case IDS_DISABLEDEVICE
:
1469 if (!dap
->DeviceStarted
)
1471 SendMessage(hComboBox
,
1488 GetSelectedUsageAction(IN HWND hComboBox
)
1493 Index
= (INT
)SendMessage(hComboBox
,
1497 if (Index
!= CB_ERR
)
1499 INT iRet
= (INT
) SendMessage(hComboBox
,
1514 ApplyGeneralSettings(IN HWND hwndDlg
,
1515 IN PDEVADVPROP_INFO dap
)
1519 if (dap
->DeviceUsageChanged
&& dap
->IsAdmin
&& dap
->CanDisable
)
1521 UINT SelectedUsageAction
;
1522 BOOL NeedReboot
= FALSE
;
1524 SelectedUsageAction
= GetSelectedUsageAction(GetDlgItem(hwndDlg
,
1526 switch (SelectedUsageAction
)
1528 case IDS_ENABLEDEVICE
:
1529 if (!dap
->DeviceStarted
)
1531 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1532 &dap
->DeviceInfoData
,
1539 case IDS_DISABLEDEVICE
:
1540 if (dap
->DeviceStarted
)
1542 Ret
= EnableDevice(dap
->DeviceInfoSet
,
1543 &dap
->DeviceInfoData
,
1558 /* make PropertySheet() return PSM_REBOOTSYSTEM */
1559 PropSheet_RebootSystem(hwndDlg
);
1564 /* FIXME - display an error message */
1565 DPRINT1("Failed to enable/disable device! LastError: %d\n",
1570 Ret
= !dap
->DeviceUsageChanged
;
1572 /* disable the apply button */
1573 PropSheet_UnChanged(GetParent(hwndDlg
),
1575 dap
->DeviceUsageChanged
= FALSE
;
1581 UpdateDevInfo(IN HWND hwndDlg
,
1582 IN PDEVADVPROP_INFO dap
,
1585 HWND hDevUsage
, hPropSheetDlg
, hDevProbBtn
;
1587 ULONG Status
, ProblemNumber
;
1588 SP_DEVINSTALL_PARAMS_W InstallParams
;
1589 UINT TroubleShootStrId
= IDS_TROUBLESHOOTDEV
;
1590 BOOL bFlag
, bDevActionAvailable
= TRUE
;
1591 BOOL bDrvInstalled
= FALSE
;
1593 HDEVINFO DeviceInfoSet
= NULL
;
1594 PSP_DEVINFO_DATA DeviceInfoData
= NULL
;
1595 PROPSHEETHEADER psh
;
1596 DWORD nDriverPages
= 0;
1597 BOOL RecalcPages
= FALSE
;
1599 hPropSheetDlg
= GetParent(hwndDlg
);
1601 if (dap
->PageInitialized
)
1603 /* switch to the General page */
1604 PropSheet_SetCurSelByID(hPropSheetDlg
,
1607 /* remove and destroy the existing device property sheet pages */
1608 if (dap
->DevPropSheets
!= NULL
)
1611 iPage
!= dap
->nDevPropSheets
;
1614 if (dap
->DevPropSheets
[iPage
] != NULL
)
1616 PropSheet_RemovePage(hPropSheetDlg
,
1618 dap
->DevPropSheets
[iPage
]);
1627 if (dap
->FreeDevPropSheets
)
1629 /* don't free the array if it's the one allocated in
1630 DisplayDeviceAdvancedProperties */
1631 HeapFree(GetProcessHeap(),
1633 dap
->DevPropSheets
);
1635 dap
->FreeDevPropSheets
= FALSE
;
1638 dap
->DevPropSheets
= NULL
;
1639 dap
->nDevPropSheets
= 0;
1643 /* create a new device info set and re-open the device */
1644 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1646 SetupDiDestroyDeviceInfoList(dap
->CurrentDeviceInfoSet
);
1649 dap
->ParentDevInst
= 0;
1650 dap
->CurrentDeviceInfoSet
= SetupDiCreateDeviceInfoListEx(NULL
,
1654 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1656 if (SetupDiOpenDeviceInfo(dap
->CurrentDeviceInfoSet
,
1660 &dap
->CurrentDeviceInfoData
))
1662 if (dap
->CloseDevInst
)
1664 SetupDiDestroyDeviceInfoList(dap
->DeviceInfoSet
);
1667 dap
->CloseDevInst
= TRUE
;
1668 dap
->DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1669 dap
->DeviceInfoData
= dap
->CurrentDeviceInfoData
;
1670 dap
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
1678 /* get the parent node from the initial devinst */
1679 CM_Get_Parent_Ex(&dap
->ParentDevInst
,
1680 dap
->DeviceInfoData
.DevInst
,
1685 if (dap
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
1687 DeviceInfoSet
= dap
->CurrentDeviceInfoSet
;
1688 DeviceInfoData
= &dap
->CurrentDeviceInfoData
;
1692 DeviceInfoSet
= dap
->DeviceInfoSet
;
1693 DeviceInfoData
= &dap
->DeviceInfoData
;
1698 DeviceInfoSet
= dap
->DeviceInfoSet
;
1699 DeviceInfoData
= &dap
->DeviceInfoData
;
1702 dap
->HasDriverPage
= FALSE
;
1703 dap
->HasResourcePage
= FALSE
;
1704 dap
->HasPowerPage
= FALSE
;
1705 if (IsDriverInstalled(DeviceInfoData
->DevInst
,
1710 if (SetupDiCallClassInstaller((dap
->ShowRemotePages
?
1711 DIF_ADDREMOTEPROPERTYPAGE_ADVANCED
:
1712 DIF_ADDPROPERTYPAGE_ADVANCED
),
1716 /* get install params */
1717 InstallParams
.cbSize
= sizeof(SP_DEVINSTALL_PARAMS_W
);
1718 if (!SetupDiGetDeviceInstallParamsW(DeviceInfoSet
,
1722 /* zero the flags */
1723 InstallParams
.Flags
= 0;
1726 dap
->HasDriverPage
= !(InstallParams
.Flags
& DI_DRIVERPAGE_ADDED
);
1727 dap
->HasResourcePage
= !(InstallParams
.Flags
& DI_RESOURCEPAGE_ADDED
);
1728 dap
->HasPowerPage
= !(InstallParams
.Flags
& DI_FLAGSEX_POWERPAGE_ADDED
);
1732 /* get the device icon */
1733 if (dap
->hDevIcon
!= NULL
)
1735 DestroyIcon(dap
->hDevIcon
);
1736 dap
->hDevIcon
= NULL
;
1738 if (!SetupDiLoadClassIcon(&DeviceInfoData
->ClassGuid
,
1742 dap
->hDevIcon
= NULL
;
1745 /* get the device name */
1746 if (GetDeviceDescriptionString(DeviceInfoSet
,
1749 sizeof(dap
->szDevName
) / sizeof(dap
->szDevName
[0])))
1751 PropSheet_SetTitle(hPropSheetDlg
,
1756 /* set the device image */
1757 SendDlgItemMessage(hwndDlg
,
1760 (WPARAM
)dap
->hDevIcon
,
1763 /* set the device name edit control text */
1764 SetDlgItemText(hwndDlg
,
1768 /* set the device type edit control text */
1769 if (GetDeviceTypeString(DeviceInfoData
,
1771 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1773 SetDlgItemText(hwndDlg
,
1778 /* set the device manufacturer edit control text */
1779 if (GetDeviceManufacturerString(DeviceInfoSet
,
1782 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1784 SetDlgItemText(hwndDlg
,
1785 IDC_DEVMANUFACTURER
,
1789 /* set the device location edit control text */
1790 if (GetDeviceLocationString(DeviceInfoSet
,
1794 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1796 SetDlgItemText(hwndDlg
,
1801 /* set the device status edit control text */
1802 if (GetDeviceStatusString(DeviceInfoData
->DevInst
,
1805 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])))
1807 SetDlgItemText(hwndDlg
,
1812 /* set the device troubleshoot button text and disable it if necessary */
1813 hDevProbBtn
= GetDlgItem(hwndDlg
,
1815 cr
= CM_Get_DevNode_Status_Ex(&Status
,
1817 DeviceInfoData
->DevInst
,
1820 if (cr
== CR_SUCCESS
&& (Status
& DN_HAS_PROBLEM
))
1822 switch (ProblemNumber
)
1824 case CM_PROB_DEVLOADER_FAILED
:
1826 /* FIXME - only if it's not a root bus devloader,
1827 disable the button otherwise */
1828 TroubleShootStrId
= IDS_UPDATEDRV
;
1832 case CM_PROB_OUT_OF_MEMORY
:
1833 case CM_PROB_ENTRY_IS_WRONG_TYPE
:
1834 case CM_PROB_LACKED_ARBITRATOR
:
1835 case CM_PROB_FAILED_START
:
1837 case CM_PROB_UNKNOWN_RESOURCE
:
1839 TroubleShootStrId
= IDS_UPDATEDRV
;
1843 case CM_PROB_BOOT_CONFIG_CONFLICT
:
1844 case CM_PROB_NORMAL_CONFLICT
:
1845 case CM_PROB_REENUMERATION
:
1847 /* FIXME - Troubleshoot conflict */
1851 case CM_PROB_FAILED_FILTER
:
1852 case CM_PROB_REINSTALL
:
1853 case CM_PROB_FAILED_INSTALL
:
1855 TroubleShootStrId
= IDS_REINSTALLDRV
;
1859 case CM_PROB_DEVLOADER_NOT_FOUND
:
1862 1) if it's a missing system devloader:
1863 - disable the button (Reinstall Driver)
1864 2) if it's not a system devloader but still missing:
1866 3) if it's not a system devloader but the file can be found:
1868 4) if it's a missing or empty software key
1874 case CM_PROB_INVALID_DATA
:
1875 case CM_PROB_PARTIAL_LOG_CONF
:
1876 case CM_PROB_NO_VALID_LOG_CONF
:
1877 case CM_PROB_HARDWARE_DISABLED
:
1878 case CM_PROB_CANT_SHARE_IRQ
:
1879 case CM_PROB_TRANSLATION_FAILED
:
1880 case CM_PROB_SYSTEM_SHUTDOWN
:
1881 case CM_PROB_PHANTOM
:
1882 bDevActionAvailable
= FALSE
;
1885 case CM_PROB_NOT_VERIFIED
:
1886 case CM_PROB_DEVICE_NOT_THERE
:
1887 /* FIXME - search hardware */
1890 case CM_PROB_NEED_RESTART
:
1891 case CM_PROB_WILL_BE_REMOVED
:
1893 case CM_PROB_TOO_EARLY
:
1894 case CM_PROB_DISABLED_SERVICE
:
1895 TroubleShootStrId
= IDS_REBOOT
;
1898 case CM_PROB_REGISTRY
:
1899 /* FIXME - check registry? */
1902 case CM_PROB_DISABLED
:
1903 /* if device was disabled by the user: */
1904 TroubleShootStrId
= IDS_ENABLEDEV
;
1905 /* FIXME - otherwise disable button because the device was
1906 disabled by the system*/
1909 case CM_PROB_DEVLOADER_NOT_READY
:
1910 /* FIXME - if it's a graphics adapter:
1911 - if it's a a secondary adapter and the main adapter
1921 case CM_PROB_FAILED_ADD
:
1922 TroubleShootStrId
= IDS_PROPERTIES
;
1927 if (LoadString(hDllInstance
,
1930 sizeof(dap
->szTemp
) / sizeof(dap
->szTemp
[0])) != 0)
1932 SetWindowText(hDevProbBtn
,
1935 EnableWindow(hDevProbBtn
,
1936 dap
->IsAdmin
&& bDevActionAvailable
);
1938 /* check if the device can be enabled/disabled */
1939 hDevUsage
= GetDlgItem(hwndDlg
,
1942 dap
->CanDisable
= FALSE
;
1943 dap
->DeviceStarted
= FALSE
;
1945 if (CanDisableDevice(DeviceInfoData
->DevInst
,
1949 dap
->CanDisable
= bFlag
;
1952 if (IsDeviceStarted(DeviceInfoData
->DevInst
,
1956 dap
->DeviceStarted
= bFlag
;
1959 /* enable/disable the device usage controls */
1960 EnableWindow(GetDlgItem(hwndDlg
,
1962 dap
->CanDisable
&& dap
->IsAdmin
);
1963 EnableWindow(hDevUsage
,
1964 dap
->CanDisable
&& dap
->IsAdmin
);
1966 /* clear the combobox */
1967 SendMessage(hDevUsage
,
1971 if (dap
->CanDisable
)
1973 InitDevUsageActions(hwndDlg
,
1978 /* find out how many new device property sheets to add.
1979 fake a PROPSHEETHEADER structure, we don't plan to
1980 call PropertySheet again!*/
1981 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
1985 /* get the number of device property sheets for the device */
1986 if (!SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
1991 dap
->PropertySheetType
) &&
1992 nDriverPages
!= 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
1994 dap
->nDevPropSheets
+= nDriverPages
;
2001 /* include the driver page */
2002 if (dap
->HasDriverPage
)
2003 dap
->nDevPropSheets
++;
2005 /* include the details page */
2007 dap
->nDevPropSheets
++;
2009 if (dap
->HasResourcePage
)
2010 dap
->nDevPropSheets
++;
2012 /* add the device property sheets */
2013 if (dap
->nDevPropSheets
!= 0)
2015 dap
->DevPropSheets
= HeapAlloc(GetProcessHeap(),
2017 dap
->nDevPropSheets
* sizeof(HPROPSHEETPAGE
));
2018 if (dap
->DevPropSheets
!= NULL
)
2020 if (nDriverPages
!= 0)
2022 psh
.phpage
= dap
->DevPropSheets
;
2024 /* query the device property sheet pages to add */
2025 if (SetupDiGetClassDevPropertySheets(DeviceInfoSet
,
2028 dap
->nDevPropSheets
,
2030 dap
->PropertySheetType
))
2032 /* add the property sheets */
2034 iPage
!= nDriverPages
;
2037 if (PropSheet_AddPage(hPropSheetDlg
,
2038 dap
->DevPropSheets
[iPage
]))
2044 dap
->FreeDevPropSheets
= TRUE
;
2048 /* cleanup, we were unable to get the device property sheets */
2049 iPage
= nDriverPages
;
2050 dap
->nDevPropSheets
-= nDriverPages
;
2057 /* add the driver page if necessary */
2058 if (dap
->HasDriverPage
)
2060 PROPSHEETPAGE pspDriver
= {0};
2061 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2062 pspDriver
.dwFlags
= PSP_DEFAULT
;
2063 pspDriver
.hInstance
= hDllInstance
;
2064 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDRIVER
);
2065 pspDriver
.pfnDlgProc
= AdvProcDriverDlgProc
;
2066 pspDriver
.lParam
= (LPARAM
)dap
;
2067 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2068 if (dap
->DevPropSheets
[iPage
] != NULL
)
2070 if (PropSheet_AddPage(hPropSheetDlg
,
2071 dap
->DevPropSheets
[iPage
]))
2078 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2079 dap
->DevPropSheets
[iPage
] = NULL
;
2086 /* Add the details page */
2087 PROPSHEETPAGE pspDetails
= {0};
2088 pspDetails
.dwSize
= sizeof(PROPSHEETPAGE
);
2089 pspDetails
.dwFlags
= PSP_DEFAULT
;
2090 pspDetails
.hInstance
= hDllInstance
;
2091 pspDetails
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEDETAILS
);
2092 pspDetails
.pfnDlgProc
= AdvProcDetailsDlgProc
;
2093 pspDetails
.lParam
= (LPARAM
)dap
;
2094 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDetails
);
2095 if (dap
->DevPropSheets
[iPage
] != NULL
)
2097 if (PropSheet_AddPage(hPropSheetDlg
,
2098 dap
->DevPropSheets
[iPage
]))
2105 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2106 dap
->DevPropSheets
[iPage
] = NULL
;
2111 if (dap
->HasResourcePage
)
2113 PROPSHEETPAGE pspDriver
= {0};
2114 pspDriver
.dwSize
= sizeof(PROPSHEETPAGE
);
2115 pspDriver
.dwFlags
= PSP_DEFAULT
;
2116 pspDriver
.hInstance
= hDllInstance
;
2117 pspDriver
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICERESOURCES
);
2118 pspDriver
.pfnDlgProc
= ResourcesProcDriverDlgProc
;
2119 pspDriver
.lParam
= (LPARAM
)dap
;
2120 dap
->DevPropSheets
[iPage
] = dap
->pCreatePropertySheetPageW(&pspDriver
);
2121 if (dap
->DevPropSheets
[iPage
] != NULL
)
2123 if (PropSheet_AddPage(hPropSheetDlg
,
2124 dap
->DevPropSheets
[iPage
]))
2131 dap
->pDestroyPropertySheetPage(dap
->DevPropSheets
[iPage
]);
2132 dap
->DevPropSheets
[iPage
] = NULL
;
2136 /* FIXME: Add the power page */
2139 dap
->nDevPropSheets
= 0;
2144 PropSheet_RecalcPageSizes(hPropSheetDlg
);
2147 /* finally, disable the apply button */
2148 PropSheet_UnChanged(hPropSheetDlg
,
2150 dap
->DeviceUsageChanged
= FALSE
;
2156 DlgParentSubWndProc(IN HWND hwnd
,
2161 PDEVADVPROP_INFO dap
;
2163 dap
= (PDEVADVPROP_INFO
)GetProp(hwnd
,
2164 L
"DevMgrDevChangeSub");
2167 if (uMsg
== WM_DEVICECHANGE
&& !IsWindowVisible(dap
->hWndGeneralPage
))
2169 SendMessage(dap
->hWndGeneralPage
,
2175 /* pass the message the the old window proc */
2176 return CallWindowProc(dap
->ParentOldWndProc
,
2184 /* this is not a good idea if the subclassed window was an ansi
2185 window, but we failed finding out the previous window proc
2186 so we can't use CallWindowProc. This should rarely - if ever -
2189 return DefWindowProc(hwnd
,
2199 AdvPropGeneralDlgProc(IN HWND hwndDlg
,
2204 PDEVADVPROP_INFO dap
;
2205 INT_PTR Ret
= FALSE
;
2207 dap
= (PDEVADVPROP_INFO
)GetWindowLongPtr(hwndDlg
,
2210 if (dap
!= NULL
|| uMsg
== WM_INITDIALOG
)
2216 switch (LOWORD(wParam
))
2220 if (HIWORD(wParam
) == CBN_SELCHANGE
)
2222 PropSheet_Changed(GetParent(hwndDlg
),
2224 dap
->DeviceUsageChanged
= TRUE
;
2229 case IDC_DEVPROBLEM
:
2233 /* display the device problem wizard */
2234 ShowDeviceProblemWizard(hwndDlg
,
2236 &dap
->DeviceInfoData
,
2247 NMHDR
*hdr
= (NMHDR
*)lParam
;
2251 ApplyGeneralSettings(hwndDlg
,
2260 dap
= (PDEVADVPROP_INFO
)((LPPROPSHEETPAGE
)lParam
)->lParam
;
2265 dap
->hWndGeneralPage
= hwndDlg
;
2267 SetWindowLongPtr(hwndDlg
,
2271 /* subclass the parent window to always receive
2272 WM_DEVICECHANGE messages */
2273 hWndParent
= GetParent(hwndDlg
);
2274 if (hWndParent
!= NULL
)
2276 /* subclass the parent window. This is not safe
2277 if the parent window belongs to another thread! */
2278 dap
->ParentOldWndProc
= (WNDPROC
)SetWindowLongPtr(hWndParent
,
2280 (LONG_PTR
)DlgParentSubWndProc
);
2282 if (dap
->ParentOldWndProc
!= NULL
&&
2284 L
"DevMgrDevChangeSub",
2287 dap
->hWndParent
= hWndParent
;
2291 /* do not call UpdateDevInfo directly in here because it modifies
2292 the pages of the property sheet! */
2293 PostMessage(hwndDlg
,
2302 case WM_DEVICECHANGE
:
2304 /* FIXME - don't call UpdateDevInfo for all events */
2305 UpdateDevInfo(hwndDlg
,
2314 UpdateDevInfo(hwndDlg
,
2317 dap
->PageInitialized
= TRUE
;
2323 /* restore the old window proc of the subclassed parent window */
2324 if (dap
->hWndParent
!= NULL
&& dap
->ParentOldWndProc
!= NULL
)
2326 if (SetWindowLongPtr(dap
->hWndParent
,
2328 (LONG_PTR
)dap
->ParentOldWndProc
) == (LONG_PTR
)DlgParentSubWndProc
)
2330 RemoveProp(dap
->hWndParent
,
2331 L
"DevMgrDevChangeSub");
2344 DisplayDeviceAdvancedProperties(IN HWND hWndParent
,
2345 IN LPCWSTR lpDeviceID OPTIONAL
,
2346 IN HDEVINFO DeviceInfoSet
,
2347 IN PSP_DEVINFO_DATA DeviceInfoData
,
2348 IN HINSTANCE hComCtl32
,
2349 IN LPCWSTR lpMachineName
,
2352 PROPSHEETHEADER psh
= {0};
2353 PROPSHEETPAGE pspGeneral
= {0};
2354 PPROPERTYSHEETW pPropertySheetW
;
2355 PCREATEPROPERTYSHEETPAGEW pCreatePropertySheetPageW
;
2356 PDESTROYPROPERTYSHEETPAGE pDestroyPropertySheetPage
;
2357 PDEVADVPROP_INFO DevAdvPropInfo
;
2358 HMACHINE hMachine
= NULL
;
2359 DWORD DevIdSize
= 0;
2362 /* we don't want to statically link against comctl32, so find the
2363 functions we need dynamically */
2365 (PPROPERTYSHEETW
)GetProcAddress(hComCtl32
,
2367 pCreatePropertySheetPageW
=
2368 (PCREATEPROPERTYSHEETPAGEW
)GetProcAddress(hComCtl32
,
2369 "CreatePropertySheetPageW");
2370 pDestroyPropertySheetPage
=
2371 (PDESTROYPROPERTYSHEETPAGE
)GetProcAddress(hComCtl32
,
2372 "DestroyPropertySheetPage");
2373 if (pPropertySheetW
== NULL
||
2374 pCreatePropertySheetPageW
== NULL
||
2375 pDestroyPropertySheetPage
== NULL
)
2380 if (lpDeviceID
== NULL
)
2382 /* find out how much size is needed for the device id */
2383 if (SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2389 DPRINT1("SetupDiGetDeviceInstanceId unexpectedly returned TRUE!\n");
2393 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER
)
2400 DevIdSize
= (DWORD
)wcslen(lpDeviceID
) + 1;
2403 if (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0')
2405 CONFIGRET cr
= CM_Connect_Machine(lpMachineName
,
2407 if (cr
!= CR_SUCCESS
)
2413 /* create the internal structure associated with the "General",
2414 "Driver", ... pages */
2415 DevAdvPropInfo
= HeapAlloc(GetProcessHeap(),
2417 FIELD_OFFSET(DEVADVPROP_INFO
,
2419 (DevIdSize
* sizeof(WCHAR
)));
2420 if (DevAdvPropInfo
== NULL
)
2422 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2426 if (lpDeviceID
== NULL
)
2428 /* read the device instance id */
2429 if (!SetupDiGetDeviceInstanceId(DeviceInfoSet
,
2431 DevAdvPropInfo
->szDeviceID
,
2440 /* copy the device instance id supplied by the caller */
2441 wcscpy(DevAdvPropInfo
->szDeviceID
,
2445 DevAdvPropInfo
->DeviceInfoSet
= DeviceInfoSet
;
2446 DevAdvPropInfo
->DeviceInfoData
= *DeviceInfoData
;
2447 DevAdvPropInfo
->CurrentDeviceInfoSet
= INVALID_HANDLE_VALUE
;
2448 DevAdvPropInfo
->CurrentDeviceInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2450 DevAdvPropInfo
->ShowRemotePages
= (lpMachineName
!= NULL
&& lpMachineName
[0] != L
'\0');
2451 DevAdvPropInfo
->hMachine
= hMachine
;
2452 DevAdvPropInfo
->lpMachineName
= lpMachineName
;
2453 DevAdvPropInfo
->szDevName
[0] = L
'\0';
2454 DevAdvPropInfo
->hComCtl32
= hComCtl32
;
2455 DevAdvPropInfo
->pCreatePropertySheetPageW
= pCreatePropertySheetPageW
;
2456 DevAdvPropInfo
->pDestroyPropertySheetPage
= pDestroyPropertySheetPage
;
2458 DevAdvPropInfo
->IsAdmin
= IsUserAdmin();
2459 DevAdvPropInfo
->DoDefaultDevAction
= ((dwFlags
& DPF_DEVICE_STATUS_ACTION
) != 0);
2460 DevAdvPropInfo
->Extended
= ((dwFlags
& DPF_EXTENDED
) != 0);
2462 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
2463 psh
.dwFlags
= PSH_PROPTITLE
| PSH_NOAPPLYNOW
;
2464 psh
.hwndParent
= hWndParent
;
2465 psh
.pszCaption
= DevAdvPropInfo
->szDevName
;
2467 DevAdvPropInfo
->PropertySheetType
= DevAdvPropInfo
->ShowRemotePages
?
2468 DIGCDP_FLAG_REMOTE_ADVANCED
:
2469 DIGCDP_FLAG_ADVANCED
;
2471 psh
.phpage
= HeapAlloc(GetProcessHeap(),
2473 1 * sizeof(HPROPSHEETPAGE
));
2474 if (psh
.phpage
== NULL
)
2479 /* add the "General" property sheet */
2480 pspGeneral
.dwSize
= sizeof(PROPSHEETPAGE
);
2481 pspGeneral
.dwFlags
= PSP_DEFAULT
;
2482 pspGeneral
.hInstance
= hDllInstance
;
2483 pspGeneral
.pszTemplate
= (LPCWSTR
)MAKEINTRESOURCE(IDD_DEVICEGENERAL
);
2484 pspGeneral
.pfnDlgProc
= AdvPropGeneralDlgProc
;
2485 pspGeneral
.lParam
= (LPARAM
)DevAdvPropInfo
;
2486 psh
.phpage
[psh
.nPages
] = pCreatePropertySheetPageW(&pspGeneral
);
2487 if (psh
.phpage
[psh
.nPages
] != NULL
)
2492 DevAdvPropInfo
->nDevPropSheets
= psh
.nPages
;
2494 if (psh
.nPages
!= 0)
2496 Ret
= pPropertySheetW(&psh
);
2498 /* NOTE: no need to destroy the property sheets anymore! */
2505 /* in case of failure the property sheets must be destroyed */
2506 if (psh
.phpage
!= NULL
)
2512 if (psh
.phpage
[i
] != NULL
)
2514 pDestroyPropertySheetPage(psh
.phpage
[i
]);
2520 if (DevAdvPropInfo
!= NULL
)
2522 if (DevAdvPropInfo
->FreeDevPropSheets
)
2524 /* don't free the array if it's the one allocated in
2525 DisplayDeviceAdvancedProperties */
2526 HeapFree(GetProcessHeap(),
2528 DevAdvPropInfo
->DevPropSheets
);
2531 if (DevAdvPropInfo
->CloseDevInst
)
2533 /* close the device info set in case a new one was created */
2534 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->DeviceInfoSet
);
2537 if (DevAdvPropInfo
->CurrentDeviceInfoSet
!= INVALID_HANDLE_VALUE
)
2539 SetupDiDestroyDeviceInfoList(DevAdvPropInfo
->CurrentDeviceInfoSet
);
2542 if (DevAdvPropInfo
->hDevIcon
!= NULL
)
2544 DestroyIcon(DevAdvPropInfo
->hDevIcon
);
2547 HeapFree(GetProcessHeap(),
2552 if (psh
.phpage
!= NULL
)
2554 HeapFree(GetProcessHeap(),
2559 if (hMachine
!= NULL
)
2561 CM_Disconnect_Machine(hMachine
);
2569 GetDeviceAndComputerName(LPWSTR lpString
,
2571 WCHAR szMachineName
[])
2575 szDeviceID
[0] = L
'\0';
2576 szMachineName
[0] = L
'\0';
2578 while (*lpString
!= L
'\0')
2580 if (*lpString
== L
'/')
2583 if(!_wcsnicmp(lpString
, L
"DeviceID", 8))
2586 if (*lpString
!= L
'\0')
2589 while ((*lpString
!= L
' ') &&
2590 (*lpString
!= L
'\0') &&
2591 (i
<= MAX_DEVICE_ID_LEN
))
2593 szDeviceID
[i
++] = *lpString
++;
2595 szDeviceID
[i
] = L
'\0';
2599 else if (!_wcsnicmp(lpString
, L
"MachineName", 11))
2602 if (*lpString
!= L
'\0')
2605 while ((*lpString
!= L
' ') &&
2606 (*lpString
!= L
'\0') &&
2607 (i
<= MAX_COMPUTERNAME_LENGTH
))
2609 szMachineName
[i
++] = *lpString
++;
2611 szMachineName
[i
] = L
'\0';
2614 /* knock the pointer back one and let the next
2615 * pointer deal with incrementing, otherwise we
2616 * go past the end of the string */
2626 /***************************************************************************
2628 * DeviceAdvancedPropertiesW
2631 * Invokes the device properties dialog, this version may add some property pages
2635 * hWndParent: Handle to the parent window
2636 * lpMachineName: Machine Name, NULL is the local machine
2637 * lpDeviceID: Specifies the device whose properties are to be shown
2640 * Always returns -1, a call to GetLastError returns 0 if successful
2646 DeviceAdvancedPropertiesW(IN HWND hWndParent OPTIONAL
,
2647 IN LPCWSTR lpMachineName OPTIONAL
,
2648 IN LPCWSTR lpDeviceID
)
2651 SP_DEVINFO_DATA DevInfoData
;
2652 HINSTANCE hComCtl32
;
2655 if (lpDeviceID
== NULL
)
2657 SetLastError(ERROR_INVALID_PARAMETER
);
2661 /* dynamically load comctl32 */
2662 hComCtl32
= LoadAndInitComctl32();
2663 if (hComCtl32
!= NULL
)
2665 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2669 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2671 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2672 if (SetupDiOpenDeviceInfo(hDevInfo
,
2678 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2687 SetupDiDestroyDeviceInfoList(hDevInfo
);
2690 FreeLibrary(hComCtl32
);
2697 /***************************************************************************
2699 * DeviceAdvancedPropertiesA
2702 * Invokes the device properties dialog, this version may add some property pages
2706 * hWndParent: Handle to the parent window
2707 * lpMachineName: Machine Name, NULL is the local machine
2708 * lpDeviceID: Specifies the device whose properties are to be shown
2711 * Always returns -1, a call to GetLastError returns 0 if successful
2717 DeviceAdvancedPropertiesA(IN HWND hWndParent OPTIONAL
,
2718 IN LPCSTR lpMachineName OPTIONAL
,
2719 IN LPCSTR lpDeviceID
)
2721 LPWSTR lpMachineNameW
= NULL
;
2722 LPWSTR lpDeviceIDW
= NULL
;
2725 if (lpMachineName
!= NULL
)
2727 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2733 if (lpDeviceID
!= NULL
)
2735 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2742 Ret
= DeviceAdvancedPropertiesW(hWndParent
,
2747 if (lpMachineNameW
!= NULL
)
2749 HeapFree(GetProcessHeap(),
2753 if (lpDeviceIDW
!= NULL
)
2755 HeapFree(GetProcessHeap(),
2764 /***************************************************************************
2766 * DevicePropertiesExA
2769 * Invokes the extended device properties dialog
2772 * hWndParent: Handle to the parent window
2773 * lpMachineName: Machine Name, NULL is the local machine
2774 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2775 * bShowDevMgr is nonzero
2776 * dwFlags: This parameter can be a combination of the following flags:
2777 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2778 * the default device status action button
2779 * to be clicked (Troubleshoot, Enable
2781 * bShowDevMgr: If non-zero it displays the device manager instead of
2782 * the advanced device property dialog
2785 * 1: if bShowDevMgr is non-zero and no error occured
2786 * -1: a call to GetLastError returns 0 if successful
2792 DevicePropertiesExA(IN HWND hWndParent OPTIONAL
,
2793 IN LPCSTR lpMachineName OPTIONAL
,
2794 IN LPCSTR lpDeviceID OPTIONAL
,
2795 IN DWORD dwFlags OPTIONAL
,
2796 IN BOOL bShowDevMgr
)
2798 LPWSTR lpMachineNameW
= NULL
;
2799 LPWSTR lpDeviceIDW
= NULL
;
2802 if (lpMachineName
!= NULL
)
2804 if (!(lpMachineNameW
= ConvertMultiByteToUnicode(lpMachineName
,
2810 if (lpDeviceID
!= NULL
)
2812 if (!(lpDeviceIDW
= ConvertMultiByteToUnicode(lpDeviceID
,
2819 Ret
= DevicePropertiesExW(hWndParent
,
2826 if (lpMachineNameW
!= NULL
)
2828 HeapFree(GetProcessHeap(),
2832 if (lpDeviceIDW
!= NULL
)
2834 HeapFree(GetProcessHeap(),
2843 /***************************************************************************
2845 * DevicePropertiesExW
2848 * Invokes the extended device properties dialog
2851 * hWndParent: Handle to the parent window
2852 * lpMachineName: Machine Name, NULL is the local machine
2853 * lpDeviceID: Specifies the device whose properties are to be shown, optional if
2854 * bShowDevMgr is nonzero
2855 * dwFlags: This parameter can be a combination of the following flags:
2856 * * DPF_DEVICE_STATUS_ACTION: Only valid if bShowDevMgr, causes
2857 * the default device status action button
2858 * to be clicked (Troubleshoot, Enable
2860 * bShowDevMgr: If non-zero it displays the device manager instead of
2861 * the advanced device property dialog
2864 * 1: if bShowDevMgr is non-zero and no error occured
2865 * -1: a call to GetLastError returns 0 if successful
2871 DevicePropertiesExW(IN HWND hWndParent OPTIONAL
,
2872 IN LPCWSTR lpMachineName OPTIONAL
,
2873 IN LPCWSTR lpDeviceID OPTIONAL
,
2874 IN DWORD dwFlags OPTIONAL
,
2875 IN BOOL bShowDevMgr
)
2879 if (dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
))
2881 DPRINT1("DevPropertiesExW: Invalid flags: 0x%x\n",
2882 dwFlags
& ~(DPF_EXTENDED
| DPF_DEVICE_STATUS_ACTION
));
2883 SetLastError(ERROR_INVALID_FLAGS
);
2889 DPRINT("DevPropertiesExW doesn't support bShowDevMgr!\n");
2890 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2895 SP_DEVINFO_DATA DevInfoData
;
2896 HINSTANCE hComCtl32
;
2898 if (lpDeviceID
== NULL
)
2900 SetLastError(ERROR_INVALID_PARAMETER
);
2904 /* dynamically load comctl32 */
2905 hComCtl32
= LoadAndInitComctl32();
2906 if (hComCtl32
!= NULL
)
2908 hDevInfo
= SetupDiCreateDeviceInfoListEx(NULL
,
2912 if (hDevInfo
!= INVALID_HANDLE_VALUE
)
2914 DevInfoData
.cbSize
= sizeof(SP_DEVINFO_DATA
);
2915 if (SetupDiOpenDeviceInfo(hDevInfo
,
2921 Ret
= DisplayDeviceAdvancedProperties(hWndParent
,
2930 SetupDiDestroyDeviceInfoList(hDevInfo
);
2933 FreeLibrary(hComCtl32
);
2941 /***************************************************************************
2946 * Invokes the device properties dialog directly
2949 * hWndParent: Handle to the parent window
2950 * lpMachineName: Machine Name, NULL is the local machine
2951 * lpDeviceID: Specifies the device whose properties are to be shown
2952 * bShowDevMgr: If non-zero it displays the device manager instead of
2953 * the device property dialog
2956 * >=0: if no errors occured
2957 * -1: if errors occured
2965 DevicePropertiesA(HWND hWndParent
,
2966 LPCSTR lpMachineName
,
2970 return DevicePropertiesExA(hWndParent
,
2978 /***************************************************************************
2983 * Invokes the device properties dialog directly
2986 * hWndParent: Handle to the parent window
2987 * lpMachineName: Machine Name, NULL is the local machine
2988 * lpDeviceID: Specifies the device whose properties are to be shown
2989 * bShowDevMgr: If non-zero it displays the device manager instead of
2990 * the device property dialog
2993 * >=0: if no errors occured
2994 * -1: if errors occured
3002 DevicePropertiesW(HWND hWndParent
,
3003 LPCWSTR lpMachineName
,
3007 return DevicePropertiesExW(hWndParent
,
3015 /***************************************************************************
3017 * DeviceProperties_RunDLLA
3020 * Invokes the device properties dialog
3023 * hWndParent: Handle to the parent window
3024 * hInst: Handle to the application instance
3025 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3027 * nCmdShow: Specifies how the window should be shown
3034 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3035 * (/MachineName is optional). This function only parses this string and eventually
3036 * calls DeviceProperties().
3042 DeviceProperties_RunDLLA(HWND hWndParent
,
3047 LPWSTR lpDeviceCmdW
= NULL
;
3049 if (lpDeviceCmd
!= NULL
)
3051 if ((lpDeviceCmdW
= ConvertMultiByteToUnicode(lpDeviceCmd
,
3054 DeviceProperties_RunDLLW(hWndParent
,
3061 if (lpDeviceCmdW
!= NULL
)
3063 HeapFree(GetProcessHeap(),
3070 /***************************************************************************
3072 * DeviceProperties_RunDLLW
3075 * Invokes the device properties dialog
3078 * hWndParent: Handle to the parent window
3079 * hInst: Handle to the application instance
3080 * lpDeviceCmd: A command that includes the DeviceID of the properties to be shown,
3082 * nCmdShow: Specifies how the window should be shown
3089 * - lpDeviceCmd is a string in the form of "/MachineName MACHINE /DeviceID DEVICEPATH"
3090 * (/MachineName is optional). This function only parses this string and eventually
3091 * calls DeviceProperties().
3097 DeviceProperties_RunDLLW(HWND hWndParent
,
3099 LPCWSTR lpDeviceCmd
,
3102 WCHAR szDeviceID
[MAX_DEVICE_ID_LEN
+1];
3103 WCHAR szMachineName
[MAX_COMPUTERNAME_LENGTH
+1];
3104 LPWSTR lpString
= (LPWSTR
)lpDeviceCmd
;
3106 if (!GetDeviceAndComputerName(lpString
,
3110 DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID
, szMachineName
);
3114 DevicePropertiesW(hWndParent
,