当前位置: 首页 > news >正文

企业网站托管公司品牌建设存在的问题及建议

企业网站托管公司,品牌建设存在的问题及建议,网站续费一般多少钱,广州网站建设 全包WIMGAPI库是 Windows 操作系统中的一个应用程序编程接口#xff08;API#xff09;可用于创建#xff0c;编辑#xff0c;提取浏览和部署 WIM、ESD格式的镜像文件。 这里只简单演示在Qt Creator#xff0c; Mscv2017 Debug#xff0c;WINDOWS 开发环境下的调用完整实例。… WIMGAPI库是 Windows 操作系统中的一个应用程序编程接口API可用于创建编辑提取浏览和部署 WIM、ESD格式的镜像文件。 这里只简单演示在Qt Creator Mscv2017 DebugWINDOWS 开发环境下的调用完整实例。 目录 WIMGAPI描述数据预处理获取镜像的相关信息导出指定系统中的文件获取镜像目录结构装载/卸载镜像提取镜像到指定目录 WIMGAPI描述 WIMGAPI Windows Imaging API是 Windows 操作系统中的一个应用程序编程接口API用于处理 Windows 映像.wim文件格式。Windows 映像是一种压缩的文件容器可用于存储操作系统、应用程序和驱动程序等文件 注https://www.cnblogs.com/suv789/p/17549323.html WIMGAPI是适合WINDOWS 环境下处理WIM、ESD镜像格式的库 常用方法说明 WIMCreateFile 创建新的图像文件或打开现有的图像文件。WIMApplyImage 将图像应用于Windows图像的目录路径(。wim)文件。WIMCaptureImage 从目录路径捕获图像并将其存储在图像文件中。WIMCloseHandle 关闭打开的Windows imaging(。wim)文件或图像句柄。WIMCommitImageHandle 将已装载映像中的更改保存回. wim文件。WIMCopyFile 将现有文件复制到新文件中。通过回调函数通知应用程序它的进度。如果源文件包含验证数据则在复制操作期间会验证文件的内容。WIMDeleteImage 从. wim (Windows映像)文件中删除映像使其无法被访问。但是文件资源仍然可供WIMSetReferenceFile功能。WIMDeleteImageMounts 从以前装载映像的所有目录中删除映像。WIMExportImage 从一个Windows映像(.wim)文件复制到另一个文件。WIMExtractImagePath 从Windows映像(.wim)文件复制到指定位置。WIMGetAttributes 返回存储在映像文件中的卷映像的数量。WIMGetImageCount 返回存储在Windows映像中的卷映像的数量。wim)文件。WIMGetImageInformation 返回有关中图像的信息。wim (Windows映像)文件。WIMGetMessageCallbackCount 返回图像库当前注册的回调例程的计数。WIMGetMountedImageHandle 返回一个WIM句柄和一个镜像句柄对应于一个挂载的镜像目录。WIMGetMountedImageInfo 返回当前装载的映像列表。WIMGetMountedImageInfoFromHandle 查询已装载图像句柄的状态。WIMGetMountedImages 返回当前装载的映像列表。此功能已被取代WIMGetMountedImageInfo.WIMLoadImage 从Windows映像加载卷映像(。wim)文件。WIMMessageCallback 与一起使用的应用程序定义的函数WIMRegisterMessageCallback或者WIMUnregisterMessageCallback功能。WIMMountImage 将映像装入Windows映像(。wim)文件复制到指定目录。WIMMountImageHandle 将映像装入Windows映像(。wim)文件复制到指定目录。WIMRegisterLogFile 将用于调试或跟踪目的的日志文件注册到当前WIMGAPI会话中。WIMRegisterMessageCallback 用特定于图像的数据注册要调用的函数。有关可以处理的消息的信息请参见信息.WIMRemountImage 重新激活以前装载到指定目录的已装载映像。WIMSetBootImage 将具有给定映像索引的映像标记为可启动。WIMSetImageInformation 将有关图像的信息存储在Windows图像(。wim)文件。WIMSetReferenceFile 启用WIMApplyImage和WIMCaptureImage使用替代的函数。文件资源的wim文件。当使用相似数据捕获多个图像时这可以优化存储。WIMSetTemporaryPath 设置临时图像文件的存储位置。WIMSplitFile 启用大的Windows映像(。wim)文件分割成较小的部分以便在较小形式的介质上复制或存储。WIMUnmountImage 卸载Windows映像中已装载的映像(。wim)文件从指定的目录。WIMUnmountImageHandle 从Windows映像中卸载映像(。wim ),它以前与一起安装WIMMountImageHandle功能。WIMUnregisterLogFile 出于调试或跟踪目的从当前WIMGAPI会话中注销日志文件。WIMUnregisterMessageCallback 注销用特定于图像的数据调用的函数。 具体参数建议查看WIMGAPI 中的API说明 或者通过GItHub中获取wingapi的一些宏定义和类结构 https://github.com/VulpesSARL/MiniNT5-Tools/blob/b3bbc6c2c1af7207438a34b1546fa67ab7a038e2/FoxCWrapperWIM/wimgapi.h 数据预处理 WIMGAPI 是通过LoadLibraryExW 加载Wimgapi库获取各种Api的调用。 这里只包含部分使用到的api和宏定义 完整的APi和宏定义建议查看GItHub上面的wimgapi.h文件内容 #define PF_INIT(proc, name) if (pf##proc NULL) pf##proc \(proc##_t) GetProcAddress(GetLibraryHandle(#name), #proc) #define PF_INIT_OR_OUT(proc, name) do {PF_INIT(proc, name); \if (pf##proc NULL) {qDebug(Unable to locate %s() in %s.dll: %s, \ #proc, #name, GetLastError()); goto out;} } while(0)// From https://docs.microsoft.com/en-us/previous-versions/msdn10/dd834960(vmsdn.10) // as well as https://msfn.org/board/topic/150700-wimgapi-wimmountimage-progressbar/ enum WIMMessage {WIM_MSG WM_APP 0x1476,WIM_MSG_TEXT,WIM_MSG_PROGRESS, // Indicates an update in the progress of an image application.WIM_MSG_PROCESS, // Enables the caller to prevent a file or a directory from being captured or applied.WIM_MSG_SCANNING, // Indicates that volume information is being gathered during an image capture.WIM_MSG_SETRANGE, // Indicates the number of files that will be captured or applied.WIM_MSG_SETPOS, // Indicates the number of files that have been captured or applied.WIM_MSG_STEPIT, // Indicates that a file has been either captured or applied.WIM_MSG_COMPRESS, // Enables the caller to prevent a file resource from being compressed during a capture.WIM_MSG_ERROR, // Alerts the caller that an error has occurred while capturing or applying an image.WIM_MSG_ALIGNMENT, // Enables the caller to align a file resource on a particular alignment boundary.WIM_MSG_RETRY, // Sent when the file is being reapplied because of a network timeout.WIM_MSG_SPLIT, // Enables the caller to align a file resource on a particular alignment boundary.WIM_MSG_FILEINFO, // Used in conjunction with WimApplyImages()s WIM_FLAG_FILEINFO flag to provide detailed file info.WIM_MSG_INFO, // Sent when an info message is available.WIM_MSG_WARNING, // Sent when a warning message is available.WIM_MSG_CHK_PROCESS,WIM_MSG_SUCCESS 0,WIM_MSG_ABORT_IMAGE -1 };/* Action type, for progress bar breakdown */ enum action_type {OP_NOOP_WITH_TASKBAR -3,OP_NOOP -2,OP_INIT -1,OP_ANALYZE_MBR 0,OP_BADBLOCKS,OP_ZERO_MBR,OP_PARTITION,OP_FORMAT,OP_CREATE_FS,OP_FIX_MBR,OP_FILE_COPY,OP_PATCH,OP_FINALIZE,OP_MAX };enum {WIM_COMPRESS_NONE 0,WIM_COMPRESS_XPRESS 1,WIM_COMPRESS_LZX 2 };#define WIM_GENERIC_READ GENERIC_READ #define WIM_GENERIC_WRITE GENERIC_WRITE #define WIM_GENERIC_MOUNT GENERIC_EXECUTE #define WIM_OPEN_EXISTING OPEN_EXISTING #define WIM_OPEN_ALWAYS OPEN_ALWAYS #define WIM_UNDOCUMENTED_BULLSHIT 0x20000000#define WIM_FLAG_RESERVED 0x00000001 #define WIM_FLAG_VERIFY 0x00000002 #define WIM_FLAG_INDEX 0x00000004 #define WIM_FLAG_NO_APPLY 0x00000008 #define WIM_FLAG_NO_DIRACL 0x00000010 #define WIM_FLAG_NO_FILEACL 0x00000020 #define WIM_FLAG_SHARE_WRITE 0x00000040 #define WIM_FLAG_FILEINFO 0x00000080 #define WIM_FLAG_NO_RP_FIX 0x00000100 #define WIM_FLAG_MOUNT_READONLY 0x00000200 #define INVALID_CALLBACK_VALUE 0xFFFFFFFFstatic HMODULE GetLibraryHandle(const char* szLibraryName) {HMODULE h NULL;const wchar_t* wszLibraryName NULL;int size;if (szLibraryName NULL || szLibraryName[0] 0)goto out;size MultiByteToWideChar(CP_UTF8, 0, szLibraryName, -1, NULL, 0);if ((size 1) || ((wszLibraryName (wchar_t*)calloc(size, sizeof(wchar_t))) NULL) ||(MultiByteToWideChar(CP_UTF8, 0, szLibraryName, -1, (LPWSTR)wszLibraryName, size) ! size))goto out;// If the library is already opened, just return a handle (that doesnt need to be freed)if ((h GetModuleHandleW(wszLibraryName)) ! NULL)goto out;h LoadLibraryExW(wszLibraryName, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);if(hNULL)qDebug(Unable to load %S.dll: %s, wszLibraryName, GetLastError()); out:free((LPWSTR)wszLibraryName);return h; } 静态实例 typedef HANDLE (WINAPI *WIMCreateFile_t)(PWSTR, DWORD, DWORD, DWORD, DWORD, PDWORD); static WIMCreateFile_t pfWIMCreateFileNULL;typedef BOOL (WINAPI *WIMGetImageInformation_t)(HANDLE, PVOID , PDWORD); static WIMGetImageInformation_t pfWIMGetImageInformationNULL;typedef BOOL (WINAPI *WIMSetTemporaryPath_t)( HANDLE ,PWSTR ); static WIMSetTemporaryPath_t pfWIMSetTemporaryPathNULL;typedef DWORD (WINAPI *WIMGetImageCount_t)( HANDLE ); static WIMGetImageCount_t pfWIMGetImageCountNULL;typedef HANDLE (WINAPI *WIMLoadImage_t)(HANDLE ,DWORD ); static WIMLoadImage_t pfWIMLoadImageNULL;typedef BOOL (WINAPI *WIMCloseHandle_t)(HANDLE); static WIMCloseHandle_t pfWIMCloseHandleNULL;typedef BOOL (WINAPI *WIMApplyImage_t)(HANDLE, PCWSTR, DWORD); static WIMApplyImage_t pfWIMApplyImageNULL;typedef BOOL (WINAPI *WIMSetBootImage_t)(HANDLE, DWORD); static WIMSetBootImage_t pfWIMSetBootImageNULL;typedef BOOL (WINAPI *WIMMountImage_t)(PCWSTR, PCWSTR, DWORD, PCWSTR); static WIMMountImage_t pfWIMMountImageNULL;typedef BOOL (WINAPI *WIMUnmountImage_t)(PCWSTR, PCWSTR, DWORD, BOOL); static WIMUnmountImage_t pfWIMUnmountImageNULL;typedef DWORD (WINAPI *WIMRegisterMessageCallback_t)(HANDLE, FARPROC, PVOID); static WIMRegisterMessageCallback_t pfWIMRegisterMessageCallbackNULL;typedef DWORD (WINAPI *WIMUnregisterMessageCallback_t)(HANDLE, FARPROC); static WIMUnregisterMessageCallback_t pfWIMUnregisterMessageCallbackNULL;typedef HANDLE (WINAPI *WIMCaptureImage_t)(HANDLE , PCWSTR , DWORD); static WIMCaptureImage_t pfWIMCaptureImageNULL;typedef BOOL (WINAPI *WIMMountImageHandle_t)(HANDLE, PCWSTR, DWORD); static WIMMountImageHandle_t pfWIMMountImageHandleNULL;typedef BOOL (WINAPI *WIMUnmountImageHandle_t)(HANDLE, DWORD); static WIMUnmountImageHandle_t pfWIMUnmountImageHandleNULL;typedef BOOL (WINAPI *WIMExtractImagePath_t) (HANDLE, PWSTR, PWSTR, DWORD); static WIMExtractImagePath_t pfWIMExtractImagePathNULL;格式转换: 在涉及到windows api的接口调用时 Qt开发环境下这两个方法是绝对少不了的毕竟传入路径的时候都需要转换文本格式。 /** Converts an UTF8 string to UTF-16 (allocate returned string)* Returns NULL on error*/ static wchar_t* _utf8_to_wchar(const char* str) {// qDebug()[_utf8_to_wchar] --;int size 0;wchar_t* wstr NULL;if (str NULL)return NULL;// Convert the empty string tooif (str[0] 0)return (wchar_t*)calloc(1, sizeof(wchar_t));// Find out the size we need to allocate for our converted stringsize MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);if (size 1) // An empty string would be size 1return NULL;if ((wstr (wchar_t*)calloc(size, sizeof(wchar_t))) NULL)return NULL;if (utf8_to_wchar_no_alloc(str, wstr, size) ! size) {sfree(wstr);return NULL;}return wstr; }/** Converts an UTF-16 string to UTF8 (allocate returned string)* Returns NULL on error*/ static char* _wchar_to_utf8(const wchar_t* wstr) {int size 0;char* str NULL;/* Find out the size we need to allocate for our converted string */size WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);if (size 1) /* An empty string would be size 1 */return NULL;if ((str (char*)calloc(size, 1)) NULL)return NULL;if (wchar_to_utf8_no_alloc(wstr, str, size) ! size) {free(str);return NULL;}return str; } 获取镜像的相关信息 WIM、ESD镜像版本信息实际上就是一个XML格式保存的 通过WIMGetImageInformation 获取 示例中整个操作是将XML写入了一个临时文件 值得注意的是pfWIMCreateFile 打开WIM时需要将dwFlagsAndAttributes设置为WIM_UNDOCUMENTED_BULLSHIT 如果设置为0测试部分镜像会无法加载 TempFilePath tempObj; //一个用于生成临时文件的类//临时文件夹wchar_t* wtemptempObj.GetTempDirU();wchar_t* wimage;///临时文件wchar_t* wdsttempObj.GetTempFileNameU(1);///XML格式信息wchar_t* wim_XMLinfo;HANDLE hWim NULL;HANDLE hFile NULL;DWORD dw 0;DWORD dwFlagsAndAttributesWIM_UNDOCUMENTED_BULLSHIT;//Image_path 镜像文件路径///使用wimgapi库读取数据wimage_utf8_to_wchar(Image_path.toStdString().c_str());//实例化API PF_INIT_OR_OUT(WIMCreateFile, Wimgapi);PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi);PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi);PF_INIT_OR_OUT(WIMGetImageInformation, Wimgapi);PF_INIT_OR_OUT(WIMGetImageCount, Wimgapi);hWim pfWIMCreateFile(wimage, WIM_GENERIC_READ, WIM_OPEN_EXISTING,dwFlagsAndAttributes , 0, NULL);if (hWim NULL) {qDebug( Could not access image: %d, GetLastError());goto out;}///设置临时文件夹路径if (!pfWIMSetTemporaryPath(hWim, wtemp)) {qDebug( Could not set temp path: %d, GetLastError());goto out;}///获取镜像包含的系统数量int Image_CountpfWIMGetImageCount(hWim);if(Image_Count0)qDebug( Could not get image count: %d, GetLastError());qDebug()[Image_Count] Image_Count;///获取 系统的xml信息if (!pfWIMGetImageInformation(hWim, wim_XMLinfo, dw) || (dw 0)) {qDebug( Could not access WIM info: %d, GetLastError());goto out;}///写入临时文件hFile CreateFileW(wdst, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);if ((hFile INVALID_HANDLE_VALUE)|| (!WriteFile(hFile, wim_XMLinfo, dw, dw, NULL))) {qDebug( Could not extract file: %s, GetLastError());goto out;}CloseHandle(hFile);hFileINVALID_HANDLE_VALUE;///打开xml读取数据//Parser_XML(QString::fromWCharArray(wdst)); out:if ( (hWim ! NULL)) {qDebug(Closing: %s, Image_path.toStdString().c_str());if (hWim ! NULL)pfWIMCloseHandle(hWim);}if(hFile ! INVALID_HANDLE_VALUE)CloseHandle(hFile);safe_free(wtemp);safe_free(wimage);safe_free(wdst);导出指定系统中的文件 一个WIM、ESD镜像文件中至少包含一个系统镜像 pfWIMLoadImage加载镜像时都需要先设置一个临时文件夹 默认镜像索引从1开始小于等于镜像系统数量 void Lib_Wimgapi::Export_File_by(int index,QString wimpath,QString outfile) {TempFilePath tempObj;//临时文件夹wchar_t* wtemptempObj.GetTempDirU();///镜像路径wchar_t* wimage_utf8_to_wchar(Image_path.toStdString().c_str());///WIM 镜像路径 如 windows\\boot.exewchar_t* wsrc_utf8_to_wchar(wimpath.toStdString().c_str());///输出路径 如 C:\\Users\\admin\\Desktop\\boot.exewchar_t* wdst_utf8_to_wchar(outfile.toStdString().c_str());HANDLE hWim NULL;HANDLE hImageNULL;DWORD dw0;///实例化函数方法PF_INIT_OR_OUT(WIMCreateFile, Wimgapi);PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi);PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi);PF_INIT_OR_OUT(WIMLoadImage, Wimgapi);PF_INIT_OR_OUT(WIMExtractImagePath, Wimgapi);hWim pfWIMCreateFile(wimage, WIM_GENERIC_READ, WIM_OPEN_EXISTING,WIM_UNDOCUMENTED_BULLSHIT , 0, NULL);if (hWim NULL) {qDebug( Could not access image: %d, GetLastError());goto out;}///设置临时文件夹路径if (!pfWIMSetTemporaryPath(hWim, wtemp)) {qDebug( Could not set temp path: %d, GetLastError());goto out;}///至少为1int WIM_INDEXqMin(qMax(1,index),Image_Count);hImage pfWIMLoadImage(hWim, WIM_INDEX);if (hImage NULL) {qDebug( Could not set index: %d, GetLastError());goto out;}///输出文件if (!pfWIMExtractImagePath(hImage, wsrc, wdst, dw)) {qDebug( Could not extract file: %d, GetLastError());goto out;}out:if (hWim ! NULL || hWim ! hImage) {qDebug(Closing: %s, Image_path.toStdString().c_str());if (hWim ! NULL)pfWIMCloseHandle(hWim);if (hImage ! NULL)pfWIMCloseHandle(hImage);}safe_free(wtemp);safe_free(wimage);safe_free(wsrc);safe_free(wdst); }获取镜像目录结构装载/卸载镜像 WIMGAPI库中貌似没有可以直接获取目录结构的函数写示例的时候我是先通过 加载镜像(pfWIMLoadImage)- 装载镜像(WIMMountImageHandle)- 读取目录结构(文件夹遍历)- 卸载镜像(WIMUnmountImageHandle) 这个流程来获取目录结构的 TempFilePath tempObj;HANDLE hWim NULL;HANDLE hImage NULL;///Image_pathwchar_t* wimage _utf8_to_wchar(Image_path.toStdString().c_str());//临时文件夹wchar_t* wtemptempObj.GetTempDirU();//用于装载的路径QDir tempMountDir(QString::fromWCharArray(wtemp)\\TempMount_WIMGAPI);if(!tempMountDir.exists())tempMountDir.mkpath(QString::fromWCharArray(wtemp)\\TempMount_WIMGAPI);wchar_t* wdst_utf8_to_wchar(QString(QString::fromWCharArray(wtemp)\\TempMount_WIMGAPI).toStdString().c_str());QString TempFileQString::fromWCharArray(wdst);qDebug()临时装载路径: TempFile;//PF_INIT_OR_OUT(WIMRegisterMessageCallback, Wimgapi);PF_INIT_OR_OUT(WIMCreateFile, Wimgapi);PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi);PF_INIT_OR_OUT(WIMLoadImage, Wimgapi);PF_INIT_OR_OUT(WIMApplyImage, Wimgapi);PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi);//PF_INIT_OR_OUT(WIMUnregisterMessageCallback, Wimgapi);PF_INIT_OR_OUT(WIMMountImageHandle, Wimgapi);PF_INIT_OR_OUT(WIMUnmountImageHandle, Wimgapi);// 调试信息 // if (pfWIMRegisterMessageCallback(NULL, (FARPROC)WimProgressCallback, NULL) INVALID_CALLBACK_VALUE) { // qDebug( Could not set progress callback: %d, GetLastError()); // goto out; // }hWim pfWIMCreateFile(wimage, WIM_GENERIC_READ|WIM_GENERIC_MOUNT, WIM_OPEN_EXISTING,WIM_UNDOCUMENTED_BULLSHIT , 0, NULL);if (hWim NULL) {qDebug( Could not access image: %d, GetLastError());goto out;}if (!pfWIMSetTemporaryPath(hWim, wtemp)) {qDebug( Could not set temp path: %d, GetLastError());goto out;}int WIM_INDEXqMax(1,index.toInt());hImage pfWIMLoadImage(hWim, WIM_INDEX);if (hImage NULL) {qDebug( Could not set index: %d, GetLastError());goto out;}///清除历史缓存//! 方案一 用这种方法可以检查文件目录 但是无法获取文件的属性 // Fetch_Files.clear(); // // Run a first pass using WIM_FLAG_NO_APPLY to count the files // if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_NO_APPLY)) { // qDebug( Could not count the files to apply: %d, GetLastError()); // goto out; // }//! 方案二 通过装载卸载的方式 获取文件目录结构if(!pfWIMMountImageHandle(hImage,wdst,WIM_FLAG_MOUNT_READONLY)){qDebug(Could not Mount Image: %d, GetLastError());goto out;}//遍历目录结构//Lib_Deploy_Environment::getInstance().EnumerateFiles(TempFile,Fetch_Files);//! 如果需要对镜像镜像修改 可以在此处操作文件目录/文件 然后提交保存//!WIMCommitImageHandle 保存装载后的更改!if(!pfWIMUnmountImageHandle(hImage,0)){//dism /Get-MountedWimInfo//dism /Cleanup-Wim//CMD_WRITE(dism /Cleanup-Wim);qDebug(Could not Unmount Image: %d, GetLastError());} out:if ((hImage ! NULL) || (hWim ! NULL)) {qDebug(Closing: %s, Image_path.toStdString().c_str());if (hImage ! NULL)pfWIMCloseHandle(hImage);if (hWim ! NULL)pfWIMCloseHandle(hWim);} // if (pfWIMUnregisterMessageCallback ! NULL) // pfWIMUnregisterMessageCallback(NULL, (FARPROC)WimProgressCallback);safe_free(wimage);safe_free(wdst);safe_free(wtemp);其中需要注意的是 如果因为各种原因卸载或者装载失败都需要调用Windwos系统自带的Dism.exe删除不完整的记录 CMD执行 dism.exe /Cleanup-Wim 提取镜像到指定目录 通过pfWIMApplyImage 提取镜像时可以加上WIMRegisterMessageCallback的回调函数获取提取文件进度也可以实现简单的进度条效果 //!回调函数 static DWORD WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PVOID pvIgnored) {//qDebug()[dwMsgId] dwMsgId;PBOOL pbCancel NULL;PWIN32_FIND_DATA pFileData;const char* level NULL;uint64_t size;switch (dwMsgId) {case WIM_MSG_PROGRESS:qDebug()[WIM_MSG_PROGRESS] --;// The default WIM progress is useless for apply (freezes at 95%, which is usually when// only half the files have been processed), so we only use it for mounting/unmounting.//UpdateProgressWithInfo(progress_op, progress_msg, progress_offset wParam, progress_total);break;case WIM_MSG_PROCESS:{qDebug()[WIM_MSG_PROCESS] --;PWSTR pszFullPath(PWSTR)wParam ;qDebug()WIM_MSG_PROCESS pszFullPath : QString::fromWCharArray(pszFullPath);// The amount of files processed is overwhelming (16k for a typical image),// and trying to display it *WILL* slow us down, so we dont.pbCancel (PBOOL)lParam;*pbCancel TRUE;break;} // break;case WIM_MSG_FILEINFO:{qDebug()[WIM_MSG_FILEINFO] --;pFileData (PWIN32_FIND_DATA)lParam;if (pFileData-dwFileAttributes FILE_ATTRIBUTE_DIRECTORY) {//!文件夹qDebug()[Dir] QString::fromWCharArray((PWSTR)pFileData-cFileName);qDebug()[wParam] QString::fromWCharArray((PWSTR)wParam);} else {//!文件qDebug()[File] QString::fromWCharArray(pFileData-cFileName);qDebug()[wParam] QString::fromWCharArray((PWSTR)wParam);}break;}case WIM_MSG_RETRY:qDebug()[WIM_MSG_RETRY] --;level retry;// fall throughcase WIM_MSG_INFO:if (level NULL) level info;// fall throughcase WIM_MSG_WARNING:if (level NULL) level warning;// fall throughcase WIM_MSG_ERROR:if (level NULL) level error;SetLastError((DWORD)lParam);qDebug(WIM processing %s: %S [%d]\n, level, (PWSTR)wParam, GetLastError());break;}return WIM_MSG_SUCCESS; }//!提取镜像TempFilePath tempObj;//临时文件夹wchar_t* wtemptempObj.GetTempDirU();//QString Imagepath 镜像路径wchar_t* wimage_utf8_to_wchar(Imagepath.toStdString().c_str());//QString descpath 提取到指定文件夹wchar_t* wdst_utf8_to_wchar(descpath.toStdString().c_str());HANDLE hWim NULL;HANDLE hImageNULL;DWORD dw0;PF_INIT_OR_OUT(WIMRegisterMessageCallback, Wimgapi);PF_INIT_OR_OUT(WIMCreateFile, Wimgapi);PF_INIT_OR_OUT(WIMSetTemporaryPath, Wimgapi);PF_INIT_OR_OUT(WIMLoadImage, Wimgapi);PF_INIT_OR_OUT(WIMApplyImage, Wimgapi);PF_INIT_OR_OUT(WIMCloseHandle, Wimgapi);PF_INIT_OR_OUT(WIMUnregisterMessageCallback, Wimgapi);//设置回调函数if (pfWIMRegisterMessageCallback(NULL, (FARPROC)WimProgressCallback, NULL) INVALID_CALLBACK_VALUE) {qDebug( Could not set progress callback: %d, GetLastError());goto out;}hWim pfWIMCreateFile(wimage, WIM_GENERIC_READ|WIM_GENERIC_MOUNT, WIM_OPEN_EXISTING,WIM_UNDOCUMENTED_BULLSHIT , 0, NULL);if (hWim NULL) {qDebug( Could not access image: %d, GetLastError());goto out;}if (!pfWIMSetTemporaryPath(hWim, wtemp)) {qDebug( Could not set temp path: %d, GetLastError());goto out;}//指定镜像索引indexhImage pfWIMLoadImage(hWim, index);if (hImage NULL) {qDebug( Could not set index: %d, GetLastError());goto out;}//! WIM_FLAG_FILEINFO 提取镜像if (!pfWIMApplyImage(hImage, wdst, WIM_FLAG_FILEINFO)) {qDebug( Could not Export WIM Image: %d, GetLastError());goto out;}out:if ((hImage ! NULL) || (hWim ! NULL)) {qDebug(Closing: %s, Image_path.toStdString().c_str());if (hImage ! NULL)pfWIMCloseHandle(hImage);if (hWim ! NULL)pfWIMCloseHandle(hWim);}if (pfWIMUnregisterMessageCallback ! NULL)pfWIMUnregisterMessageCallback(NULL, (FARPROC)WimProgressCallback);safe_free(wimage);safe_free(wdst);safe_free(wtemp);提示 pfWIMApplyImage 函数的 WIM_FLAG_NO_APPLY 属性不提取文件只会在回调函数中返回WIM_MSG_PROCESS信号同时可输出文件路径可用于统计文件目录数量WIM_FLAG_FILEINFO 属性会提取文件按目录结构写入指定文件夹中会在回调函数中返回WIM_MSG_FILEINFO信号。
http://www.pierceye.com/news/757610/

