Esempio n. 1
0
        public bool Getting_WindowsInfo(string path)
        {
            ManagedWimLib.Wim.GlobalInit("libwim-15.dll");
            try
            {
                ManagedWimLib.Wim     wim  = ManagedWimLib.Wim.OpenWim(path, ManagedWimLib.OpenFlags.DEFAULT);
                ManagedWimLib.WimInfo info = wim.GetWimInfo();
                string[] index             = new string[info.ImageCount];
                ManagedWimLib.CompressionType compression = info.CompressionType;

                for (int i = 0; i < info.ImageCount; i++)
                {
                    switch (info.CompressionType)
                    {
                    case ManagedWimLib.CompressionType.LZMS:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "LZMS");
                        break;

                    case ManagedWimLib.CompressionType.LZX:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "LZX");
                        break;

                    case ManagedWimLib.CompressionType.NONE:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "NONE");
                        break;

                    case ManagedWimLib.CompressionType.XPRESS:
                        Windows_Editions_List.Rows.Add(wim.GetImageDescription(i + 1), (info.TotalBytes / (1024 * 1024)).ToString() + " MB", "XPRESS");
                        break;
                    }
                }
                ManagedWimLib.Wim.GlobalCleanup();
                return(true);
            }
            catch
            {
                MessageBox.Show("Error loading the selected file: " + path);
                ManagedWimLib.Wim.GlobalCleanup();
                return(false);
            }
        }