Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Runtime.InteropServices;
- using JCotton.DismSharp.Interop;
- namespace JCotton.DismSharp {
- public class WindowsImage : IDisposable {
- private ImageType _imageType;
- private uint _imageIndex;
- private string _imageName;
- private string _imageDescription;
- private ulong _imageSize;
- private WindowsImageArchitecture _architecture;
- private string _productName;
- private string _editionId;
- private string _installationType;
- private string _hal;
- private string _productType;
- private string _productSuite;
- private Version _version;
- private uint _spBuild;
- private uint _spLevel;
- private ImageBootable _bootable;
- private string _systemRoot;
- private Collection<string> _languages;
- private uint _defaultLanguageIndex;
- private WimCustomizedInfo _customizedInfo;
- public ImageType ImageType => this._imageType;
- public uint ImageIndex => this._imageIndex;
- public string ImageName => this._imageName;
- public string ImageDescription => this._imageDescription;
- public ulong ImageSize => this._imageSize;
- public WindowsImageArchitecture Architecture => this._architecture;
- public string ProductName => this._productName;
- public string EditionId => this._editionId;
- public string InstallationType => this._installationType;
- public string Hal => this._hal;
- public string ProductType => this._productType;
- public string ProductSuite => this._productSuite;
- public Version Version => this._version;
- public uint SpBuild => this._spBuild;
- public uint SpLevel => this._spLevel;
- public ImageBootable Bootable => this._bootable;
- public string SystemRoot => this._systemRoot;
- public IReadOnlyList<string> Languages => this._languages;
- public string DefaultLanguage => this._languages[(int)this._defaultLanguageIndex];
- public WimCustomizedInfo CustomizedInfo => this._customizedInfo;
- public WindowsImage(DismImageInfo info) {
- this._imageType = info.ImageType;
- this._imageIndex = info.ImageIndex;
- this._imageName = info.ImageName;
- this._imageDescription = info.ImageDescription;
- this._imageSize = info.ImageSize;
- this._architecture = info.Architecture;
- this._productName = info.ProductName;
- this._productSuite = info.ProductSuite;
- this._version = new Version(
- (int)info.MajorVersion,
- (int)info.MinorVersion,
- (int)info.Build
- );
- this._spBuild = info.SpBuild;
- this._spLevel = info.SpLevel;
- this._bootable = info.Bootable;
- this._systemRoot = info.SystemRoot;
- this._languages = new Collection<string>(
- Utilites.PtrToArray<DismString>(
- info.Language,
- info.LanguageCount
- )
- .Select(l => l.Value)
- .ToList()
- );
- this._defaultLanguageIndex = info.DefaultLanguageIndex;
- this._customizedInfo = info.CustomizedInfo == IntPtr.Zero
- ? null
- : new WimCustomizedInfo(
- Marshal.PtrToStructure<DismWimCustomizedInfo>(info.CustomizedInfo)
- );
- }
- ~WindowsImage() {
- this.Dispose(false);
- }
- public void Dispose() {
- this.Dispose(true);
- GC.SuppressFinalize(this);
- }
- private void Dispose(bool disposing) {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement