Jump to content

Recommended Posts

Does anyone know how to use the WIM imaging format? What i am trying to do is figure out how to transpose this piece of code to VB.Net:

BOOL

WINAPI

WIMApplyImage(

IN HANDLE hImage,

IN LPWSTR lpszPath,

IN DWORD dwApplyFlags

);

Parameters

hImage

[in] A handle to a volume image returned by the WIMLoadImage or WIMCaptureImage functions.

lpszPath

[in] A pointer to a null-terminated string containing the root drive or directory path where the image data will be applied. The specified path must not exceed MAX_PATH characters in length.

dwApplyFlags

[in] Specifies how the file is to be treated and what features are to be used.

Flag Description

WIM_FLAG_VERIFY

Verified that files match original data.

WIM_FLAG_INDEX

Specifies that the image is to be sequentially read for caching or performance purposes.

WIM_FLAG_NO_APPLY

Applies the image without physically creating directories or files. Useful for obtaining a list of files and directories in the image.

WIM_FLAG_FILEINFO

Sends a WIM_MSG_FILEINFO message during the apply operation.

Return ValueIf the function succeeds, then the return value is nonzero.

If the function fails, then the return value is zero. To obtain extended error information, call the GetLastError function.

RemarksTo obtain more information during an image apply, see the WIMRegisterMessageCallback function.

To obtain the list of files in an image without actually applying the image, specify the WIM_FLAG_NO_APPLY flag and register a callback that handles the WIM_MSG_PROCESS message. To obtain additional file information from the WIM_MSG_FILEINFO message, specify the WIM_FLAG_FILEINFO.

The second part is:

Captures an image from a directory path and stores it in an image file.

C++

HANDLE

WINAPI

WIMCaptureImage(

IN HANDLE hWim,

IN LPWSTR lpszPath,

IN DWORD dwCaptureFlags

);

Parameters

hWim

[in] The handle to a .wim file returned by WIMCreateFile.

lpszPath

[in] A pointer to a null-terminated string containing the root drive or directory path from where the image data will be captured. The specified path must not exceed MAX_PATH characters in length.

dwCaptureFlags

[in] Specifies the features to use during the capture.

Flag Description

WIM_FLAG_VERIFY

Capture will verify single-instance files byte by byte.

Return ValueIf the function succeeds, then the return value is a handle to an object representing the volume image. If the function fails, then the return value is NULL. To obtain extended error information, call GetLastError.

RemarksTo obtain information during an image capture, see the WIMRegisterMessageCallback function.

The last is :

Registers a function to be called with imaging-specific data. For information about the messages that can be handled, see Messages.

C++

DWORD

WINAPI

WIMRegisterMessageCallback(

IN_OPT HANDLE hWim

IN FARPROC fpMessageProc,

IN_OPT LPVOID lpvUserData

);

Parameters

hWim

[in optional] The handle to a WIM file returned by WIMCreateFile.

fpMessageProc

[in] A pointer to an application-defined callback function. For more information, see the WIMMessageCallback function.

lpvUserData

[in] A pointer that specifies an application-defined value to be passed to the callback function.

Return ValueIf the function succeeds, then the return value is the zero-based index of the callback. If the function fails, then the return value is INVALID_CALLBACK_VALUE (0xFFFFFFFF). To obtain extended error information, call the GetLastError function.

RemarksIf a WIM handle is specified, the callback function will only receive messages regarding that WIM file. If no handle is specified, then the callback function will receive messages for all image handles.

Call the WIMUnregisterMessageCallback function when the callback function is no longer required.

Thanx in advance !

Link to comment
Share on other sites

  • 2 months later...

  • 1 month later...

Hi

I am also trying to write an ImageX app. However, I don't want to use .Net because there is no official support for this in WinPE 2. Even if .Net was added to WinPE 2, then we could only load WinPE in Ram on systems with 1Gb of memory or more. As it is WinPE 2 needs over 256Mb of ram and adding .Net would probably leave little free ram.

If anyone has the wimgapi.dll working with VB6 and can supply me with some basic VB6 code for using it I would be very grateful.

Thanks

Link to comment
Share on other sites

  • 1 month later...

I wrote a VB6 disk imaging app using SmartWim instead of the wimgapi sdk because of the hanging issues and lack of event sinking to script clients. SmartWim is an ActiveX component from http://www.smartdeploy.com that is based on the Wimgapi SDK and works flawlessly in VB, VBScript, DHTML, etc.

For instance, here is some VB6 code that applies an image while displaying a progress bar:

' In a form

Private WithEvents objSmartWim As SmartWim

Private Sub Command1_Click()

Dim ResultCode As swcError

Set objSmartWim = New SmartWim

objSmartWim.File = "C:\Image.wim"

objSmartWim.Name = "My Test Image"

objSmartWim.Path = "C:\Test"

ResultCode = objSmartWim.ApplyImage()

MsgBox objSmartWim.GetErrorDescription(ResultCode)

Set objSmartWim = Nothing

End Sub

Private Sub objSmartWim_Progress(ByVal nPercent As Integer, ByVal nSeconds As Long)

ProgressBar1.Value = nPercent

End Sub

That's it! No hangs, no gigantic declare sections, etc.

Have fun...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...