在DELPHI中如何写入WIM镜像的名称及WIM镜像的描述 ( 积分: 100 )

  • 主题发起人 主题发起人 宋阳
  • 开始时间 开始时间

宋阳

Unregistered / Unconfirmed
GUEST, unregistred user!
在DELPHI中如何写入WIM镜像的名称及WIM镜像的描述<br>以下VC++的两个代码片断,在DELPHI如何实现写入WIM镜像的INFO?<br>片断1<br>void&nbsp;EditWIMFile(HANDLE&nbsp;hImg,&nbsp;int&nbsp;imgNum,&nbsp;LPWSTR&nbsp;pName,&nbsp;LPWSTR&nbsp;pDesc)<br>{<br> //Get&nbsp;the&nbsp;info&nbsp;and&nbsp;divide&nbsp;it&nbsp;into&nbsp;two&nbsp;strings<br> WCHAR&nbsp;*ImgInfoBuf,&nbsp;TempString[100];<br> DWORD&nbsp;ImgInfoBufSize;<br> WIMGetImageInformation(hImg,&nbsp;(LPVOID&nbsp;*)&amp;ImgInfoBuf,&nbsp;&amp;ImgInfoBufSize);<br> wsprintf(TempString,&nbsp;TEXT(&quot;&lt;IMAGE&nbsp;INDEX=/&quot;%d/&quot;&gt;&quot;),&nbsp;imgNum);&nbsp;<br> WCHAR&nbsp;*StringPointer&nbsp;=&nbsp;wcsstr(ImgInfoBuf,&nbsp;TempString);&nbsp;&nbsp;<br> WCHAR&nbsp;*SecondString&nbsp;=&nbsp;wcsstr(++StringPointer,&nbsp;TEXT(&quot;&lt;&quot;));&nbsp;<br> SecondString[-1]&nbsp;=&nbsp;0; //end&nbsp;the&nbsp;first&nbsp;string&nbsp;&nbsp;<br><br> //Copy&nbsp;the&nbsp;first&nbsp;string&nbsp;to&nbsp;a&nbsp;new&nbsp;buffer&nbsp;and&nbsp;add&nbsp;our&nbsp;extra&nbsp;info<br> WCHAR&nbsp;*NewInfoBuf&nbsp;=&nbsp;(WCHAR&nbsp;*)LocalAlloc(LPTR,&nbsp;ImgInfoBufSize&nbsp;+&nbsp;200&nbsp;*&nbsp;sizeof(WCHAR));<br> lstrcpy(NewInfoBuf,&nbsp;ImgInfoBuf);<br> if&nbsp;(*pName)&nbsp;{<br> wsprintf(TempString,&nbsp;TEXT(&quot;&nbsp;&lt;NAME&gt;%s&lt;/NAME&gt;/n&nbsp;&nbsp;&quot;),&nbsp;pName);<br> lstrcat(NewInfoBuf,&nbsp;TempString);&nbsp;<br> }<br> if&nbsp;(*pDesc)&nbsp;{<br> if&nbsp;(*pName)<br> wsprintf(TempString,&nbsp;TEXT(&quot;&lt;DESCRIPTION&gt;%s&lt;/DESCRIPTION&gt;/n&nbsp;&nbsp;&quot;),&nbsp;pDesc);<br> else<br> wsprintf(TempString,&nbsp;TEXT(&quot;&nbsp;&lt;DESCRIPTION&gt;%s&lt;/DESCRIPTION&gt;/n&nbsp;&nbsp;&quot;),&nbsp;pDesc);<br> lstrcat(NewInfoBuf,&nbsp;TempString);&nbsp;<br> }<br><br> //Add&nbsp;the&nbsp;second&nbsp;string&nbsp;to&nbsp;the&nbsp;new&nbsp;buffer&nbsp;and&nbsp;reset&nbsp;the&nbsp;info&nbsp;in&nbsp;the&nbsp;file<br> lstrcat(NewInfoBuf,&nbsp;SecondString);<br> WIMSetImageInformation(hImg,&nbsp;NewInfoBuf,&nbsp;wcslen(NewInfoBuf)&nbsp;*&nbsp;sizeof(WCHAR));<br><br> //Free&nbsp;the&nbsp;storage<br> LocalFree(ImgInfoBuf);<br> LocalFree(NewInfoBuf);<br>}<br>片断2<br>void&nbsp;__fastcall&nbsp;TMycallback::Aeditnewwimfile(HANDLE&nbsp;hImg,&nbsp;int&nbsp;imgNum,&nbsp;AnsiString&nbsp;pName,&nbsp;AnsiString&nbsp;pDesc)<br>{<br>AnsiString&nbsp;aall,&nbsp;aa,&nbsp;bb,&nbsp;cc,&nbsp;dd;<br>wchar_t&nbsp;*ImgInfoBuf,&nbsp;*NewInfoBuf;<br>DWORD&nbsp;ImgInfoBufSize;<br>int&nbsp;pre;<br><br>ImgInfoBuf&nbsp;=&nbsp;new&nbsp;wchar_t[20000];<br>WIMGetImageInformation(hImg,&nbsp;(LPVOID&nbsp;*)&amp;ImgInfoBuf,&nbsp;&amp;ImgInfoBufSize);<br>aall&nbsp;=&nbsp;String(WideCharToString(ImgInfoBuf));<br>bb&nbsp;=&nbsp;String(&quot;&lt;IMAGE&nbsp;INDEX=/&quot;&quot;&nbsp;+&nbsp;String(imgNum)&nbsp;+&nbsp;&quot;/&quot;&gt;&quot;);<br>aa&nbsp;=&nbsp;String(aall.SubString(1,&nbsp;aall.Pos(bb)&nbsp;-&nbsp;1));&nbsp;<br>pre&nbsp;=&nbsp;aa.Length()&nbsp;+&nbsp;bb.Length();&nbsp;&nbsp;<br>dd&nbsp;=&nbsp;String(aall.SubString(pre&nbsp;+&nbsp;1,&nbsp;aall.Length()&nbsp;-&nbsp;pre));&nbsp;<br><br>aall&nbsp;=&nbsp;String(aa)&nbsp;+&nbsp;String(bb);<br>aall&nbsp;+=&nbsp;String(&quot;/n&nbsp;&lt;NAME&gt;&quot;&nbsp;+&nbsp;pName&nbsp;+&nbsp;&quot;&lt;/NAME&gt;&quot;);<br>aall&nbsp;+=&nbsp;String(&quot;/n&nbsp;&lt;DESCRIPTION&gt;&quot;&nbsp;+&nbsp;pDesc&nbsp;+&nbsp;&quot;&lt;/DESCRIPTION&gt;&quot;);<br>aall&nbsp;+=&nbsp;String(dd);<br><br>NewInfoBuf&nbsp;=&nbsp;new&nbsp;wchar_t[20000];<br>aall.WideChar(NewInfoBuf,aall.WideCharBufSize());&nbsp;&nbsp;<br>WIMSetImageInformation(hImg,&nbsp;&amp;NewInfoBuf,&nbsp;/*aall.Length()*/wcslen(NewInfoBuf)&nbsp;*&nbsp;sizeof(WCHAR));<br>}
 
这是一个为微软新的系统封装工具Imagex.EXE而写的图形工具,只是不调用Imagex.EXE,而是直接调用wimgapi.dll中的函数,上面的VC++代码片断是一网友写的加入WIM镜像名称和镜像描述的部分代码;&nbsp;WIMGetImageInformation()函数是获取WIM信息,而WIMSetImageInformation()是写入修改后的WIM信息;<br>下面是wimgapi.dll函数中DELPHI中声明<br>&nbsp;const<br>&nbsp;&nbsp;WIMGAPI_DLL&nbsp;=&nbsp;'WIMGAPI.DLL';<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;WIM_GENERIC_READ&nbsp;=&nbsp;GENERIC_READ;<br>&nbsp;&nbsp;WIM_GENERIC_WRITE&nbsp;=&nbsp;GENERIC_WRITE;<br>&nbsp;&nbsp;WIM_CREATE_NEW&nbsp;=&nbsp;CREATE_NEW;<br>&nbsp;&nbsp;WIM_CREATE_ALWAYS&nbsp;=&nbsp;CREATE_ALWAYS;<br>&nbsp;&nbsp;WIM_OPEN_EXISTING&nbsp;=&nbsp;OPEN_EXISTING;<br>&nbsp;&nbsp;WIM_OPEN_ALWAYS&nbsp;=&nbsp;OPEN_ALWAYS;<br><br>&nbsp;&nbsp;WIM_COMPRESS_NONE&nbsp;=&nbsp;0;<br>&nbsp;&nbsp;WIM_COMPRESS_XPRESS&nbsp;=&nbsp;1;<br>&nbsp;&nbsp;WIM_COMPRESS_LZX&nbsp;=&nbsp;2;<br><br>&nbsp;&nbsp;WIM_CREATED_NEW&nbsp;=&nbsp;0;<br>&nbsp;&nbsp;WIM_OPENED_EXISTING&nbsp;=&nbsp;1;<br><br>&nbsp;&nbsp;WIM_FLAG_RESERVED&nbsp;=&nbsp;$00000001;<br>&nbsp;&nbsp;WIM_FLAG_VERIFY&nbsp;=&nbsp;$00000002;<br>&nbsp;&nbsp;WIM_FLAG_INDEX&nbsp;=&nbsp;$00000004;<br>&nbsp;&nbsp;WIM_FLAG_NO_APPLY&nbsp;=&nbsp;$00000008;<br>&nbsp;&nbsp;WIM_FLAG_NO_DIRACL&nbsp;=&nbsp;$00000010;<br>&nbsp;&nbsp;WIM_FLAG_NO_FILEACL&nbsp;=&nbsp;$00000020;<br>&nbsp;&nbsp;WIM_FLAG_SHARE_WRITE&nbsp;=&nbsp;$00000040;<br>&nbsp;&nbsp;WIM_FLAG_FILEINFO&nbsp;=&nbsp;$00000080;<br>&nbsp;&nbsp;WIM_FLAG_NO_RP_FIX&nbsp;=&nbsp;$00000100;<br><br>&nbsp;&nbsp;WIM_REFERENCE_APPEND&nbsp;=&nbsp;$00010000;<br>&nbsp;&nbsp;WIM_REFERENCE_REPLACE&nbsp;=&nbsp;$00020000;<br>&nbsp;&nbsp;WIM_EXPORT_ALLOW_DUPLICATES&nbsp;=&nbsp;$00000001;<br>&nbsp;&nbsp;WIM_EXPORT_ONLY_RESOURCES&nbsp;=&nbsp;$00000002;<br>&nbsp;&nbsp;WIM_EXPORT_ONLY_METADATA&nbsp;=&nbsp;$00000004;<br><br>&nbsp;&nbsp;INVALID_CALLBACK_VALUE&nbsp;=&nbsp;$FFFFFFFF;<br>&nbsp;&nbsp;WIM_COPY_FILE_RETRY&nbsp;=&nbsp;$01000000;<br><br>&nbsp;&nbsp;WIM_MSG&nbsp;=&nbsp;WM_APP&nbsp;+&nbsp;$1476;<br>&nbsp;&nbsp;WIM_MSG_TEXT&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;WIM_MSG_PROGRESS&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;2;<br>&nbsp;&nbsp;WIM_MSG_PROCESS&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;3;<br>&nbsp;&nbsp;WIM_MSG_SCANNING&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;4;<br>&nbsp;&nbsp;WIM_MSG_SETRANGE&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;5;<br>&nbsp;&nbsp;WIM_MSG_SETPOS&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;6;<br>&nbsp;&nbsp;WIM_MSG_STEPIT&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;7;<br>&nbsp;&nbsp;WIM_MSG_COMPRESS&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;8;<br>&nbsp;&nbsp;WIM_MSG_ERROR&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;9;<br>&nbsp;&nbsp;WIM_MSG_ALIGNMENT&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;10;<br>&nbsp;&nbsp;WIM_MSG_RETRY&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;11;<br>&nbsp;&nbsp;WIM_MSG_SPLIT&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;12;<br>&nbsp;&nbsp;WIM_MSG_FILEINFO&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;13;<br>&nbsp;&nbsp;WIM_MSG_INFO&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;14;<br>&nbsp;&nbsp;WIM_MSG_WARNING&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;15;<br>&nbsp;&nbsp;WIM_MSG_CHK_PROCESS&nbsp;=&nbsp;WIM_MSG&nbsp;+&nbsp;16;<br><br>&nbsp;&nbsp;WIM_MSG_SUCCESS&nbsp;=&nbsp;ERROR_SUCCESS;<br>&nbsp;&nbsp;WIM_MSG_DONE&nbsp;=&nbsp;$FFFFFFF0;<br>&nbsp;&nbsp;WIM_MSG_SKIP_ERROR&nbsp;=&nbsp;$FFFFFFFE;<br>&nbsp;&nbsp;WIM_MSG_ABORT_IMAGE&nbsp;=&nbsp;$FFFFFFFF;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_NORMAL&nbsp;=&nbsp;$00000000;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_RESOURCE_ONLY&nbsp;=&nbsp;$00000001;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_METADATA_ONLY&nbsp;=&nbsp;$00000002;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_VERIFY_DATA&nbsp;=&nbsp;$00000004;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_RP_FIX&nbsp;=&nbsp;$00000008;<br><br>&nbsp;&nbsp;WIM_ATTRIBUTE_SPANNED&nbsp;=&nbsp;$00000010;<br>&nbsp;&nbsp;WIM_ATTRIBUTE_READONLY&nbsp;=&nbsp;$00000020;<br>type<br>&nbsp;&nbsp;//LPWIM_INFO&nbsp;=&nbsp;^PWIM_INFO;<br>&nbsp;&nbsp;PWIM_INFO&nbsp;=&nbsp;^WIM_INFO;<br>&nbsp;&nbsp;WIM_INFO_A&nbsp;=&nbsp;packed&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;WimPath:&nbsp;array[0..MAX_PATH&nbsp;-&nbsp;1]&nbsp;of&nbsp;WideChar;<br>&nbsp;&nbsp;&nbsp;&nbsp;Guid:&nbsp;TGUID;<br>&nbsp;&nbsp;&nbsp;&nbsp;ImageCount:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;CompressionType:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;PartNumber:&nbsp;WORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;TotalParts:&nbsp;WORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;BootIndex:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;WimAttributes:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;WimFlagsAndAttr:&nbsp;DWORD;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;WIM_INFO&nbsp;=&nbsp;WIM_INFO_A;<br><br>&nbsp;&nbsp;//LPWIM_MOUNT_LIST&nbsp;=&nbsp;^PWIM_MOUNT_LIST;<br>&nbsp;&nbsp;PWIM_MOUNT_LIST&nbsp;=&nbsp;^WIM_MOUNT_LIST;<br>&nbsp;&nbsp;WIM_MOUNT_LIST_A&nbsp;=&nbsp;packed&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;WimPath:&nbsp;array[0..MAX_PATH&nbsp;-&nbsp;1]&nbsp;of&nbsp;WideChar;<br>&nbsp;&nbsp;&nbsp;&nbsp;MountPath:&nbsp;array[0..MAX_PATH&nbsp;-&nbsp;1]&nbsp;of&nbsp;WideChar;<br>&nbsp;&nbsp;&nbsp;&nbsp;ImageIndex:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;&nbsp;MountedForRW:&nbsp;BOOL;<br><br><br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;WIM_MOUNT_LIST&nbsp;=&nbsp;WIM_MOUNT_LIST_A;<br><br>&nbsp;&nbsp;PLARGE_INTEGER&nbsp;=&nbsp;^LARGE_INTEGER;<br><br>//////////////////////////<br>Function&nbsp;WIMApplyImage(hImage:thandle;&nbsp;lpszPath:widestring;dzApplyFlags:DWORD):LongBool;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMCreateFile(lpszWimPath:PWideChar;dwDesiredAccess,dwCreationDisposition,dwFlagsAndAttributes,dwCompressionType:DWORD;var&nbsp;lpdwCreationResult:PDWORD):THandle;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMSetTemporaryPath(hWnd:THandle;TemporaryPath:widestring):Integer;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMLoadImage(hWnd:THandle;ImageIndex:longint):THandle;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMCloseHandle(Handle:Thandle):longbool;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMDeleteImage(hWim:&nbsp;THandle;<br>&nbsp;&nbsp;dwImageIndex:&nbsp;DWORD):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMMountImage(lpszMountPath,&nbsp;lpszWimFileName:&nbsp;widestring;<br>&nbsp;&nbsp;dwImageIndex:&nbsp;DWORD;<br>&nbsp;&nbsp;lpszTempPath:&nbsp;widestring):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMUnmountImage(lpszMountPath,&nbsp;lpszWimFileName:&nbsp;widestring;<br>&nbsp;&nbsp;dwImageIndex:&nbsp;DWORD;<br>&nbsp;&nbsp;bCommitChanges:&nbsp;BOOL):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMGetImageCount(hWim:&nbsp;THandle):&nbsp;DWORD;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMGetImageInformation(hImage:&nbsp;HWND;<br>&nbsp;&nbsp;pvImageInfo:&nbsp;Pointer;<br>&nbsp;&nbsp;lpcbImageInfo:PDWord):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>&nbsp;Function&nbsp;WIMCaptureImage(hWim:&nbsp;HWND;<br>&nbsp;&nbsp;lpszCapturePath:&nbsp;widestring;<br>&nbsp;&nbsp;dwCaptureFlags:&nbsp;DWORD):&nbsp;HWND;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMExportImage(shImage,&nbsp;thWim:&nbsp;HWND;<br>&nbsp;&nbsp;dwFlags:&nbsp;DWORD):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMUnregisterMessageCallback(hWim:&nbsp;HWND;<br>&nbsp;&nbsp;fpMessageProc:&nbsp;Pointer):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMRegisterMessageCallback(hWim:&nbsp;HWND;<br>&nbsp;&nbsp;fpMessageProc,&nbsp;pvUserData:&nbsp;Pointer):&nbsp;DWORD;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>&nbsp;Function&nbsp;WIMSetImageInformation(hImage:&nbsp;HWND;<br>&nbsp;&nbsp;pvImageInfo:&nbsp;Pointer;<br>&nbsp;&nbsp;cbImageInfo:&nbsp;DWORD):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMGetMessageCallbackCount(hWim:&nbsp;HWND):&nbsp;DWORD;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;<br>Function&nbsp;WIMGetAttributes(hWim:&nbsp;HWND;<br>&nbsp;&nbsp;lpcbImageInfo:&nbsp;PWIM_INFO;<br>&nbsp;&nbsp;cbWimInfo:&nbsp;DWORD):&nbsp;BOOL;&nbsp;stdcall;&nbsp;external&nbsp;WIMGAPI_DLL;
 
无结果结题了
 
把记录设计成链表,<br>&nbsp;WIM_MOUNT_LIST_A&nbsp;=&nbsp;packed&nbsp;record<br>&nbsp;&nbsp;&nbsp;WimPath:&nbsp;array[0..MAX_PATH&nbsp;-&nbsp;1]&nbsp;of&nbsp;WideChar;<br>&nbsp;&nbsp;&nbsp;MountPath:&nbsp;array[0..MAX_PATH&nbsp;-&nbsp;1]&nbsp;of&nbsp;WideChar;<br>&nbsp;&nbsp;&nbsp;ImageIndex:&nbsp;DWORD;<br>&nbsp;&nbsp;&nbsp;MountedForRW:&nbsp;BOOL;<br>&nbsp;&nbsp;&nbsp;Next:&nbsp;WIM_MOUNT_LIST_A&nbsp;^;<br>&nbsp;&nbsp;end;<br>读下一条就是读Next。<br><br>或者把记录存入TList,就不用自己设计链表了。
 
没看你代码,大致应该这样的吧(我也没用WIMGAPI,只是想当然了)<br><br>var&nbsp;<br>&nbsp;p&nbsp;:&nbsp;PWIM_MOUNT_LIST;<br>&nbsp;n&nbsp;:&nbsp;DWORD;<br>begin<br>&nbsp;p&nbsp;:=&nbsp;AllocMem(SizeOf(WIM_MOUNT_LIST)*1000);<br>&nbsp;WIMGetMountedImages(p,&nbsp;@n);<br>&nbsp;//p&nbsp;指向第一条记录<br>&nbsp;inc(p);<br>&nbsp;//现在p指向第二条记录<br>&nbsp;。。。。。<br>&nbsp;FreeMem(p);<br>end;
 
tseug:你好!<br>&nbsp;&nbsp;&nbsp;&nbsp;看来你对WIMGAPI是比较了解的,一看就知道的&nbsp;WIMGetMountedImages的问题<br>我曾经试过<br>var<br>&nbsp;MOUNT_LIST:&nbsp;WIM_MOUNT_LIST;<br>&nbsp;MOUN_Size:DWORD;<br>begin<br>&nbsp;&nbsp;MOUN_Size:=SizeOf(MOUNT_LIST);<br>&nbsp;&nbsp;WIMGetMountedImages(@MOUNT_LIST,@MOUN_Size);<br>&nbsp;&nbsp;FOR&nbsp;I:=1&nbsp;TO&nbsp;MOUN_Size&nbsp;div&nbsp;1048&nbsp;do&nbsp;begin&nbsp;//1048是每个记录的长度<br>&nbsp;&nbsp;memo1.Lines.Add(MOUNT_LIST.WimPath&nbsp;);<br>&nbsp;&nbsp;memo1.Lines.Add(MOUNT_LIST.MountPath&nbsp;);<br>&nbsp;&nbsp;{在此如何把指针移动第二条记呢?我就是不会移.......}<br>&nbsp;end;<br>END:<br>//MOUN_Size&nbsp;div&nbsp;1048&nbsp;可以获得挂载的镜像数<br>//而我也仅仅只能获取第一个已挂载的镜像信息,无法已挂载的第二个镜像的信息
 
&gt;WIMGetMountedImages(@MOUNT_LIST,@MOUN_Size);<br>动态分配内存比较方便,要不喜欢动态分配,你试试下面代码<br><br>var<br>&nbsp;MOUNT_LIST:&nbsp;array[0..MAXINT&nbsp;div&nbsp;SizeOf(WIM_MOUNT_LIST)-1]&nbsp;of&nbsp;WIM_MOUNT_LIST;<br>&nbsp;MOUN_Size:DWORD;<br>begin<br>&nbsp;&nbsp;MOUN_Size:=SizeOf(MOUNT_LIST);<br>&nbsp;&nbsp;WIMGetMountedImages(@MOUNT_LIST,@MOUN_Size);<br>&nbsp;&nbsp;FOR&nbsp;I:=Low(MOUNT_LIST)&nbsp;TO&nbsp;High(MOUNT_LIST)&nbsp;do&nbsp;begin&nbsp;//1048是每个记录的长度<br>&nbsp;&nbsp;memo1.Lines.Add(MOUNT_LIST.WimPath&nbsp;);<br>&nbsp;&nbsp;memo1.Lines.Add(MOUNT_LIST.MountPath&nbsp;);<br>&nbsp;&nbsp;{在此如何把指针移动第二条记呢?我就是不会移.......}<br>&nbsp;end;
 
tseug:你好<br>&nbsp;&nbsp;&nbsp;这个也不行,有这个提示'Stack&nbsp;overflow'。
 
抱歉,因为我手头没有WIMGAPI.DLL,也没找到相关帮助,要不你把DLL发给我一份,<br>我试试吧。
 
tseug:你好<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;我准备把wimgapi.dll和SDK在DELPHI中的申明一起发给你,关键是怎么发?发到那里?
 
发我邮箱吧tseug@263.net
 
你试试下面代码吧,我这没法试验,有结果了说一声<br><br>
代码:
uses<br>&nbsp;&nbsp;WImgApi;<br><br>procedure&nbsp;TForm25.Button1Click(Sender:&nbsp;TObject);<br>var<br>&nbsp;&nbsp;MntList&nbsp;:&nbsp;PWIM_MOUNT_LIST;<br>&nbsp;&nbsp;BufSize&nbsp;:&nbsp;Dword;<br><br>&nbsp;&nbsp;I&nbsp;:&nbsp;Integer;<br>&nbsp;&nbsp;P&nbsp;:&nbsp;PWIM_MOUNT_LIST;<br>begin<br>&nbsp;&nbsp;//缓冲区最大容量,&nbsp;不知道100够不够<br>&nbsp;&nbsp;BufSize&nbsp;:=&nbsp;100&nbsp;*&nbsp;SizeOf(WIM_MOUNT_LIST);&nbsp;//我也不知道该不该乘<br><br>&nbsp;&nbsp;//申请内存<br>&nbsp;&nbsp;MntList&nbsp;:=&nbsp;AllocMem(BufSize);<br>&nbsp;&nbsp;try<br><br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;WIMGetMountedImages(MntList,&nbsp;@BufSize)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//逐项显示<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P&nbsp;:=&nbsp;MntList;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;BufSize&nbsp;div&nbsp;SizeOf(WIM_MOUNT_LIST)&nbsp;-&nbsp;1&nbsp;do&nbsp;//同样,我也不知道该不该除<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memo1.Lines.Add(Format('%WIMPath=%s,&nbsp;MountPath=%s,&nbsp;ImageIndex=%d',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[P^.WimPath,&nbsp;P^.MountPath,&nbsp;P^.ImageIndex]));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(P);&nbsp;&nbsp;//指针指向下一项<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Memo1.Lines.Add(SysErrorMessage(GetLastError));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;FreeMem(MntList);<br>&nbsp;&nbsp;end;<br><br>end;
 
就是&nbsp;Memo1.Lines.Add(Format('%WIMPath=%s,&nbsp;MountPath=%s,&nbsp;ImageIndex=%d',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[P^.WimPath,&nbsp;P^.MountPath,&nbsp;P^.ImageIndex]));这句不是问题的问题改一下<br>Memo1.Lines.Add(Format('WIMPath=%s,&nbsp;MountPath=%s,&nbsp;ImageIndex=%d',<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[P^.WimPath,&nbsp;P^.MountPath,&nbsp;P^.ImageIndex]));<br>成功!OK<br>问题结束了。
 
后退
顶部