Mount Image

May 12, 2015 at 4:41 PM
Hi, i try to mount with managed api an image, but it fails allways, with handle error

Here the code i use for mounting
using (WimHandle wimHandle = WimgApi.CreateFile(
                    Item.PathImg,
                    WimFileAccess.Mount,
                    WimCreationDisposition.OpenExisting,
                    WimCreateFileOptions.None,
                    WimCompressionType.None
                ))
                {
                    WimgApi.SetTemporaryPath(wimHandle, Environment.GetEnvironmentVariable("TEMP"));
                    WimgApi.RegisterMessageCallback(wimHandle, MyCallbackMethod);
                    using (WimHandle imgHandle = WimgApi.LoadImage(wimHandle, 1))
                    {
                        try
                        {
                            WimgApi.MountImage(imgHandle, tempDirectory, WimMountImageOptions.None);
                           ...
                            WimgApi.UnmountImage(imgHandle);
                        }
                        catch (Exception Ex)
                        {
                            MessageBox.Show(Ex.ToString());
                        }
                    }
                    WimgApi.UnregisterMessageCallback(wimHandle, MyCallbackMethod);
                }
The error linked is:
System.ComponentModel.Win32Exception (0x80004005): Descripteur non valide
à Microsoft.Wim.WimgApi.MountImage(WimHandle imageHandle, String mountPath, WimMountImageOptions options)

When i try to mount directly with path-file and not by handle, that work.
I checked your documentation, i see that WimFileAccess need to be 'WimFileAccess.Mount'
but badly that dont work for me.
Have you the same problem?
Jan 28, 2016 at 9:24 PM
You need the read flag with the mount flag in createfile.