0

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.

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.