* UPDATE HISTORY:
* 04-04-2004 Created
*/
-#include <precomp.h>
+#include "precomp.h"
#define NDEBUG
#include <debug.h>
-/* setupapi */
-DWORD WINAPI pSetupGuidFromString(PCWSTR pString, LPGUID lpGUID);
-
typedef INT_PTR (WINAPI *PPROPERTYSHEETW)(LPCPROPSHEETHEADERW);
typedef HPROPSHEETPAGE (WINAPI *PCREATEPROPERTYSHEETPAGEW)(LPCPROPSHEETPAGEW);
typedef BOOL (WINAPI *PDESTROYPROPERTYSHEETPAGE)(HPROPSHEETPAGE);
UINT Flags;
struct
{
+ UINT Extended : 1;
UINT FreeDevPropSheets : 1;
UINT CanDisable : 1;
UINT DeviceStarted : 1;
(ULONG_PTR)dap);
break;
}
+ case IDC_UPDATEDRIVER:
+ {
+ if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
+ {
+ BOOL NeedReboot;
+ if (DiShowUpdateDevice(hwndDlg, dap->CurrentDeviceInfoSet, &dap->CurrentDeviceInfoData, 0, &NeedReboot))
+ {
+ if (NeedReboot)
+ {
+ //FIXME: load text from resource file
+ if(MessageBoxW(hwndDlg, L"Reboot now?", L"Reboot required", MB_YESNO | MB_ICONQUESTION) == IDYES)
+ {
+ HANDLE hToken;
+ TOKEN_PRIVILEGES Privileges;
+
+ if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken))
+ {
+ DPRINT("OpenProcessToken failed\n");
+ break;
+ }
+
+ /* Get the LUID for the Shutdown privilege */
+ if (!LookupPrivilegeValueW(NULL, SE_SHUTDOWN_NAME, &Privileges.Privileges[0].Luid))
+ {
+ DPRINT("LookupPrivilegeValue failed\n");
+ break;
+ }
+
+ /* Assign the Shutdown privilege to our process */
+ Privileges.PrivilegeCount = 1;
+ Privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ if (!AdjustTokenPrivileges(hToken, FALSE, &Privileges, 0, NULL, NULL))
+ {
+ DPRINT("AdjustTokenPrivileges failed\n");
+ break;
+ }
+
+ /* Finally shut down the system */
+ if(!ExitWindowsEx(EWX_POWEROFF, SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED))
+ {
+ DPRINT("ExitWindowsEx failed\n");
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
}
break;
}
DisplayDevNodeEnumerator(IN PDEVADVPROP_INFO dap,
IN HWND hwndListView)
{
- HDEVINFO DeviceInfoSet;
PSP_DEVINFO_DATA DeviceInfoData;
DWORD dwType = 0;
if (dap->CurrentDeviceInfoSet != INVALID_HANDLE_VALUE)
{
- DeviceInfoSet = dap->CurrentDeviceInfoSet;
DeviceInfoData = &dap->CurrentDeviceInfoData;
}
else
{
- DeviceInfoSet = dap->DeviceInfoSet;
DeviceInfoData = &dap->DeviceInfoData;
}
dap->nDevPropSheets++;
/* include the details page */
- dap->nDevPropSheets++;
+ if (dap->Extended)
+ dap->nDevPropSheets++;
/* add the device property sheets */
if (dap->nDevPropSheets != 0)
}
}
- if (1)
+ if (dap->Extended)
{
+ /* Add the details page */
PROPSHEETPAGE pspDetails = {0};
pspDetails.dwSize = sizeof(PROPSHEETPAGE);
pspDetails.dwFlags = PSP_DEFAULT;
dap->DevPropSheets[iPage] = NULL;
}
}
- }
- /* FIXME: Add the resources page */
+ /* FIXME: Add the resources page */
+ }
/* FIXME: Add the power page */
}
DevAdvPropInfo->IsAdmin = IsUserAdmin();
DevAdvPropInfo->DoDefaultDevAction = ((dwFlags & DPF_DEVICE_STATUS_ACTION) != 0);
+ DevAdvPropInfo->Extended = ((dwFlags & DPF_EXTENDED) != 0);
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPTITLE | PSH_NOAPPLYNOW;