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.

80 lines
1.7 KiB

  1. // RenameTestDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "driver.h"
  5. #include "Rename.h"
  6. #import "\bin\McsDctWorkerObjects.tlb" no_namespace, named_guids
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CRenameTestDlg property page
  14. IMPLEMENT_DYNCREATE(CRenameTestDlg, CPropertyPage)
  15. CRenameTestDlg::CRenameTestDlg() : CPropertyPage(CRenameTestDlg::IDD)
  16. {
  17. //{{AFX_DATA_INIT(CRenameTestDlg)
  18. m_Computer = _T("");
  19. m_NoChange = FALSE;
  20. //}}AFX_DATA_INIT
  21. }
  22. CRenameTestDlg::~CRenameTestDlg()
  23. {
  24. }
  25. void CRenameTestDlg::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CPropertyPage::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CRenameTestDlg)
  29. DDX_Text(pDX, IDC_COMPUTER, m_Computer);
  30. DDX_Check(pDX, IDC_NOCHANGE, m_NoChange);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CRenameTestDlg, CPropertyPage)
  34. //{{AFX_MSG_MAP(CRenameTestDlg)
  35. ON_BN_CLICKED(IDC_RENAME, OnRename)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CRenameTestDlg message handlers
  40. void CRenameTestDlg::OnRename()
  41. {
  42. UpdateData(TRUE);
  43. CWaitCursor w;
  44. IRenameComputerPtr pPtr;
  45. CString msg;
  46. HRESULT hr;
  47. hr = pPtr.CreateInstance(CLSID_ChangeDomain);
  48. if ( FAILED(hr) )
  49. {
  50. msg.Format(L"Failed to create ChangeDomain COM object, CoCreateInstance returned %lx",hr);
  51. }
  52. else
  53. {
  54. pPtr->NoChange = m_NoChange;
  55. hr = pPtr->RenameLocalComputer(m_Computer.AllocSysString());
  56. if ( SUCCEEDED(hr) )
  57. {
  58. msg = L"Rename succeeded!";
  59. }
  60. else
  61. {
  62. msg.Format(L"Rename failed, hr=%lx",hr);
  63. }
  64. }
  65. MessageBox(msg);
  66. }