【问题标题】:Detect bitlocker partition state using delphi使用delphi检测bitlocker分区状态
【发布时间】:2016-12-17 18:14:54
【问题描述】:

我之前用 bitlocker 加密了我的一个分区,它运行良好。 现在我如何检测这个分区是否打开? 我的意思是分区是否被锁定?

【问题讨论】:

  • 应该可以从注册表中读取值,位于 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\BDESVC

标签: delphi state partition bitlocker


【解决方案1】:

如果您想查找加密状态,可以使用 GetEncryptionMethod

GetEncryptionMethod

uint32 GetEncryptionMethod(
  [out] uint32 EncryptionMethod,
  [out] string SelfEncryptionDriveEncryptionMethod
);

如果 EncryptionMethod0,则该卷未加密,否则 已加密

【讨论】:

  • Angelica,我想知道加密驱动器是锁定还是解锁。不过还是谢谢你。
【解决方案2】:

由于我现在无法测试以下代码,您可以尝试一下:

program WmiTest;

{$APPTYPE CONSOLE}


uses
  SysUtils
  ,ActiveX
  ,ComObj
  ,Variants;


function GetWMIstring(wmiHost, root, wmiClass, wmiProperty: string): string;
var
  objWMIService : OLEVariant;
  colItems      : OLEVariant;
  colItem       : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;

  function GetWMIObject(const objectName: String): IDispatch;
  var
    chEaten: Integer;
    BindCtx: IBindCtx;//for access to a bind context
    Moniker: IMoniker;//Enables you to use a moniker object
  begin
    OleCheck(CreateBindCtx(0, bindCtx));
    OleCheck(MkParseDisplayName(BindCtx, StringToOleStr(objectName), chEaten, Moniker));//Converts a string into a moniker that identifies the object named by the string
    OleCheck(Moniker.BindToObject(BindCtx, nil, IDispatch, Result));//Binds to the specified object
  end;

begin
  objWMIService := GetWMIObject(Format('winmgmts:\\%s\%s',[wmiHost,root]));
  colItems      := objWMIService.ExecQuery(Format('SELECT * FROM %s',[wmiClass]),'WQL',0);
  oEnum         := IUnknown(colItems._NewEnum) as IEnumVariant;
  while oEnum.Next(1, colItem, iValue) = 0 do
  begin
     Result:=colItem.Properties_.Item(wmiProperty, 0);
  end;
end;

begin
 try
    CoInitialize(nil);
    try
      WriteLn(GetWMIstring('.', 'Root\CIMV2\Security\MicrosoftVolumeEncryption', 'Win32_EncryptableVolume','LockStatus'));
      Readln;
    finally
    CoUninitialize;
    end;
 except
    on E:Exception do
    Begin
        Writeln(E.Classname, ': ', E.Message);
        Readln;
    End;
  end;
end.

基于 RRUZ 在此处 https://stackoverflow.com/a/2762023/368364 的回答以及 Norman Bauer 在此处 https://www.normanbauer.com/2010/09/28/how-to-get-some-information-on-bitlocker-using-vbscript-and-wmi/ 提供的查询

【讨论】:

  • 我测试它。这不是一个简单的方法。如果我知道 vbscript,其中一个链接会很有帮助。
猜你喜欢
  • 2019-12-31
  • 1970-01-01
  • 2014-08-09
  • 1970-01-01
  • 2020-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多