I have this method to test if I successfully get ROT:
void func()
{
IRunningObjectTable *rot;
qDebug() << GetRunningObjectTable(0, &rot);
}
Everything's fine from main thread but not in a separate one:
func(); // qDebug prints S_OK (0)
QFuture<void> future = QtConcurrent::run(func); // qDebug prints E_UNEXPECTED (0x8000FFFF)
Compiling with MinGW 5.3.0 32bits.
I don't get why would it be different from the main thread than an other.
Help would be appreciated.
Because your thread function didn't invoke CoInitialize or CoInitializeEx before invoking GetRunningObjectTable.
This would likely work from a thread
void func_in_thread()
{
CoInitializeEx(nullptr,COINIT_MULTITHREADED);
IRunningObjectTable *rot = nullptr;
qDebug() << GetRunningObjectTable(0, &rot);
CoUninitialize();
}
User contributions licensed under CC BY-SA 3.0