Source code of Windows XP (NT5)
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.

147 lines
3.7 KiB

  1. #include "miginf.h"
  2. #include "migutil.h"
  3. #include "basetypes.h"
  4. #include "utiltypes.h"
  5. #include "objstr.h"
  6. extern "C" {
  7. #include "ism.h"
  8. }
  9. #include "modules.h"
  10. #ifndef ARRAYSIZE
  11. #define ARRAYSIZE(x) ((sizeof(x)) / (sizeof(x[0])))
  12. #endif
  13. HINF g_hMigWizInf = INVALID_HANDLE_VALUE;
  14. POBJLIST g_HTMLApps;
  15. BOOL OpenAppInf (LPTSTR pszFileName)
  16. {
  17. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  18. return TRUE;
  19. }
  20. if (!pszFileName)
  21. {
  22. TCHAR szFileName[MAX_PATH];
  23. PTSTR psz;
  24. if (!GetModuleFileName (NULL, szFileName, ARRAYSIZE(szFileName))) {
  25. return FALSE;
  26. }
  27. psz = _tcsrchr (szFileName, TEXT('\\'));
  28. if (!psz) {
  29. return FALSE;
  30. }
  31. lstrcpy (psz + 1, TEXT("migwiz.inf"));
  32. pszFileName = szFileName;
  33. }
  34. g_hMigWizInf = SetupOpenInfFile (pszFileName, NULL, INF_STYLE_WIN4|INF_STYLE_OLDNT, NULL);
  35. return g_hMigWizInf != INVALID_HANDLE_VALUE;
  36. }
  37. VOID CloseAppInf (VOID)
  38. {
  39. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  40. SetupCloseInfFile (g_hMigWizInf);
  41. g_hMigWizInf = INVALID_HANDLE_VALUE;
  42. }
  43. }
  44. BOOL IsComponentEnabled (UINT uType, PCTSTR szComponent)
  45. {
  46. BOOL bResult = FALSE;
  47. INFCONTEXT ic;
  48. //
  49. // script-based entries start with $, while module-based entries don't.
  50. // This ensures script components do not collide with anything else.
  51. // Remove the $ to simplify [Single Floppy] or [Multiple Floppy].
  52. //
  53. if (_tcsnextc (szComponent) == TEXT('$')) {
  54. szComponent = _tcsinc (szComponent);
  55. }
  56. if (g_hMigWizInf != INVALID_HANDLE_VALUE) {
  57. switch (uType) {
  58. case MIGINF_SELECT_OOBE:
  59. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("OOBE"), szComponent, &ic);
  60. break;
  61. case MIGINF_SELECT_SETTINGS:
  62. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Settings Only"), szComponent, &ic);
  63. if (!g_fStoreToFloppy && !bResult)
  64. {
  65. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Settings Only.Ext"), szComponent, &ic);
  66. }
  67. break;
  68. case MIGINF_SELECT_FILES:
  69. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files Only"), szComponent, &ic);
  70. if (!g_fStoreToFloppy && !bResult)
  71. {
  72. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files Only.Ext"), szComponent, &ic);
  73. }
  74. break;
  75. case MIGINF_SELECT_BOTH:
  76. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files and Settings"), szComponent, &ic);
  77. if (!g_fStoreToFloppy && !bResult)
  78. {
  79. bResult = SetupFindFirstLine (g_hMigWizInf, TEXT("Files and Settings.Ext"), szComponent, &ic);
  80. }
  81. break;
  82. default:
  83. bResult = TRUE;
  84. break;
  85. }
  86. }
  87. return bResult;
  88. }
  89. BOOL
  90. GetAppsToInstall (
  91. VOID
  92. )
  93. {
  94. INFCONTEXT ic;
  95. POBJLIST objList = NULL;
  96. BOOL fResult;
  97. LPTSTR p;
  98. MIG_COMPONENT_ENUM mce;
  99. _FreeObjectList(g_HTMLApps);
  100. g_HTMLApps = NULL;
  101. if (IsmEnumFirstComponent (&mce, COMPONENTENUM_ALIASES | COMPONENTENUM_ENABLED |
  102. COMPONENTENUM_PREFERRED_ONLY, COMPONENT_NAME)) {
  103. do {
  104. if (IsmIsComponentSelected (mce.ComponentString, 0)) {
  105. p = _tcsinc(mce.ComponentString);
  106. if (SetupFindFirstLine (g_hMigWizInf, TEXT("AppsToInstallOnDest"), p, &ic)) {
  107. objList = _AllocateObjectList (mce.LocalizedAlias);
  108. objList->Next = g_HTMLApps;
  109. g_HTMLApps = objList;
  110. }
  111. }
  112. } while (IsmEnumNextComponent (&mce));
  113. }
  114. return (objList != NULL);
  115. }