Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <shlobj.h>
- #pragma comment(lib, "shell32.lib")
- #pragma comment(lib, "propsys.lib")
- #include <iostream>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string>
- #include <vector>
- #include <windows.h>
- using namespace std;
- wchar_t* convertCharArrayToLPCWSTR(const char* charArray)
- {
- wchar_t* wString = new wchar_t[4096];
- MultiByteToWideChar(CP_ACP, 0, charArray, -1, wString, 4096);
- return wString;
- }
- bool 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 true;
- }
- else
- {
- return false;
- }
- }
- }
- }
- if (drive)
- {
- drive->Release();
- }
- return false;
- }
- int main(void)
- {
- cout << "Is disk C: encrypted : " << getDriveEncryptionStatus(convertCharArrayToLPCWSTR("C:")) << endl;
- cout << "Is disk D: encrypted : " << getDriveEncryptionStatus(convertCharArrayToLPCWSTR("D:")) << endl;
- cout << "Is disk G: encrypted : " << getDriveEncryptionStatus(convertCharArrayToLPCWSTR("G:")) << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement