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.

177 lines
4.9 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "pgSveDef.h"
  6. // JMC: This is taken from access.cpl
  7. /***********************************************************************/
  8. // CopyKey( hKey, hKeyDst, name )
  9. // create the destination key
  10. // for each value
  11. // CopyValue
  12. // for each subkey
  13. // CopyKey
  14. DWORD CopyKey( HKEY hkeySrc, HKEY hkeyDst, LPSTR szKey )
  15. {
  16. HKEY hkeyOld = NULL, hkeyNew = NULL;
  17. char szValue[128];
  18. BYTE szData[128];
  19. char szBuffer[128];
  20. DWORD iStatus;
  21. UINT nValue, nKey;
  22. DWORD iValueLen, iDataLen;
  23. DWORD dwType;
  24. iStatus = RegOpenKeyExA( hkeySrc, szKey, 0, KEY_ENUMERATE_SUB_KEYS |
  25. KEY_SET_VALUE, &hkeyOld );
  26. if( iStatus != ERROR_SUCCESS)
  27. goto exit;
  28. iStatus = RegOpenKeyExA( hkeyDst, szKey, 0, KEY_ENUMERATE_SUB_KEYS, &hkeyNew );
  29. if( iStatus != ERROR_SUCCESS )
  30. {
  31. iStatus = RegCreateKeyExA( hkeyDst, szKey, 0, "", 0, KEY_SET_VALUE,
  32. NULL, &hkeyNew, NULL);
  33. if( iStatus != ERROR_SUCCESS )
  34. {
  35. goto exit;
  36. }
  37. }
  38. //*********** copy the values **************** //
  39. for( nValue = 0, iValueLen=sizeof szValue, iDataLen=sizeof szValue;
  40. ERROR_SUCCESS == (iStatus = RegEnumValueA(hkeyOld,
  41. nValue,
  42. szValue,
  43. &iValueLen,
  44. NULL, // reserved
  45. &dwType, // don't need type
  46. szData,
  47. &iDataLen ) );
  48. nValue ++, iValueLen=sizeof szValue, iDataLen=sizeof szValue )
  49. {
  50. iStatus = RegSetValueExA( hkeyNew,
  51. szValue,
  52. 0, // reserved
  53. dwType,
  54. szData,
  55. iDataLen);
  56. }
  57. if( iStatus != ERROR_NO_MORE_ITEMS )
  58. {
  59. goto exit;
  60. }
  61. //*********** copy the subtrees ************** //
  62. for( nKey = 0;
  63. ERROR_SUCCESS == (iStatus = RegEnumKeyA(hkeyOld,nKey,szBuffer,sizeof(szBuffer)));
  64. nKey ++ )
  65. {
  66. iStatus = CopyKey( hkeyOld, hkeyNew, szBuffer );
  67. if( iStatus != ERROR_NO_MORE_ITEMS && iStatus != ERROR_SUCCESS )
  68. {
  69. goto exit;
  70. }
  71. }
  72. if( iStatus == ERROR_NO_MORE_ITEMS )
  73. iStatus = ERROR_SUCCESS;
  74. exit:
  75. if (hkeyOld)
  76. RegCloseKey(hkeyOld);
  77. if (hkeyNew)
  78. RegCloseKey(hkeyNew);
  79. return iStatus;
  80. }
  81. DWORD SaveLookToDefaultUser( void )
  82. {
  83. DWORD iStatus;
  84. HKEY hkeyDst;
  85. iStatus = RegOpenKeyExA( HKEY_USERS, ".DEFAULT", 0,
  86. KEY_SET_VALUE | KEY_ENUMERATE_SUB_KEYS, &hkeyDst );
  87. if( iStatus != ERROR_SUCCESS )
  88. return iStatus;
  89. iStatus = CopyKey( HKEY_CURRENT_USER, hkeyDst, "Control Panel\\Desktop");
  90. iStatus = CopyKey( HKEY_CURRENT_USER, hkeyDst, "Control Panel\\Colors");
  91. RegCloseKey( hkeyDst );
  92. return iStatus;
  93. }
  94. DWORD SaveAccessibilityToDefaultUser( void )
  95. {
  96. DWORD iStatus;
  97. HKEY hkeyDst;
  98. iStatus = RegOpenKeyExA( HKEY_USERS, ".DEFAULT", 0, KEY_SET_VALUE, &hkeyDst );
  99. if( iStatus != ERROR_SUCCESS )
  100. return iStatus;
  101. iStatus = CopyKey( HKEY_CURRENT_USER, hkeyDst, "Control Panel\\Accessibility");
  102. RegCloseKey( hkeyDst );
  103. return iStatus;
  104. }
  105. CSaveForDefaultUserPg::CSaveForDefaultUserPg(
  106. LPPROPSHEETPAGE ppsp
  107. ) : WizardPage(ppsp, IDS_WIZSAVEASDEFAULTTITLE, IDS_WIZSAVEASDEFAULTSUBTITLE)
  108. {
  109. m_dwPageId = IDD_WIZWORKSTATIONDEFAULT;
  110. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  111. }
  112. CSaveForDefaultUserPg::~CSaveForDefaultUserPg(
  113. VOID
  114. )
  115. {
  116. }
  117. LRESULT CSaveForDefaultUserPg::OnPSN_WizNext(HWND hwnd, INT idCtl, LPPSHNOTIFY pnmh)
  118. {
  119. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_CHECKSAVESETTINGTODEFAULT)))
  120. {
  121. SaveAccessibilityToDefaultUser();
  122. // JMC Check for admin privleges for both callse
  123. if(ERROR_SUCCESS != SaveLookToDefaultUser())
  124. StringTableMessageBox(m_hwnd, IDS_WIZERRORNEEDADMINTEXT, IDS_WIZERRORNEEDADMINTITLE, MB_OK);
  125. }
  126. return WizardPage::OnPSN_WizNext(hwnd, idCtl, pnmh);
  127. }
  128. LRESULT
  129. CSaveForDefaultUserPg::OnCommand(
  130. HWND hwnd,
  131. WPARAM wParam,
  132. LPARAM lParam
  133. )
  134. {
  135. LRESULT lResult = 1;
  136. WORD wNotifyCode = HIWORD(wParam);
  137. WORD wCtlID = LOWORD(wParam);
  138. HWND hwndCtl = (HWND)lParam;
  139. return lResult;
  140. }
  141. LRESULT
  142. CSaveForDefaultUserPg::OnInitDialog(
  143. HWND hwnd,
  144. WPARAM wParam,
  145. LPARAM lParam
  146. )
  147. {
  148. Button_SetCheck(GetDlgItem(m_hwnd, IDC_RADIO2), TRUE);
  149. return 1;
  150. }