The BitLocker status is available to any ordinary user in the shell. Windows obtains the status using the Windows Property System in the Win32 API to check the undocumented shell property System.Volume.BitLockerProtection
. Your program will also be able to check this property without elevation.
If the value of this property is 1, 3, or 5, BitLocker is enabled on the drive. Any other value is considered off.
You can use the Win32 API to check this shell property. As a courtesy, I have ported my managed implementation from my other answer to a similar question.
#include <shlobj.h>
#pragma comment(lib, "shell32.lib")
#pragma comment(lib, "propsys.lib")
DriveEncryptionStatus getDriveEncryptionStatus(LPCWSTR parsingName)
{
IShellItem2 *drive = NULL;
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
hr = SHCreateItemFromParsingName(parsingName, NULL, IID_PPV_ARGS(&drive));
if (SUCCEEDED(hr)) {
PROPERTYKEY pKey;
hr = PSGetPropertyKeyFromName(L"System.Volume.BitLockerProtection", &pKey);
if (SUCCEEDED(hr)) {
PROPVARIANT prop;
PropVariantInit(&prop);
hr = drive->GetProperty(pKey, &prop);
if (SUCCEEDED(hr)) {
int status = prop.intVal;
drive->Release();
if (status == 1 || status == 3 || status == 5)
return DriveEncryptionStatus::Protected;
else
return DriveEncryptionStatus::Unprotected;
}
}
}
if (drive)
drive->Release();
return DriveEncryptionStatus::Unknown;
}
int main()
{
DriveEncryptionStatus status = getDriveEncryptionStatus(L"C:");
return 0;
}