如何确定是否在没有管理员特权的情况下对驱动器进行了BitLocker加密? [英] How to tell if drive is BitLocker encrypted without admin privilege?

查看:91
本文介绍了如何确定是否在没有管理员特权的情况下对驱动器进行了BitLocker加密?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于我的目的,我所需要知道的是通过其DOS路径进行的驱动器的BitLocker加密状态.像这样:

For my purpose all I need to know is drive's BitLocker encryption status by its DOS path. Something like this:

enum DriveEncryptionStatus{
    Unprotected,
    Protected,
    Unknown
};

DriveEncryptionStatus = GetDriveBitlockerEncryptionStatus(L"C:\\");

我能够找到

要使用Win32_EncryptableVolume方法,请满足以下条件必须满足:您必须具有管理员权限.

To use the Win32_EncryptableVolume methods, the following conditions must be met: You must have administrator privileges.

有没有在不以管理员身份运行的情况下执行此操作的想法吗?

Any idea how to do this without running as an administrator?

推荐答案

Shell中的任何普通用户均可使用BitLocker状态.Windows使用 Windows属性来获取状态Win32 API中的系统,以检查未记录的外壳属性 System.Volume.BitLockerProtection .您的程序也将能够在不提升海拔的情况下检查此属性.

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.

如果此属性的值为1、3或5,则在驱动器上启用BitLocker.其他任何值均视为关闭.

If the value of this property is 1, 3, or 5, BitLocker is enabled on the drive. Any other value is considered off.

您可以使用Win32 API来检查此shell属性.出于礼貌,我从我移植了我的托管实现其他类似问题的答案.

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;
}

这篇关于如何确定是否在没有管理员特权的情况下对驱动器进行了BitLocker加密?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