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.

155 lines
3.6 KiB

  1. /*++
  2. Copyright (C) 1997-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. // PrefDlg.cpp : implementation file
  8. //
  9. #include "stdafx.h"
  10. #include "WMITest.h"
  11. #include "PrefDlg.h"
  12. #include "Utils.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CPrefDlg dialog
  20. CPrefDlg::CPrefDlg(CWnd* pParent /*=NULL*/)
  21. : CDialog(CPrefDlg::IDD, pParent)
  22. {
  23. //{{AFX_DATA_INIT(CPrefDlg)
  24. m_bLoadLast = FALSE;
  25. m_bShowSystem = FALSE;
  26. m_bShowInherited = FALSE;
  27. m_bEnablePrivsOnStartup = FALSE;
  28. m_bPrivsEnabled = FALSE;
  29. //}}AFX_DATA_INIT
  30. m_dwUpdateFlag = WBEM_FLAG_CREATE_OR_UPDATE;
  31. m_dwClassUpdateMode = WBEM_FLAG_UPDATE_COMPATIBLE;
  32. }
  33. void CPrefDlg::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CDialog::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(CPrefDlg)
  37. DDX_Check(pDX, IDC_LOAD_LAST, m_bLoadLast);
  38. DDX_Check(pDX, IDC_SYSTEM_PROPS, m_bShowSystem);
  39. DDX_Check(pDX, IDC_SHOW_INHERITED, m_bShowInherited);
  40. DDX_Check(pDX, IDC_PRIVS_ON_START, m_bEnablePrivsOnStartup);
  41. DDX_Check(pDX, IDC_ENABLE_PRIVS, m_bPrivsEnabled);
  42. //}}AFX_DATA_MAP
  43. if (!pDX->m_bSaveAndValidate)
  44. {
  45. DWORD dwID;
  46. switch(m_dwUpdateFlag)
  47. {
  48. case WBEM_FLAG_CREATE_ONLY:
  49. dwID = IDC_CREATE;
  50. break;
  51. case WBEM_FLAG_UPDATE_ONLY:
  52. dwID = IDC_UPDATE;
  53. break;
  54. default:
  55. case WBEM_FLAG_CREATE_OR_UPDATE:
  56. dwID = IDC_CREATE_OR_UPDATE;
  57. break;
  58. }
  59. CheckRadioButton(IDC_CREATE, IDC_CREATE_OR_UPDATE, dwID);
  60. switch(m_dwClassUpdateMode)
  61. {
  62. case WBEM_FLAG_UPDATE_COMPATIBLE:
  63. dwID = IDC_COMPATIBLE;
  64. break;
  65. case WBEM_FLAG_UPDATE_SAFE_MODE:
  66. dwID = IDC_SAFE;
  67. break;
  68. default:
  69. case WBEM_FLAG_UPDATE_FORCE_MODE:
  70. dwID = IDC_FORCE;
  71. break;
  72. }
  73. CheckRadioButton(IDC_COMPATIBLE, IDC_FORCE, dwID);
  74. if (m_bPrivsEnabled)
  75. GetDlgItem(IDC_ENABLE_PRIVS)->EnableWindow(FALSE);
  76. }
  77. else
  78. {
  79. switch(GetCheckedRadioButton(IDC_CREATE, IDC_CREATE_OR_UPDATE))
  80. {
  81. case IDC_CREATE:
  82. m_dwUpdateFlag = WBEM_FLAG_CREATE_ONLY;
  83. break;
  84. case IDC_UPDATE:
  85. m_dwUpdateFlag = WBEM_FLAG_UPDATE_ONLY;
  86. break;
  87. default:
  88. case IDC_CREATE_OR_UPDATE:
  89. m_dwUpdateFlag = WBEM_FLAG_CREATE_OR_UPDATE;
  90. break;
  91. }
  92. switch(GetCheckedRadioButton(IDC_COMPATIBLE, IDC_FORCE))
  93. {
  94. case IDC_COMPATIBLE:
  95. m_dwClassUpdateMode = WBEM_FLAG_UPDATE_COMPATIBLE;
  96. break;
  97. case IDC_SAFE:
  98. m_dwClassUpdateMode = WBEM_FLAG_UPDATE_SAFE_MODE;
  99. break;
  100. default:
  101. case IDC_FORCE:
  102. m_dwClassUpdateMode = WBEM_FLAG_UPDATE_FORCE_MODE;
  103. break;
  104. }
  105. }
  106. }
  107. BEGIN_MESSAGE_MAP(CPrefDlg, CDialog)
  108. //{{AFX_MSG_MAP(CPrefDlg)
  109. ON_BN_CLICKED(IDC_ENABLE_PRIVS, OnEnablePrivs)
  110. //}}AFX_MSG_MAP
  111. END_MESSAGE_MAP()
  112. /////////////////////////////////////////////////////////////////////////////
  113. // CPrefDlg message handlers
  114. void CPrefDlg::OnEnablePrivs()
  115. {
  116. HRESULT hr = EnableAllPrivileges(TOKEN_PROCESS);
  117. if (SUCCEEDED(hr))
  118. GetDlgItem(IDC_ENABLE_PRIVS)->EnableWindow(FALSE);
  119. else
  120. AfxMessageBox(IDS_ENABLE_PRIVS_FAILED, hr);
  121. }