pub fn CoInitializeEx(coinit: COINIT) -> HrResult<CoUninitializeGuard>
Available on crate feature
ole
only.Expand description
CoInitializeEx
function, which
initializes
the COM library. When succeeding, returns an informational error code.
In the original C implementation, you must call
CoUninitialize
as a cleanup operation.
Here, the cleanup is performed automatically, because CoInitializeEx
returns a CoUninitializeGuard
, which
automatically calls CoUninitialize
when the guard goes out of scope. You
must, however, keep the guard alive, otherwise the cleanup will be performed
right away.
ยงExamples
use winsafe::{self as w, prelude::*, co};
let _com_guard = w::CoInitializeEx( // keep guard alive
co::COINIT::APARTMENTTHREADED
| co::COINIT::DISABLE_OLE1DDE,
)?;
// program runs...
// CoUninitialize() automatically called