我之前用 bitlocker 加密了我的一个分区,它运行良好。现在我如何检测这个分区是否打开?我的意思是分区是否被锁定?
问问题
409 次
2 回答
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-使用 vbscript-and-wmi/ 的一些关于 bitlocker 的信息
于 2016-12-18T10:25:15.907 回答
1
如果要查找加密状态,则可以使用 GetEncryptionMethod
uint32 GetEncryptionMethod(
[out] uint32 EncryptionMethod,
[out] string SelfEncryptionDriveEncryptionMethod
);
如果EncryptionMethod为0 ,则该卷未加密,否则已加密。
于 2016-12-18T09:39:08.380 回答