Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
3.4 KiB

  1. // devpopg.h : header file
  2. //
  3. #ifndef __DEVPOPG_H__
  4. #define __DEVPOPG_H__
  5. /*++
  6. Copyright (C) 1997-1999 Microsoft Corporation
  7. Module Name:
  8. devpopg.h
  9. Abstract:
  10. header file for devpopg.cpp
  11. Author:
  12. William Hsieh (williamh) created
  13. Revision History:
  14. --*/
  15. #include "proppage.h"
  16. #include "wmium.h"
  17. #include "wdmguid.h"
  18. #include "ndisguid.h"
  19. //
  20. // help topic ids
  21. //
  22. #define IDH_DISABLEHELP (DWORD(-1))
  23. #define IDH_DEVMGR_PWRMGR_WAKEENABLE 2003170
  24. #define IDH_DEVMGR_PWRMGR_MGMT_WAKEENABLE 2003185
  25. #define IDH_DEVMGR_PWRMGR_DEVICEENABLE 2003180
  26. typedef struct tagPowerTimeouts {
  27. ULONG ConservationIdleTime;
  28. ULONG PerformanceIdleTime;
  29. } DM_POWER_DEVICE_TIMEOUTS, *PDM_POWER_DEVICE_TIMEOUTS;
  30. class CPowerEnable {
  31. public:
  32. CPowerEnable(const GUID& wmiGuid, ULONG DataBlockSize)
  33. : m_hWmiBlock(INVALID_HANDLE_VALUE),
  34. m_WmiInstDataSize(0), m_pWmiInstData(NULL),
  35. m_DataBlockSize(DataBlockSize)
  36. {
  37. m_wmiGuid = wmiGuid;
  38. m_DevInstId[0] = _T('\0');
  39. }
  40. virtual ~CPowerEnable()
  41. {
  42. Close();
  43. }
  44. BOOL IsOpened()
  45. {
  46. return INVALID_HANDLE_VALUE != m_hWmiBlock;
  47. }
  48. BOOL Get(BOOLEAN& fEnabled);
  49. BOOL Set(BOOLEAN fEnable);
  50. BOOL Open(LPCTSTR DeviceId);
  51. BOOL Close()
  52. {
  53. if (INVALID_HANDLE_VALUE != m_hWmiBlock) {
  54. WmiCloseBlock(m_hWmiBlock);
  55. }
  56. m_hWmiBlock = INVALID_HANDLE_VALUE;
  57. m_DevInstId[0] = _T('\0');
  58. if (m_pWmiInstData) {
  59. delete [] m_pWmiInstData;
  60. m_pWmiInstData = NULL;
  61. }
  62. m_WmiInstDataSize = 0;
  63. return TRUE;
  64. }
  65. operator GUID&()
  66. {
  67. return m_wmiGuid;
  68. }
  69. protected:
  70. WMIHANDLE m_hWmiBlock;
  71. ULONG m_Version;
  72. GUID m_wmiGuid;
  73. ULONG m_WmiInstDataSize;
  74. BYTE* m_pWmiInstData;
  75. ULONG m_DataBlockSize;
  76. TCHAR m_DevInstId[MAX_DEVICE_ID_LEN + 2];
  77. };
  78. class CPowerShutdownEnable : public CPowerEnable {
  79. public:
  80. CPowerShutdownEnable() : CPowerEnable(GUID_POWER_DEVICE_ENABLE, sizeof(BOOLEAN))
  81. {}
  82. // override dtor is not necessary
  83. };
  84. class CPowerWakeEnable : public CPowerEnable {
  85. public:
  86. CPowerWakeEnable() : CPowerEnable(GUID_POWER_DEVICE_WAKE_ENABLE, sizeof(BOOLEAN))
  87. {}
  88. // override dtor is not necessary
  89. };
  90. class CPowerWakeMgmtEnable : public CPowerEnable {
  91. public:
  92. CPowerWakeMgmtEnable() : CPowerEnable(GUID_NDIS_WAKE_ON_MAGIC_PACKET_ONLY, sizeof(BOOLEAN))
  93. {}
  94. // override dtor is not necessary
  95. };
  96. class CDevicePowerMgmtPage : public CPropSheetPage {
  97. public:
  98. CDevicePowerMgmtPage() :
  99. m_pDevice(NULL),
  100. CPropSheetPage(g_hInstance, IDD_DEVPOWER_PAGE)
  101. {}
  102. ~CDevicePowerMgmtPage()
  103. {}
  104. HPROPSHEETPAGE Create(CDevice* pDevice)
  105. {
  106. ASSERT(pDevice);
  107. m_pDevice = pDevice;
  108. // override PROPSHEETPAGE structure here...
  109. m_psp.lParam = (LPARAM)this;
  110. return CreatePage();
  111. }
  112. protected:
  113. virtual BOOL OnInitDialog(LPPROPSHEETPAGE ppsp);
  114. virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  115. virtual BOOL OnApply();
  116. virtual void UpdateControls(LPARAM lParam = 0);
  117. virtual BOOL OnHelp(LPHELPINFO pHelpInfo);
  118. virtual BOOL OnContextMenu(HWND hWnd, WORD xPos, WORD yPos);
  119. private:
  120. CDevice* m_pDevice;
  121. CPowerShutdownEnable m_poShutdownEnable;
  122. CPowerWakeEnable m_poWakeEnable;
  123. CPowerWakeMgmtEnable m_poWakeMgmtEnable;
  124. };
  125. #endif // _DEVPOPG_H__