我之前使用bitlocker确认了我的一个partitios,它完美无缺。 现在我如何检测此分区是否打开? 我的意思是分区被锁定了吗?
答案 0 :(得分:1)
如果要查找加密状态,可以使用GetEncryptionMethod
uint32 GetEncryptionMethod(
[out] uint32 EncryptionMethod,
[out] string SelfEncryptionDriveEncryptionMethod
);
如果 EncryptionMethod 0 ,则该卷未加密加密。
答案 1 :(得分: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以及Norman Bauer在此提供的查询https://www.normanbauer.com/2010/09/28/how-to-get-some-information-on-bitlocker-using-vbscript-and-wmi/