【问题标题】:Checking status of Bitlocker is return null检查 Bitlocker 的状态是否返回 null
【发布时间】:2019-12-31 04:32:46
【问题描述】:

我创建了代码块来检查 bitlocker 是否在机器中启用或未遵循此主题:Detect BitLocker programmatically from c# without admin 我几乎在机器上工作得很好,但是从现在开始有一个机器返回空值:

IShellProperty prop = ShellObject.FromParsingName(rootDrive).Properties.GetProperty("System.Volume.BitLockerProtection");
int? bitLockerProtectionStatus = (prop as ShellProperty<int?>).Value; // bitLockerProtectionStatus return null

这台机器已经安装了bitlocker。我已经检查了命令“manage-bde -status C:”并返回状态“完全加密”。

上面的主题只提到了如果这个属性的值为1、3或5,则在驱动器上启用了BitLocker。任何其他值都被视为关闭。 这个值如何返回 null,我在哪里可以检查机器中这个(“System.Volume.BitLockerProtection”)的值?

【问题讨论】:

    标签: c# windows-api-code-pack bitlocker


    【解决方案1】:

    我的检测bitlocker驱动的代码:

    if (!new DriveInfo(DriveName).IsReady)
    {
        Process p = Process.Start(new ProcessStartInfo()
        {
            FileName = "cmd.exe",
            Arguments = " /C " + DriveName,
            Verb = "runas",
            UseShellExecute = false,
            RedirectStandardOutput = true,
            RedirectStandardError = true
        });
        string error = p.StandardError.ReadToEnd();
        string console = p.StandardOutput.ReadToEnd();
        bool IsBitLockerDrive = (error + console).Contains("BitLocker");//pw protected drive
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 2020-04-15
      • 2012-10-17
      相关资源
      最近更新 更多