2016-12-17 65 views
0

我使用bitlocker之前使用了其中一个分区,它的工作原理非常完美。 现在我该如何检测这个分区是否打开? 我的意思是分区被锁定或没有?使用delphi检测bitlocker分区状态

+0

它应该有可能从注册表中读取值,在HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ services \ BDESVC – RBA

回答

1

如果你想找到加密状态比你可以使用GetEncryptionMethod

GetEncryptionMethod

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

如果EncryptionMethod是然后卷不是加密的其他加密

+0

当归,我想知道一个加密驱动器是锁定或解锁。但无论如何谢谢。 –

1

正如我无法测试,现在下面的代码,你可以试试看:

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和诺曼·鲍尔在这里提供的查询https://www.normanbauer.com/2010/09/28/how-to-get-some-information-on-bitlocker-using-vbscript-and-wmi/

+0

我测试它。这不是一个简单的方法。如果我知道vbscript,链接之一会有帮助。 –