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.

138 lines
3.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: needsmig.cpp
  4. //
  5. // Module: CMCFG32.DLL AND CMSTP.EXE
  6. //
  7. // Synopsis: Implementation of the ProfileNeedsMigration function.
  8. //
  9. // Copyright (c) 1999 Microsoft Corporation
  10. //
  11. // Author: quintinb Created Header 08/19/99
  12. //
  13. //+----------------------------------------------------------------------------
  14. //+----------------------------------------------------------------------------
  15. //
  16. // Function: ProfileNeedsMigration
  17. //
  18. // Synopsis: This function determines if we need to migrate a profile or not.
  19. // Profiles that have the current Profile version format or greater
  20. // are not migrated. Profiles that have an older version format that
  21. // have already been migrated (we look to see if the GUID is missing on
  22. // NT5 or if the Delete Entry exists on Down Level) don't need to
  23. // be migrated.
  24. //
  25. // Arguments: LPCTSTR pszPathToCmp - full path to the CMP file
  26. //
  27. // Returns: BOOL - TRUE if the profile should be migrated or not
  28. //
  29. // History: quintinb Created 11/20/98
  30. //
  31. //+----------------------------------------------------------------------------
  32. BOOL ProfileNeedsMigration(LPCTSTR pszServiceName, LPCTSTR pszPathToCmp)
  33. {
  34. //
  35. // Open the CMP and check the version number. If the profile format version
  36. // is old then we need to migrate it.
  37. //
  38. if ((NULL == pszServiceName) || (NULL == pszPathToCmp) ||
  39. (TEXT('\0') == pszServiceName[0]) || (TEXT('\0') == pszPathToCmp[0]))
  40. {
  41. return FALSE;
  42. }
  43. CPlatform plat;
  44. CFileNameParts FileParts(pszPathToCmp);
  45. int iCurrentCmpVersion = GetPrivateProfileInt(c_pszCmSectionProfileFormat, c_pszVersion,
  46. 0, pszPathToCmp);
  47. if (PROFILEVERSION > iCurrentCmpVersion)
  48. {
  49. //
  50. // Now construct the path to the INF file (1.0 and 1.1 profiles kept the infs in
  51. // the system dir)
  52. //
  53. TCHAR szTemp[MAX_PATH+1];
  54. TCHAR szInfFile[MAX_PATH+1];
  55. TCHAR szGUID[MAX_PATH+1];
  56. HKEY hKey;
  57. MYVERIFY(0 != GetSystemDirectory(szTemp, MAX_PATH));
  58. MYVERIFY(CELEMS(szInfFile) > (UINT)wsprintf(szInfFile, TEXT("%s\\%s%s"), szTemp,
  59. FileParts.m_FileName, TEXT(".inf")));
  60. if (!FileExists(szInfFile))
  61. {
  62. return FALSE;
  63. }
  64. //
  65. // Get the GUID from the inf file.
  66. //
  67. ZeroMemory(szGUID, sizeof(szGUID));
  68. MYVERIFY(0 != GetPrivateProfileString(c_pszInfSectionStrings, c_pszDesktopGuid, TEXT(""), szGUID,
  69. MAX_PATH, szInfFile));
  70. if (0 != szGUID[0])
  71. {
  72. MYVERIFY(CELEMS(szTemp) > (UINT)wsprintf(szTemp,
  73. TEXT("CLSID\\%s"), szGUID));
  74. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, szTemp, 0,
  75. KEY_READ, &hKey))
  76. {
  77. //
  78. // If this is NT5, then we need to migrate. On Legacy we need to try to
  79. // open the delete subkey.
  80. //
  81. RegCloseKey(hKey);
  82. if (plat.IsAtLeastNT5())
  83. {
  84. return TRUE;
  85. }
  86. else
  87. {
  88. MYVERIFY(CELEMS(szTemp) > (UINT)wsprintf(szTemp,
  89. TEXT("CLSID\\%s\\Shell\\Delete"), szGUID));
  90. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, szTemp, 0,
  91. KEY_READ, &hKey))
  92. {
  93. //
  94. // Already been migrated
  95. //
  96. RegCloseKey(hKey);
  97. return FALSE;
  98. }
  99. else
  100. {
  101. //
  102. // Must Migrate the profile.
  103. //
  104. return TRUE;
  105. }
  106. }
  107. }
  108. else
  109. {
  110. return FALSE;
  111. }
  112. }
  113. else
  114. {
  115. //
  116. // This affects MSN, as long as we have true here their 1.0 stuff will
  117. // get migrated. If we don't want it to, change this.
  118. //
  119. return TRUE;
  120. }
  121. }
  122. else
  123. {
  124. return FALSE;
  125. }
  126. }