public static List <string> GetLockedVolumes(out Exception ex) { List <string> lockedVolumes = null; ex = Util.HandleExceptions(delegate { ManagementObjectCollection encryptableVolumes = BitlockerUtil.GetEncryptableVolumes(); if (encryptableVolumes != null) { foreach (ManagementBaseObject managementBaseObject in encryptableVolumes) { ManagementObject managementObject = (ManagementObject)managementBaseObject; string item = managementObject.GetPropertyValue("DeviceId").ToString(); Exception ex2; bool flag = BitlockerLockUtil.IsVolumeLocked(managementObject, out ex2); Util.ThrowIfNotNull(ex2); if (flag) { if (lockedVolumes == null) { lockedVolumes = new List <string>(); } lockedVolumes.Add(item); } } } }); return(lockedVolumes); }
public static ManagementObject GetEncryptableVolume(string deviceId, out Exception ex) { ManagementObject encryptableVolume = null; ex = Util.HandleExceptions(delegate { ManagementObjectCollection encryptableVolumes = BitlockerUtil.GetEncryptableVolumes(); if (encryptableVolumes != null) { using (encryptableVolumes) { foreach (ManagementBaseObject managementBaseObject in encryptableVolumes) { ManagementObject managementObject = (ManagementObject)managementBaseObject; using (managementObject) { string text = managementObject.GetPropertyValue("DeviceId").ToString(); if (text.Equals(deviceId)) { encryptableVolume = managementObject; break; } } } } } }); return(encryptableVolume); }