private void getWimButtom_Click(object sender, EventArgs e) { using (var dialog = new OpenFileDialog()) { dialog.Filter = "WIM Files(*.wim) | *.wim"; //setup here if (dialog.ShowDialog() == DialogResult.OK) //check for OK...they might press cancel, so don't do anything if they did. { dismOutputListbox.Items.Add("Image Info"); try { DismApi.Initialize(DismLogLevel.LogErrors); var api = DismApi.GetImageInfo(dialog.InitialDirectory + dialog.FileName); foreach (var imageInfo in api) { dismOutputListbox.Items.Add("Index: " + imageInfo.ImageIndex + " Image Description: " + imageInfo.ImageDescription); } } finally { // Shut down the DismApi DismApi.Shutdown(); } } } }
/// <summary> /// WIMFile Search on Mount Wim /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void wimFileSearchButton_Click(object sender, EventArgs e) { DismApi.Initialize(DismLogLevel.LogErrors); using (var dialog = new OpenFileDialog()) { dialog.Filter = "WIM Files(*.wim) | *.wim"; //setup here if (dialog.ShowDialog() == DialogResult.OK) //check for OK...they might press cancel, so don't do anything if they did. { wimFileTextBox.Text = dialog.InitialDirectory + dialog.FileName; Task.Factory.StartNew(() => { try { var api = DismApi.GetImageInfo(dialog.InitialDirectory + dialog.FileName); Task.Run(() => { if (this.InvokeRequired) { this.Invoke((MethodInvoker)(() => { dismOutputListbox.Items.Add("Image Info"); foreach (var imageInfo in api) { dismOutputListbox.Items.Add("Index: " + imageInfo.ImageIndex + " Image Description: " + imageInfo.ImageDescription); } })); } }); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } finally { // Shut down the DismApi DismApi.Shutdown(); } }); } else { DismApi.Shutdown(); } } }
public void GetImageInfoFromTestWim() { DismImageInfoCollection imageInfos = DismApi.GetImageInfo(Template.FullPath); imageInfos.Count.ShouldBe(2); foreach (DismImageInfo imageInfo in imageInfos) { imageInfo.Architecture.ShouldBe(TestWimTemplate.Architecture); imageInfo.DefaultLanguage.ShouldBe(TestWimTemplate.DefaultLangauge); imageInfo.EditionId.ShouldBe(TestWimTemplate.EditionId); imageInfo.ImageDescription.ShouldStartWith(TestWimTemplate.ImageNamePrefix); imageInfo.ImageName.ShouldStartWith(TestWimTemplate.ImageNamePrefix); imageInfo.InstallationType.ShouldBe(TestWimTemplate.InstallationType); imageInfo.ProductName.ShouldBe(TestWimTemplate.ProductName); imageInfo.ProductType.ShouldBe(TestWimTemplate.ProductType); imageInfo.ProductVersion.ShouldBe(TestWimTemplate.ProductVersion); imageInfo.SpLevel.ShouldBe(TestWimTemplate.SpLevel); } }
private void search_wim() { //block buttons en_dis_able_everything(false); //clear progress bar refresh_progress_bar_step(0, 100); refresh_progress_bar_total(0, 100); //status bar refresh_status_label("Status", "Busy"); List <string> wim_file_list = new List <string>(); wim_file_list = Directory.GetFiles(search_path, search_keyword, SearchOption.AllDirectories).ToList(); this.listView_vol.BeginUpdate(); DismApi.Initialize(DismLogLevel.LogErrors); this.listView_vol.Items.Clear(); for (int i = 0; i < wim_file_list.Count; i++) { DismImageInfoCollection imageInfos = DismApi.GetImageInfo(wim_file_list[i]); for (int j = 0; j < imageInfos.Count; j++) { ListViewItem item_buff = new ListViewItem(wim_file_list[i]); //vol item_buff.SubItems.Add(imageInfos[j].ImageIndex.ToString()); //name item_buff.SubItems.Add(imageInfos[j].ImageName); //platform string platform_translated; switch (imageInfos[j].Architecture) { case DismProcessorArchitecture.None: platform_translated = "None"; break; case DismProcessorArchitecture.Intel: platform_translated = "x86"; break; case DismProcessorArchitecture.AMD64: platform_translated = "amd64"; break; case DismProcessorArchitecture.IA64: platform_translated = "ia64"; break; case DismProcessorArchitecture.Neutral: platform_translated = "neutral"; break; default: platform_translated = "unknow"; break; } item_buff.SubItems.Add(platform_translated); //lang item_buff.SubItems.Add(imageInfos[j].DefaultLanguage.Name); //version item_buff.SubItems.Add(imageInfos[j].ProductVersion.ToString()); this.listView_vol.Items.Add(item_buff); //progress bar for total index in single file refresh_progress_bar_step(j + 1, imageInfos.Count); } //progress bar for total file refresh_progress_bar_total(i + 1, wim_file_list.Count); } DismApi.Shutdown(); this.listView_vol.EndUpdate(); this.listView_vol.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); //unblock buttos en_dis_able_everything(true); refresh_status_label("Status", "Ready"); }