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.

150 lines
3.6 KiB

  1. // RightsTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #import "\bin\McsDctWorkerObjects.tlb" no_namespace, named_guids
  5. #include "Driver.h"
  6. #include "Rights.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRightsTestDlg property page
  14. IMPLEMENT_DYNCREATE(CRightsTestDlg, CPropertyPage)
  15. CRightsTestDlg::CRightsTestDlg() : CPropertyPage(CRightsTestDlg::IDD)
  16. {
  17. //{{AFX_DATA_INIT(CRightsTestDlg)
  18. m_Computer = _T("");
  19. m_AppendToFile = FALSE;
  20. m_Filename = _T("");
  21. m_NoChange = FALSE;
  22. m_RemoveExisting = FALSE;
  23. m_Source = _T("");
  24. m_Target = _T("");
  25. m_SourceAccount = _T("");
  26. m_TargetAccount = _T("");
  27. //}}AFX_DATA_INIT
  28. }
  29. CRightsTestDlg::~CRightsTestDlg()
  30. {
  31. }
  32. void CRightsTestDlg::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CPropertyPage::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(CRightsTestDlg)
  36. DDX_Text(pDX, IDC_COMPUTER, m_Computer);
  37. DDX_Check(pDX, IDC_APPEND, m_AppendToFile);
  38. DDX_Text(pDX, IDC_FILENAME, m_Filename);
  39. DDX_Check(pDX, IDC_NOCHANGE, m_NoChange);
  40. DDX_Check(pDX, IDC_REMOVE_EXISTING, m_RemoveExisting);
  41. DDX_Text(pDX, IDC_Source, m_Source);
  42. DDX_Text(pDX, IDC_Target, m_Target);
  43. DDX_Text(pDX, IDC_SOURCE_ACCT, m_SourceAccount);
  44. DDX_Text(pDX, IDC_TARGET_ACCT, m_TargetAccount);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(CRightsTestDlg, CPropertyPage)
  48. //{{AFX_MSG_MAP(CRightsTestDlg)
  49. ON_BN_CLICKED(IDC_COPY_RIGHTS, OnCopyRights)
  50. ON_BN_CLICKED(IDC_EXPORTTOFILE, OnExporttofile)
  51. ON_BN_CLICKED(IDC_OPEN_SOURCE, OnOpenSource)
  52. ON_BN_CLICKED(IDC_OPEN_TARGET, OnOpenTarget)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CRightsTestDlg message handlers
  57. void CRightsTestDlg::OnCopyRights()
  58. {
  59. UpdateData(TRUE);
  60. CWaitCursor w;
  61. CString result;
  62. HRESULT hr = pRights->raw_CopyUserRights(m_SourceAccount.AllocSysString(),m_TargetAccount.AllocSysString());
  63. if ( SUCCEEDED(hr) )
  64. {
  65. result = L"CopyRights succeeded!";
  66. }
  67. else
  68. {
  69. result.Format(L"CopyRights failed, hr=%lx",hr);
  70. }
  71. MessageBox(result);
  72. }
  73. void CRightsTestDlg::OnExporttofile()
  74. {
  75. UpdateData(TRUE);
  76. CWaitCursor w;
  77. CString result;
  78. HRESULT hr = pRights->raw_ExportUserRights(m_Computer.AllocSysString(),m_Filename.AllocSysString(),m_AppendToFile);
  79. if ( SUCCEEDED(hr) )
  80. {
  81. result = L"ExportToFile succeeded!";
  82. }
  83. else
  84. {
  85. result.Format(L"Export failed, hr=%lx",hr);
  86. }
  87. MessageBox(result);
  88. }
  89. void CRightsTestDlg::OnOpenSource()
  90. {
  91. UpdateData(TRUE);
  92. CWaitCursor w;
  93. HRESULT hr = pRights->raw_OpenSourceServer(m_Source.AllocSysString());
  94. CString result;
  95. if ( SUCCEEDED(hr) )
  96. {
  97. result = L"OpenSource succeeded!";
  98. }
  99. else
  100. {
  101. result.Format(L"OpenSource failed, hr=%lx",hr);
  102. }
  103. MessageBox(result);
  104. }
  105. void CRightsTestDlg::OnOpenTarget()
  106. {
  107. UpdateData(TRUE);
  108. CWaitCursor w;
  109. HRESULT hr = pRights->raw_OpenTargetServer(m_Target.AllocSysString());
  110. CString result;
  111. if ( SUCCEEDED(hr) )
  112. {
  113. result = L"OpenTarget succeeded!";
  114. }
  115. else
  116. {
  117. result.Format(L"OpenTarget failed, hr=%lx",hr);
  118. }
  119. MessageBox(result);
  120. }
  121. BOOL CRightsTestDlg::OnSetActive()
  122. {
  123. HRESULT hr = pRights.CreateInstance(CLSID_UserRights);
  124. if ( FAILED(hr) )
  125. {
  126. CString str;
  127. str.Format(L"Failed to create UserRights COM object, hr=%lx",hr);
  128. MessageBox(str);
  129. }
  130. return CPropertyPage::OnSetActive();
  131. }