I’m currently trying to use the example project Com App which is given with the Qt installation (Qt_folder\Examples\4.7\activeqt\comapp)

I’m using version 4.7.4 on Windows, Qt Creator 2.3.0 and MinGw compiler.

So the example project compiles and runs fine, but it seems the COM server informations are not registered into the registry because I’m not able to reach it from any scripts, and I also cannot find UID in the registry, meaning that the COM server is not registered.

I’m trying to find a solution from 3 days ago and I’m starting to be desperate. Any help is welcome.

p.s. Sorry for my english, it’s not my native language

有帮助吗?

解决方案

Not sure if Qt looks after this under the hood but are you sure that your thread is being initialized for COM by calling CoInitializeEx?

I've been using some COM and Qt at work and this is sometimes something is overlooked.

CoInitializeEx Function

Here is an example of using the function.

MyClass::MyClass()
{
    // Make this call before attempting to access COM.
    if( SUCCEEDED( CoInitializeEx( 0, COINIT_APARTMENTTHREADED ) ) )
    {
         // This single thread has been initialized for COM usage.
         // Alternatively you can use COINIT_MULTITHREADED instead
         // of COINIT_APARTMENTTHREADED if you require threaded
         // support.
    }
    else
    {
         // Failed, still must call uninitialize.
         CoUninitialize();
    }
}

MyClass::~MyClass()
{
    CoUninitialize();
}

其他提示

It seems the only way to make COM interface to work properly is to compile from VS using Qt VS add-in. It works for me, I used Visual Studio 2008. See this post : Building ActiveQt (COM) applications with MinGW

But anyway this does not fix the issue as it's necessary to have a Microsoft VS license to be able to compile Qt software using COM interface. (VS add-in is not compatible with VS express editions)

Thanks to all for your help.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top