相关文章:

  • 沈阳网站建设 景乔科技网站制作杭州
  • 网站维护工程师月薪多少精品网站建设公
  • 永久免费企业网站申请网站开发主框架一般用什么布局
  • 网站做非经营性广告需备案python免费看电影的应用
  • 网站分哪些种类自己做网站模版
  • 汪峰做的音乐网站长沙制作公园仿竹护栏实体厂家
  • 深圳专业网站建设公司排名好的h5网站模板
  • h5做网站教程网店营销的推广方法有哪些
  • 网站关键词快速排名工具wordpress子主题
  • 做百度网站那家好google 网站质量问题
  • 网站建设维护书网站资料清单
  • 网站建设公司 深圳信科网站维护计划
  • 做网站用什么语言比较简单网站seo优化总结
  • 四川省工程建设信息网站南京好的网站设计公司
  • 城市建设单招网站合肥哪个公司做网站好
  • 深圳建站模板建站建筑公司对企业未来希望
  • 商丘网站制作电话文库网站建设
  • 新闻发布网站模板医院网站建设原理
  • 网站开发立项报告网页制作视频教程优质课
  • 网站运营分析竞争对手整站采集wordpress
  • 创建一个网站所需的成本厦门礼品网站商城制作案例
  • 南昌建设企业网站公司游戏源码
  • 网站当电话线做php网站教程视频教程
  • 百度里面的站长工具怎么取消怎么注册公司官网
  • 网站开发遵循软件管理工程师
  • 网站开发问题论文武进网站建设机构
  • 网站建设有哪些种类网站开发工程师岗位
  • 电大形考任在哪个网站做旺道seo优化软件怎么用
  • 新网 网站备案好的作文网站
  • 网站建设技术外包深圳建设公司网站