When i try to capture image with compres.Xpress or compres.lzx the code not working, look like a the script
stops working and does nothing
//Release Function to Capture Image WIMGAPI
void WIMGAPI_CaptureImage()
{
try
{
WimgApi.RegisterLogFile(@"W:\logfileResult.txt");
// Open a handle to the .wim file
WimHandle _handle = WimgApi.CreateFile(@"W:\Test_LZX_Compress.wim",
WimFileAccess.Write,
WimCreationDisposition.CreateNew,
WimCreateFileOptions.Verify,
WimCompressionType.Xpress);
try
{
//Always create a temporal path to create a temporal files during the capture
WimgApi.SetTemporaryPath(_handle, @"W:\");
//Create delegate to get information during de capturing image
//wimMessageCallback = new WimMessageCallback(WimCallBack); verify if is necessary create a instance
//Register the callback method with the specific handle returned by wimgapi.CreateFile
WimgApi.RegisterMessageCallback(_handle, WimCallBackMethod);
//Call function to Capture the image
_handleByCapturingImg = WimgApi.CaptureImage(_handle, @"D:\", WimCaptureImageOptions.None);
}
finally
{
// Be sure to unregister the callback method
WimgApi.UnregisterMessageCallback(_handle, WimCallBackMethod);
WimgApi.UnregisterLogFile(@"W:\logfileResult.txt");
}
//Be sure that close the handle for the capturing image next close the handle for the createfile
_handleByCapturingImg.Close();
_handle.Close();
MessageBox.Show("Capture Image Finished");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnCaptureWimGapi_Click(object sender, EventArgs e)
{
WIMGAPI_CaptureImage();
}
private WimMessageResult WimCallBackMethod(WimMessageType _MessageType, object _message, object _userData)
{
// This method is called for every single action during the process being executed.
// In the case of apply, you'll get Progress, Info, Warnings, Errors, etc
//
// The trick is to determine the message type and cast the "message" param to the corresponding type
//
_WimMessageResult = WimMessageResult.Success;
switch (_MessageType)
{
case WimMessageType.Progress: // Some progress is being sent
// Get the message as a WimMessageProgress object
//
WimMessageProgress progressMessage = (WimMessageProgress)_message;
// Print the progress
//
lblProgress.Text = "progress: " + progressMessage.PercentComplete.ToString("#0.##%");
lblEstimatedTime.Text = "Estimated Time Remaining: " + progressMessage.EstimatedTimeRemaining.TotalMinutes.ToString();
lblEstimatedTime.Refresh();
lblProgress.Refresh();
break;
case WimMessageType.Process: // Some progress is being sent
// Get the message as a WimMessageProgress object
//
WimMessageProcess processMessage = (WimMessageProcess)_message;
// Print the Current file
//
lblFilesInfo.Text = "File: " + processMessage.Path;
lblFilesInfo.Refresh();
break;
case WimMessageType.Scanning: // Some progress is being sent
// Get the message as a WimMessageProgress object
//
WimMessageScanning scanningMessage = (WimMessageScanning)_message;
// Print the Current file
//
lblCountFiles.Text = "Count Files: " + scanningMessage.Count.ToString();
lblCountFiles.Refresh();
break;
case WimMessageType.Compress: // Some progress is being sent
// Get the message as a WimMessageProgress object
//
WimMessageCompress compressMessage = (WimMessageCompress)_message;
// Print the Current file
//
lblFilesInfo.Text = "Compress File: " + compressMessage.Path;
lblFilesInfo.Refresh();
break;
case WimMessageType.Warning: // A warning is being sent
// Get the message as a WimMessageProgress object
//
WimMessageWarning warningMessage = (WimMessageWarning)_message;
// Print the file and error code
//
_WimMessageResult = WimMessageResult.Abort;
break;
case WimMessageType.Error: // An error is being sent
// Get the message as a WimMessageError object
//
WimMessageError errorMessage = (WimMessageError)_message;
// Print the file and error code
//
Console.WriteLine("Error: {0} ({1})", errorMessage.Path, errorMessage.Win32ErrorCode);
_WimMessageResult = WimMessageResult.Abort;
break;
}
// Depending on what this method returns, the WIMGAPI will continue or cancel.
//
// Return WimMessageResult.Abort to cancel. In this case we return Success so WIMGAPI keeps going
return _WimMessageResult;
}
When i try to capture image with compres.Xpress or compres.lzx the code not working, look like a the script
stops working and does nothing
this is mi code
#region WIMGAPI
WimMessageCallback wimMessageCallback;
CopyFileProgressCallback copyFileProgressCallback;
CopyFileProgress _copyFiles;
WimMessageResult _WimMessageResult;
WimHandle _handleByCapturingImg;