Leaked source code of windows server 2003
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.

112 lines
2.8 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: lflags.cpp
  7. //
  8. // Contents: implementation of CLocalPolRegFlags
  9. //
  10. //----------------------------------------------------------------------------
  11. #include "stdafx.h"
  12. #include "wsecmgr.h"
  13. #include "snapmgr.h"
  14. #include "attr.h"
  15. #include "LFlags.h"
  16. #include "util.h"
  17. #include "chklist.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CLocalPolRegFlags dialog
  25. CLocalPolRegFlags::CLocalPolRegFlags()
  26. : CConfigRegFlags(IDD)
  27. {
  28. //{{AFX_DATA_INIT(CLocalPolRegFlags)
  29. //}}AFX_DATA_INIT
  30. m_pHelpIDs = (DWORD_PTR) a235HelpIDs;
  31. m_uTemplateResID = IDD;
  32. }
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CLocalPolRegFlags message handlers
  35. BOOL CLocalPolRegFlags::OnApply()
  36. {
  37. if ( !m_bReadOnly )
  38. {
  39. DWORD dw = 0;
  40. CWnd *wndCL = NULL;
  41. DWORD fFlags = 0;
  42. UpdateData(TRUE);
  43. wndCL = GetDlgItem(IDC_CHECKBOX);
  44. ASSERT(wndCL != NULL);
  45. if (!m_bConfigure || !wndCL)
  46. dw = SCE_NO_VALUE;
  47. else
  48. {
  49. int nItems = (int) wndCL->SendMessage(CLM_GETITEMCOUNT,0,0);
  50. for (int i=0;i<nItems;i++)
  51. {
  52. dw = (DWORD) wndCL->SendMessage(CLM_GETSTATE,MAKELONG(i,1));
  53. if (CLST_CHECKED == dw)
  54. fFlags |= (DWORD)wndCL->SendMessage(CLM_GETITEMDATA,i);
  55. }
  56. }
  57. PSCE_REGISTRY_VALUE_INFO prv=(PSCE_REGISTRY_VALUE_INFO)(m_pData->GetBase());
  58. //
  59. // this address should never be NULL
  60. //
  61. ASSERT(prv);
  62. if ( prv )
  63. {
  64. if ( prv->Value )
  65. LocalFree(prv->Value);
  66. prv->Value = NULL;
  67. if ( fFlags != SCE_NO_VALUE )
  68. {
  69. CString strTmp;
  70. // allocate buffer
  71. strTmp.Format(TEXT("%d"), fFlags);
  72. prv->Value = (PWSTR)LocalAlloc(0, (strTmp.GetLength()+1)*sizeof(TCHAR));
  73. if ( prv->Value )
  74. //This is a safe usage.
  75. lstrcpy(prv->Value,(LPCTSTR)strTmp);
  76. else
  77. return FALSE;
  78. }
  79. m_pSnapin->UpdateLocalPolRegValue(m_pData);
  80. }
  81. }
  82. // Class hieirarchy is bad - call CAttribute base method directly
  83. return CAttribute::OnApply();
  84. }
  85. void CLocalPolRegFlags::Initialize(CResult * pResult)
  86. {
  87. CConfigRegFlags::Initialize(pResult);
  88. if (!m_bConfigure) {
  89. //
  90. // Since we don't have a UI to change configuration
  91. // fake it by "configuring" with an invalid setting
  92. //
  93. m_bConfigure = TRUE;
  94. }
  95. }