Jump to content

Splitting a WIM Image


Recommended Posts

Hey im having trouble splitting a wim image and keep getting "the parameter is incorrect", heres what i have..

Public Const WIM_COMPRESS_NONE As Byte = 0
Public Const WIM_COMPRESS_XPRESS As Byte = 1
Public Const WIM_COMPRESS_LZX As Byte = 2
Public Const WIM_GENERIC_READ As Long = &H80000000
Public Const WIM_GENERIC_WRITE As Long = &H40000000
Public Const WIM_Create_NEW As Byte = &H1
Public Const WIM_Create_ALWAYS As Byte = &H2
Public Const WIM_OPEN_EXISTING As Byte = &H3
Public Const WIM_OPEN_ALWAYS As Byte = &H4
Public Const WIM_CreateD_NEW As Byte = 0
Public Const WIM_OPENED_EXISTING As Byte = 1
Public Const WIM_FLAG_RESERVED As Byte = &H1
Public Const WIM_FLAG_VERIFY As Byte = &H2
Public Const WIM_FLAG_INDEX As Byte = &H4
Public Const WIM_FLAG_NO_APPLY As Byte = &H8
Public Const WIM_FLAG_NO_DIRACL As Byte = &H10
Public Const WIM_FLAG_NO_FILEACL As Byte = &H20
Public Const WIM_FLAG_SHARE_WRITE As Byte = &H40
Public Const WIM_FLAG_FILEINFO As Byte = &H80
Public Const WIM_FLAG_NO_RP_FIX As Integer = &H100
Public Const WIM_REFERENCE_APPEND As Long = &H10000
Public Const WIM_REFERENCE_REPLACE As Long = &H20000
Public Const WIM_EXPORT_ALLOW_DUPLICATES As Byte = &H1
Public Const WIM_EXPORT_ONLY_RESOURCES As Byte = &H2
Public Const WIM_EXPORT_ONLY_METADATA As Byte = &H4
Public Const INVALID_CALLBACK_VALUE As Long = &HFFFFFFFF
Public Const WIM_COPY_FILE_RETRY As Long = &H1000000
Public Const WIM_MSG_SUCCESS As Byte = 0&
Public Const WIM_MSG_DONE As Long = &HFFFFFFF0
Public Const WIM_MSG_SKIP_ERROR As Long = &HFFFFFFFE
Public Const WIM_MSG_ABORT_IMAGE As Long = &HFFFFFFFF
Public Const WIM_ATTRIBUTE_NORMAL As Byte = &H0
Public Const WIM_ATTRIBUTE_RESOURCE_ONLY As Byte = &H1
Public Const WIM_ATTRIBUTE_METADATA_ONLY As Byte = &H2
Public Const WIM_ATTRIBUTE_VERIFY_DATA As Byte = &H4
Public Const WIM_ATTRIBUTE_RP_FIX As Byte = &H8
Public Const WIM_ATTRIBUTE_SPANNED As Byte = &H10
Public Const WIM_ATTRIBUTE_READONLY As Byte = &H20


Private Declare Auto Function WIMCreateFile Lib "wimgapi.dll" (<MarshalAs(UnmanagedType.LPWStr)> ByVal WIMPath As String, ByVal AccessType As Integer, ByVal Creation As UInt32, ByVal Flags As UInt32, ByVal Compression As UInt32, ByRef CreationResult As Integer) As IntPtr
Private Declare Auto Function WIMGetImageInformation Lib "wimgapi.dll" (ByVal hWnd As IntPtr, ByRef ImageInfo As IntPtr, ByRef ImageInfoSize As IntPtr) As Boolean
Private Declare Auto Function WIMDeleteImage Lib "wimgapi.dll" (ByVal hWim As IntPtr, ByVal dwApplyFlags As Integer) As Boolean
Private Declare Auto Function WIMSetImageInformation Lib "WIMGAPI.DLL" (ByVal hImage As IntPtr, ByVal lpvImageInfo As Long, ByVal cbImageInfo As Integer) As Boolean
Private Declare Auto Function WIMMountImage Lib "wimgapi.dll" (ByVal eMountPath As String, ByVal eWimFile As String, ByVal eIndex As Integer, Optional ByVal eTempPath As String = "C:\Windows\Temp") As Boolean
Private Declare Auto Function WIMCloseHandle Lib "wimgapi.dll" (ByVal Handle As IntPtr) As Boolean
Private Declare Auto Function WIMSetTemporaryPath Lib "wimgapi.dll" (ByVal hWnd As IntPtr, <MarshalAs(UnmanagedType.LPWStr)> ByVal TemporaryPath As String) As Boolean
Private Declare Auto Function WIMExportImage Lib "wimgapi.dll" (ByVal hImage As IntPtr, ByVal hWim As IntPtr, ByVal dwApplyFlags As Integer) As Boolean
Private Declare Auto Function WIMLoadImage Lib "wimgapi.dll" (ByVal hwim As IntPtr, ByVal dwImageIndex As Integer) As IntPtr
Private Declare Auto Function WIMUnmountImage Lib "wimgapi.dll" (ByVal MountPath As String, ByVal WimFile As String, ByVal Index As Integer, ByVal CommitChanges As Boolean) As Boolean
Private Declare Auto Function WIMSplitFile Lib "wimgapi.dll" (ByVal hwim As IntPtr, ByVal lpszPartPath As String, ByRef pliPartSize As Integer, ByVal dwFlags As Integer) As Boolean

Dim sWimSplit As IntPtr = WIMCreateFile("D:\install.wim", WIM_GENERIC_READ, WIM_OPEN_EXISTING, WIM_FLAG_VERIFY, 0, 0)
If WIMSplitFile(sWimSplit, "C:\install.swm", 734003200, 0) = False Then GetLastDLLError()
WIMCloseHandle(sWimSplit)

734 003 200 = 700MB in bytes

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...