WIMGAPI的WIMApplyImage相关问题(VB.net),求大神帮忙看看

在vb.net中调用WIMGAPI.DLL
WIMExportImage 没有问题

Private Declare Function WIMExportImage Lib "wimgapi.dll" (ByVal hImage As IntPtr, ByVal hWim As IntPtr, ByVal dwApplyFlags As Integer) As Boolean

Private Declare Auto Function WIMSetTemporaryPath Lib "wimgapi.dll" (ByVal hWnd As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal TemporaryPath As String) As Boolean

Public Sub S_ExportImage(ByVal OriginalWIm As String, ByVal NewWIM As String, ByVal sIndex As Integer, ByVal Temp As String)
        Dim s As IntPtr = WIMCreateFile(OriginalWIm, WIM_GENERIC_READ, WIM_OPEN_EXISTING, WIM_FLAG_VERIFY, WIM_COMPRESS_NONE, WIM_OPENED_EXISTING)
        Dim t As IntPtr = WIMCreateFile(NewWIM, WIM_GENERIC_WRITE, WIM_OPEN_ALWAYS, WIM_FLAG_VERIFY, WIM_COMPRESS_XPRESS, WIM_CREATED_NEW)
        WIMSetTemporaryPath(t, Temp)
        WIMSetTemporaryPath(s, Temp)
        Dim si As IntPtr = WIMLoadImage(s, sIndex)
        WIMExportImage(si, t, 0)
        WIMCloseHandle(si)
        WIMCloseHandle(t)
        WIMCloseHandle(s)
        DeleteFolder(Temp, False)
    End Sub

但是WIMApplyImage 就不成功

Private Declare Function WIMApplyImage Lib "WIMGAPI.DLL" (ByVal hImage As IntPtr, ByVal lpszPath As String, ByVal dwApplyFlags As Integer) As Boolean
    Public Sub CWIM_WIMApplyImage(ByVal WimImg As String, ByVal Folder As String, ByVal sIndex As Integer)
        Dim s As IntPtr = WIMCreateFile(WimImg, WIM_GENERIC_READ, WIM_OPEN_EXISTING, WIM_FLAG_VERIFY, WIM_COMPRESS_NONE, WIM_OPENED_EXISTING)
        WIMSetTemporaryPath(s, "C:\Windows\Temp")
        Dim si As IntPtr = WIMLoadImage(s, sIndex)
        WIMApplyImage(si, Folder, sIndex)
        WIMCloseHandle(si)
    End Sub

不知道是哪里有错误?本人初学VB.NET,麻烦大神们帮忙看看!谢谢!

1
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!