reactos操作系统实现(62)

当文件拷贝完成后,主要就是把已经拷贝的文件进行注册表登记,还需要把用户在安装过程里选择的配置保存到注册表,同时也需要把检查到的硬件保存到注册表里。其实注册表,就是保存一些配置信息,这样下一次启动时,就可以直接把这些信息加载到内存就行了,不需要用户重新选择,也不需要重新搜索硬盘配置。代码如下:

#001  static PAGE_NUMBER

#002  RegistryPage(PINPUT_RECORD Ir)

#003  {

#004      INFCONTEXT InfContext;

#005      PWSTR Action;

#006      PWSTR File;

#007      PWSTR Section;

#008      BOOLEAN Delete;

#009      NTSTATUS Status;

#010 

 

显示注册表的页面标题。

#011      MUIDisplayPage(REGISTRY_PAGE);

#012 

 

如果修复更新就直接返回。

#013      if (RepairUpdateFlag)

#014      {

#015          return SUCCESS_PAGE;

#016      }

#017 

 

这里设置安装的路径到注册表里,以便以后安装组件时,可以到相应目录查找。

#018      if (!SetInstallPathValue(&DestinationPath))

#019      {

#020          DPRINT("SetInstallPathValue() failed/n");

#021          MUIDisplayError(ERROR_INITIALIZE_REGISTRY, Ir, POPUP_WAIT_ENTER);

#022          return QUIT_PAGE;

#023      }

#024 

 

初始化注册表缺省的硬件信息。

#025      /* Create the default hives */

#026  #ifdef __REACTOS__

#027      Status = NtInitializeRegistry(CM_BOOT_FLAG_SETUP);

#028      if (!NT_SUCCESS(Status))

#029      {

#030          DPRINT("NtInitializeRegistry() failed (Status %lx)/n", Status);

#031          MUIDisplayError(ERROR_CREATE_HIVE, Ir, POPUP_WAIT_ENTER);

#032          return QUIT_PAGE;

#033      }

#034  #else

#035      RegInitializeRegistry();

#036  #endif

#037 

 

更新安装信息到注册表。

#038      /* Update registry */

#039      CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE));

#040 

#041      if (!SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL, &InfContext))

#042      {

#043          DPRINT1("SetupFindFirstLine() failed/n");

#044          MUIDisplayError(ERROR_FIND_REGISTRY, Ir, POPUP_WAIT_ENTER);

#045          return QUIT_PAGE;

#046      }

#047 

 

 

循环地处理INF文件相应的段到注册表。

#048      do

#049      {

#050          INF_GetDataField (&InfContext, 0, &Action);

#051          INF_GetDataField (&InfContext, 1, &File);

#052          INF_GetDataField (&InfContext, 2, &Section);

#053 

#054          DPRINT("Action: %S  File: %S  Section %S/n", Action, File, Section);

#055 

#056          if (!_wcsicmp (Action, L"AddReg"))

#057          {

#058              Delete = FALSE;

#059          }

#060          else if (!_wcsicmp (Action, L"DelReg"))

#061          {

#062              Delete = TRUE;

#063          }

#064          else

#065          {

#066              continue;

#067          }

#068 

#069          CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);

#070 

#071          if (!ImportRegistryFile(File, Section, Delete))

#072          {

#073              DPRINT("Importing %S failed/n", File);

#074 

#075              MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);

#076              return QUIT_PAGE;

#077          }

#078      } while (SetupFindNextLine (&InfContext, &InfContext));

#079 

 

 

更新注册表里显示配置。

#080      /* Update display registry settings */

#081      CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYETTINGSUPDATE));

#082      if (!ProcessDisplayRegistry(SetupInf, DisplayList))

#083      {

#084          MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS, Ir, POPUP_WAIT_ENTER);

#085          return QUIT_PAGE;

#086      }

#087 

 

 

设置注册表里语言选择。

#088      /* Set the locale */

#089      CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE));

#090      if (!ProcessLocaleRegistry(LanguageList))

#091      {

#092          MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS, Ir, POPUP_WAIT_ENTER);

#093          return QUIT_PAGE;

#094      }

#095 

 

 

设置用户使用的键盘配置。

#096      /* Add keyboard layouts */

#097      CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS));

#098      if (!AddKeyboardLayouts())

#099      {

#100          MUIDisplayError(ERROR_ADDING_KBLAYOUTS, Ir, POPUP_WAIT_ENTER);

#101          return QUIT_PAGE;

#102      }

#103 

#104      if (!IsUnattendedSetup){

#105         

#106         /* Update keyboard layout settings */

#107         CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE));

#108         if (!ProcessKeyboardLayoutRegistry(LayoutList))

#109         {

#110             MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);

#111             return QUIT_PAGE;

#112         }

#113      }

 

 

设置用户选择的代码页。

#114      /* Add codepage information to registry */

#115      CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE));

#116      if (!AddCodePage())

#117      {

#118          MUIDisplayError(ERROR_ADDING_CODEPAGE, Ir, POPUP_WAIT_ENTER);

#119          return QUIT_PAGE;

#120      }

#121 

 

更新已经连接的设备到注册表。

#122      /* Update the mounted devices list */

#123      SetMountedDeviceValues(PartitionList);

#124 

#125      CONSOLE_SetStatusText(MUIGetString(STRING_DONE));

#126 

#127      return BOOT_LOADER_PAGE;

#128  }

你可能感兴趣的:(react)