在拷贝文件到磁盘之前,需要把压缩包的文件解压,然后才能拷贝文件到安装目录里,它的代码如下:
#001 static PAGE_NUMBER
#002 PrepareCopyPage(PINPUT_RECORD Ir)
#003 {
#004 HINF InfHandle;
#005 WCHAR PathBuffer[MAX_PATH];
#006 INFCONTEXT CabinetsContext;
#007 ULONG InfFileSize;
#008 PWCHAR KeyValue;
#009 UINT ErrorLine;
#010 PVOID InfFileData;
#011
#012 MUIDisplayPage(PREPARE_COPY_PAGE);
#013
创建一个文件队列。
#014 /* Create the file queue */
#015 SetupFileQueue = SetupOpenFileQueue();
#016 if (SetupFileQueue == NULL)
#017 {
#018 MUIDisplayError(ERROR_COPY_QUEUE,Ir,POPUP_WAIT_ENTER);
#019 return(QUIT_PAGE);
#020 }
#021
添加公共文件到安装INF文件,并且创建前面选择的目录,然后还需要创建目录下面所有的子目录。
#022 if (!PrepareCopyPageInfFile(SetupInf,NULL,Ir))
#023 {
#024 return QUIT_PAGE;
#025 }
#026
查找Cabinets段的配置。
#027 /* Search for the 'Cabinets' section */
#028 if (!SetupFindFirstLineW (SetupInf,L"Cabinets",&CabinetsContext))
#029 {
#030 return FILE_COPY_PAGE;
#031 }
#032
枚举目录里所有Cabinets段的文件。
#033 /*
#034 * Enumerate the directory values in the 'Cabinets'
#035 * section and parse their inf files.
#036 */
#037 do
#038 {
#039 if (!INF_GetData (&CabinetsContext,&KeyValue))
#040 break;
#041
#042 wcscpy(PathBuffer,SourcePath.Buffer);
#043 wcscat(PathBuffer,L"//");
#044 wcscat(PathBuffer,KeyValue);
#045
#046 #ifdef __REACTOS__
#047 CabinetInitialize();
#048 CabinetSetEventHandlers(NULL,NULL);
#049 CabinetSetCabinetName(PathBuffer);
#050
#051 if (CabinetOpen() == CAB_STATUS_SUCCESS)
#052 {
#053 DPRINT("Cabinet %S/n",CabinetGetCabinetName());
#054
#055 InfFileData = CabinetGetCabinetReservedArea(&InfFileSize);
#056 if (InfFileData == NULL)
#057 {
#058 MUIDisplayError(ERROR_CABINET_SCRIPT,POPUP_WAIT_ENTER);
#059 return QUIT_PAGE;
#060 }
#061 }
#062 else
#063 {
#064 DPRINT("Cannot open cabinet: %S./n",CabinetGetCabinetName());
#065 MUIDisplayError(ERROR_CABINET_MISSING,POPUP_WAIT_ENTER);
#066 return QUIT_PAGE;
#067 }
#068
#069 InfHandle = INF_OpenBufferedFileA((CHAR*) InfFileData,
#070 InfFileSize,
#071 (const CHAR*) NULL,
#072 INF_STYLE_WIN4,
#073 &ErrorLine);
#074
#075 if (InfHandle == INVALID_HANDLE_VALUE)
#076 {
#077 MUIDisplayError(ERROR_INVALID_CABINET_INF,POPUP_WAIT_ENTER);
#078 return QUIT_PAGE;
#079 }
#080
#081 CabinetCleanup();
#082
#083 if (!PrepareCopyPageInfFile(InfHandle,KeyValue,Ir))
#084 {
#085 return QUIT_PAGE;
#086 }
#087 #endif
#088 } while (SetupFindNextLine (&CabinetsContext,&CabinetsContext));
#089
#090 return FILE_COPY_PAGE;
#091 }
原文链接:https://www.f2er.com/react/308473.html