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.

115 lines
3.3 KiB

  1. // LogonPage.cpp : Implementation of CLogonPage
  2. #include "stdafx.h"
  3. #include "MainPage.h"
  4. #include "LogonPage.h"
  5. EXTERN_C const CLSID CLSID_LogonPage = __uuidof(CLogonPage);
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CLogonPage
  8. LPWSTR CLogonPage::c_aHTML[] =
  9. {
  10. L"res://nusrmgr.exe/logonpage.htm",
  11. L"res://nusrmgr.exe/logonpage_sec.htm"
  12. };
  13. STDMETHODIMP CLogonPage::Reinitialize(ULONG /*reserved*/)
  14. {
  15. _bFriendlyUIEnabled = VARIANT_FALSE;
  16. _bMultipleUsersEnabled = VARIANT_FALSE;
  17. CComPtr<ILocalMachine> spLocalMachine;
  18. if (SUCCEEDED(spLocalMachine.CoCreateInstance(CLSID_ShellLocalMachine)))
  19. {
  20. spLocalMachine->get_isFriendlyUIEnabled(&_bFriendlyUIEnabled);
  21. spLocalMachine->get_isMultipleUsersEnabled(&_bMultipleUsersEnabled);
  22. }
  23. if (NULL != _pLogonTypeCheckbox)
  24. _pLogonTypeCheckbox->put_checked(_bFriendlyUIEnabled);
  25. if (NULL != _pTSModeCheckbox)
  26. _pTSModeCheckbox->put_checked(VARIANT_FALSE == _bMultipleUsersEnabled ? VARIANT_TRUE : VARIANT_FALSE);
  27. return S_OK;
  28. }
  29. STDMETHODIMP CLogonPage::initPage(IDispatch* pdispLogonTypeCheckbox, IDispatch* pdispTSModeCheckbox)
  30. {
  31. ATOMICRELEASE(_pLogonTypeCheckbox);
  32. ATOMICRELEASE(_pTSModeCheckbox);
  33. if (NULL != pdispLogonTypeCheckbox)
  34. pdispLogonTypeCheckbox->QueryInterface(&_pLogonTypeCheckbox);
  35. if (NULL != pdispTSModeCheckbox)
  36. pdispTSModeCheckbox->QueryInterface(&_pTSModeCheckbox);
  37. return Reinitialize(0);
  38. }
  39. STDMETHODIMP CLogonPage::onOK()
  40. {
  41. HRESULT hr = S_OK;
  42. VARIANT_BOOL bFriendlyUIEnabled = VARIANT_FALSE;
  43. VARIANT_BOOL bMultipleUsersDisabled = VARIANT_TRUE;
  44. if (NULL != _pLogonTypeCheckbox)
  45. _pLogonTypeCheckbox->get_checked(&bFriendlyUIEnabled);
  46. if (NULL != _pTSModeCheckbox)
  47. _pTSModeCheckbox->get_checked(&bMultipleUsersDisabled);
  48. CComPtr<ILocalMachine> spLocalMachine;
  49. if (bFriendlyUIEnabled != _bFriendlyUIEnabled)
  50. {
  51. hr = spLocalMachine.CoCreateInstance(CLSID_ShellLocalMachine);
  52. if (spLocalMachine)
  53. {
  54. hr = spLocalMachine->put_isFriendlyUIEnabled(bFriendlyUIEnabled);
  55. if (SUCCEEDED(hr))
  56. {
  57. _bFriendlyUIEnabled = bFriendlyUIEnabled;
  58. }
  59. else
  60. {
  61. //alert(L_FriendlyUI_ErrorMessage);
  62. }
  63. }
  64. }
  65. if (bMultipleUsersDisabled == _bMultipleUsersEnabled)
  66. {
  67. if (!spLocalMachine)
  68. hr = spLocalMachine.CoCreateInstance(CLSID_ShellLocalMachine);
  69. if (spLocalMachine)
  70. {
  71. hr = spLocalMachine->put_isMultipleUsersEnabled(VARIANT_FALSE == bMultipleUsersDisabled ? VARIANT_TRUE : VARIANT_FALSE);
  72. if (SUCCEEDED(hr))
  73. {
  74. _bMultipleUsersEnabled = VARIANT_FALSE == bMultipleUsersDisabled ? VARIANT_TRUE : VARIANT_FALSE;
  75. }
  76. else
  77. {
  78. // There are 2 possible errors here. Need to check with
  79. // VTan about what they are, then make 2 different messages.
  80. //alert(L_MultiUser_ErrorMessage);
  81. }
  82. }
  83. }
  84. if (SUCCEEDED(hr))
  85. {
  86. if (NULL != _pTaskFrame)
  87. hr = _pTaskFrame->ShowPage(CLSID_MainPage, TRUE);
  88. else
  89. hr = E_UNEXPECTED;
  90. }
  91. return hr;
  92. }