I enqrypted one of my partitios with bitlocker before and it works perfect. For now how can i detect if this partition is open or not? I mean the partition is locked or not?
Asked
Active
Viewed 520 times
2 Answers
1
If you want to find Encryption State than you can use GetEncryptionMethod
uint32 GetEncryptionMethod(
[out] uint32 EncryptionMethod,
[out] string SelfEncryptionDriveEncryptionMethod
);
If EncryptionMethod is 0 then The volume is not encrypted else encrypted.

Angelica
- 488
- 5
- 22
-
Angelica, i want to know that an Encryption drive is lock or unlock. but Thank you anyway. – M.MARAMI Dec 18 '16 at 10:42
1
As I can not test now the following code, you could give it a try:
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.
based on RRUZ's answer from here https://stackoverflow.com/a/2762023/368364 and on the query provided by Norman Bauer here https://www.normanbauer.com/2010/09/28/how-to-get-some-information-on-bitlocker-using-vbscript-and-wmi/
-
I test it. it is no a simple way. one of links be helpful if i know vbscript. – M.MARAMI Dec 18 '16 at 11:09