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.

127 lines
3.7 KiB

  1. #include "priv.h"
  2. HRESULT RegisterActiveDesktopTemplates()
  3. {
  4. HRESULT hr = E_FAIL;
  5. TCHAR szPath[MAX_PATH];
  6. if (GetWindowsDirectory(szPath, ARRAYSIZE(szPath)) &&
  7. PathAppend(szPath, TEXT("web")))
  8. {
  9. // we still register safemode.htt and deskmovr.htt for Active Desktop.
  10. if (PathAppend(szPath, TEXT("safemode.htt")))
  11. {
  12. hr = SHRegisterValidateTemplate(szPath, SHRVT_REGISTER);
  13. }
  14. else
  15. {
  16. hr = ResultFromLastError();
  17. }
  18. if (SUCCEEDED(hr))
  19. {
  20. if (PathRemoveFileSpec(szPath) && PathAppend(szPath, TEXT("deskmovr.htt")))
  21. {
  22. hr = SHRegisterValidateTemplate(szPath, SHRVT_REGISTER);
  23. }
  24. else
  25. {
  26. hr = ResultFromLastError();
  27. }
  28. }
  29. }
  30. return hr;
  31. }
  32. HRESULT FixMyDocsDesktopIni()
  33. {
  34. HRESULT hr = E_FAIL;
  35. TCHAR szMyDocsIni[MAX_PATH];
  36. if ((SHGetFolderPath(NULL, CSIDL_MYPICTURES, NULL, SHGFP_TYPE_CURRENT, szMyDocsIni) == S_OK) &&
  37. PathAppend(szMyDocsIni, TEXT("desktop.ini")))
  38. {
  39. // The default PersistMoniker is automatically determined by the shell.
  40. // So, lets clear the old settings.
  41. WritePrivateProfileString(TEXT("{5984FFE0-28D4-11CF-AE66-08002B2E1262}"),
  42. TEXT("WebViewTemplate.NT5"),
  43. NULL,
  44. szMyDocsIni);
  45. WritePrivateProfileString(TEXT("{5984FFE0-28D4-11CF-AE66-08002B2E1262}"),
  46. TEXT("PersistMoniker"),
  47. NULL,
  48. szMyDocsIni);
  49. WritePrivateProfileString(TEXT("ExtShellFolderViews"),
  50. TEXT("Default"),
  51. NULL,
  52. szMyDocsIni);
  53. hr = S_OK;
  54. }
  55. return hr;
  56. }
  57. HRESULT SetFileAndFolderAttribs(HINSTANCE hInstResource)
  58. {
  59. TCHAR szWinPath[MAX_PATH];
  60. TCHAR szDestPath[MAX_PATH];
  61. int i;
  62. const LPCTSTR rgSuperHiddenFiles[] =
  63. {
  64. TEXT("winnt.bmp"),
  65. TEXT("winnt256.bmp"),
  66. TEXT("lanmannt.bmp"),
  67. TEXT("lanma256.bmp"),
  68. TEXT("Web"),
  69. TEXT("Web\\Wallpaper")
  70. };
  71. GetWindowsDirectory(szWinPath, ARRAYSIZE(szWinPath));
  72. // Change the attributes on "Winnt.bmp", "Winnt256.bmp", "lanmannt.bmp", "lanma256.bmp"
  73. // to super hidden sothat they do not showup in the wallpaper list.
  74. for (i = 0; i < ARRAYSIZE(rgSuperHiddenFiles); i++)
  75. {
  76. lstrcpyn(szDestPath, szWinPath, ARRAYSIZE(szDestPath));
  77. PathAppend(szDestPath, rgSuperHiddenFiles[i]);
  78. if (PathIsDirectory(szDestPath))
  79. {
  80. PathMakeSystemFolder(szDestPath);
  81. }
  82. else
  83. {
  84. SetFileAttributes(szDestPath, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
  85. }
  86. }
  87. const int rgSysetemFolders[] =
  88. {
  89. CSIDL_PROGRAM_FILES,
  90. #ifdef _WIN64
  91. CSIDL_PROGRAM_FILESX86
  92. #endif
  93. };
  94. // make the "Program Files" and "Program Files (x86)" system folders
  95. for (i = 0; i < ARRAYSIZE(rgSysetemFolders); i++)
  96. {
  97. if (SHGetFolderPath(NULL, rgSysetemFolders[i], NULL, 0, szDestPath) == S_OK)
  98. {
  99. PathMakeSystemFolder(szDestPath);
  100. }
  101. }
  102. // Fix up desktop.ini for My Pictures until we completely stop reading from it
  103. FixMyDocsDesktopIni();
  104. // register the last two .htt files that Active Desktop still uses
  105. RegisterActiveDesktopTemplates();
  106. return S_OK;
  107. }