private void btnDeleteOsEntry_Click(object sender, EventArgs e) { string osEntryId = this.txtOSEntryToDelete.Text.Trim(); if (osEntryId.Substring(0, 1) != "{") { MessageBox.Show("Must surround guid for os entry with curly braces '{' and '}' "); return; } if (osEntryId.Trim().Length == 0) { MessageBox.Show("os entry is blank"); return; } if (MessageBox.Show("Are you sure you wish to delete this os entry?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } bool success = BcdStore_API.DeleteOsEntry(osEntryId); if (success) { // clean out any guid references in the display list, to avoid a COM error for invalid guid list item in display list pointing to // a guid which no longer exists in the store. List <string> guidDisplayList = BcdStore_API.GetBootManagerGUIDEntriesDisplayListAsList(); bool badOneInDisplayList = false; List <string> moddedList = new List <string>(); foreach (string guid in guidDisplayList) { if (guid == osEntryId) { badOneInDisplayList = true; } else { moddedList.Add(guid); } } if (badOneInDisplayList) { string errorDetails; success = BcdStore_API.SetOSDisplayListGuids(moddedList.ToArray(), "", out errorDetails); if (!success) { MessageBox.Show("deletion went thru okay, but trouble removing some of the guid references in the display list"); return; } } } else { MessageBox.Show("failure to delete"); } MessageBox.Show("successful deletion"); }
private void FillListBoxWithCurrentOSListDisplay(ListBox lb, bool viewDescrips) { List <string> guidList = BcdStore_API.GetBootManagerGUIDEntriesDisplayListAsList(); if (guidList == null) { MessageBox.Show("trouble getting guid list"); } lb.Items.Clear(); foreach (string guid in guidList) { string descrip = BcdStore_API.GetDescriptionForGuid(guid, ""); if (viewDescrips) { if (descrip == null) { descrip = guid; // if no description default to showing guid, this is how the actual boot loader does it also } } if (!viewDescrips) { lb.Items.Add(guid); } else { lb.Items.Add(descrip); } } }