Skip to content

Commit

Permalink
Call CoInitializeEx() to initialize the COM library
Browse files Browse the repository at this point in the history
Resolves #772
  • Loading branch information
grulja committed Nov 28, 2024
1 parent c77f619 commit 0469f99
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lib/libwindisk/windisk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ WinDiskManagement::WinDiskManagement(QObject *parent, bool isHelper)
}

HRESULT res = S_OK;

HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr)) {
_com_error err(res);
logMessage(QtWarningMsg, QStringLiteral("Failed to initialize COM library. Error = %1").arg(err.ErrorMessage()));
return;
}

// This needs to be initialized before any RPC communication occurs
// Currently when used in WinDriveManager we are good.
res = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0);
Expand Down

0 comments on commit 0469f99

Please # to comment.