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.

118 lines
3.9 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. startmenumfu.c
  5. Abstract:
  6. Migrate usage date for apps to be pre-populated in startpanel MFU list using data from
  7. WINBOM.INI file.
  8. Also sets default middleware applications for ARP's "Restore computer
  9. manufacturer configuration" button.
  10. Author:
  11. Sankar Ramasubramanian 11/21/2000
  12. Revision History:
  13. --*/
  14. #include "factoryp.h"
  15. #include <shlobj.h>
  16. #define MAX_OEM_LINKS_ALLOWED 4
  17. //The following are defined in OPKWIZ also!
  18. #define INI_KEY_MFULINK _T("Link%d")
  19. #define INI_SEC_MFULIST _T("StartMenuMFUlist")
  20. // The following are defined in explorer also!
  21. #define REGSTR_PATH_DEFAULTMFU _T("Software\\Microsoft\\Windows\\CurrentVersion\\SMDEn")
  22. //The possible values under REGSTR_PATH_MFU
  23. #define VAL_LINKMSFT _T("Link%d")
  24. #define VAL_LINKOEM _T("OEM%d")
  25. //Value under REGSTR_PATH_EXPLORER\Advanced
  26. #define VAL_STARTMENUINIT _T("StartMenuInit")
  27. //
  28. // This function processes the OEM MFU section of the WinBOM.INI file and adds those entries into
  29. // the REGSTR_PATH_DEFAULTMFU database in HKLM. Explorer's per-user install will consult
  30. // this list to determine the correct MFU to show each user the first time they log on.
  31. //
  32. // Furthermore, for some reason, per-user install does NOT run if you preset
  33. // the profiles with factory.exe, so we need to set a flag for Explorer so
  34. // it can "undo" all the gunk the factory left behind so each user gets a
  35. // fresh start.
  36. BOOL StartMenuMFU(LPSTATEDATA lpStateData)
  37. {
  38. LPTSTR lpszWinBOMPath = lpStateData->lpszWinBOMPath;
  39. int iIndex;
  40. TCHAR szIniKeyName[20];
  41. TCHAR szRegKeyName[20];
  42. TCHAR szPath[MAX_PATH];
  43. TCHAR szExpanded[MAX_PATH];
  44. // For each OEM entry, copy it to HKLM
  45. for(iIndex = 0; iIndex < MAX_OEM_LINKS_ALLOWED; iIndex++)
  46. {
  47. if ( FAILED ( StringCchPrintf ( szIniKeyName, AS ( szIniKeyName ), INI_KEY_MFULINK, iIndex) ) )
  48. {
  49. FacLogFileStr(3, _T("StringCchPrintf failed %s %d" ), szIniKeyName, iIndex );
  50. }
  51. if ( FAILED ( StringCchPrintf ( szRegKeyName, AS ( szRegKeyName ), VAL_LINKOEM, iIndex) ) )
  52. {
  53. FacLogFileStr(3, _T("StringCchPrintf failed %s %d"), szRegKeyName, iIndex ) ;
  54. }
  55. if (GetPrivateProfileString(INI_SEC_MFULIST, szIniKeyName, NULLSTR, szExpanded, ARRAYSIZE(szExpanded), lpszWinBOMPath))
  56. {
  57. if (!PathUnExpandEnvStrings(szExpanded, szPath, STRSIZE(szPath)))
  58. {
  59. lstrcpyn(szPath, szExpanded, STRSIZE(szPath));
  60. }
  61. SHSetValue(HKEY_LOCAL_MACHINE, REGSTR_PATH_DEFAULTMFU, szRegKeyName, REG_EXPAND_SZ, szPath, (lstrlen(szPath) + 1) * sizeof(TCHAR));
  62. }
  63. }
  64. // Now clear the "I have built the initial MFU" flag since we want it to
  65. // rebuild the next time each user logs on.
  66. SHDeleteValue(HKEY_CURRENT_USER, REGSTR_PATH_EXPLORER _T("\\Advanced"),
  67. VAL_STARTMENUINIT);
  68. // And tell the Start Menu to show off the new MFU
  69. NotifyStartMenu(TMFACTORY_MFU);
  70. return TRUE;
  71. }
  72. BOOL DisplayStartMenuMFU(LPSTATEDATA lpStateData)
  73. {
  74. return IniSettingExists(lpStateData->lpszWinBOMPath, INI_SEC_MFULIST, NULL, NULL);
  75. }
  76. /***************************************************************************
  77. *
  78. * Setting default middleware applications
  79. *
  80. * We do it here here merely to give the OEM a warm fuzzy feeling.
  81. * The "official" setting of default middleware applications happens
  82. * in sysprep during reseal.
  83. *
  84. ***************************************************************************/
  85. void ReportSetDefaultOEMAppsError(LPCTSTR pszAppName, LPCTSTR pszIniVar)
  86. {
  87. FacLogFile(0 | LOG_ERR, IDS_ERR_SETDEFAULTS_NOTFOUND, pszAppName, pszIniVar);
  88. }
  89. BOOL SetDefaultApps(LPSTATEDATA lpStateData)
  90. {
  91. return SetDefaultOEMApps(lpStateData->lpszWinBOMPath);
  92. }