Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to call Registeration-Free COM dll?
Forum Updated to NodeBB v4.3 + New Features

How to call Registeration-Free COM dll?

Scheduled Pinned Locked Moved Solved General and Desktop
36 Posts 4 Posters 6.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • hskoglundH hskoglund

    Hi forgot to mention: how did I find that GUID QUuid("{6E795DE9-872D-43CF-A831-496EF9D86C68}")? It's from line 68 in main.cpp in the Wrapperax example, it's one of the 3 classIDs listed (you can use any one of the 3).

    For your dll, you need to find the relevant CLSID, in the manifest file look for the comclass line.
    For example, the manifest file shown in that ancient QtBug suggestion shows:

    ...
    <comClass clsid="{6BF52A52-394A-11D3-B153-00C04F79FAA6}" 
    ...
    

    If you want to use that and open the Windows Media Player dll (wmp.dll) instead, change my demo code above to:

    // load a COM flavored DLL without using the registry (here we use wmp.dll)
        QLibrary regFreeLib("wmp.dll");
    
    // wire up the DllGetClassObject function so we can call it
        auto regFreeGetDllClassObject = reinterpret_cast<HRESULT (__stdcall *)(REFCLSID,REFIID,LPVOID*)> (regFreeLib.resolve("DllGetClassObject"));
        if (nullptr == regFreeGetDllClassObject)
            qFatal("wiring up DLLGetClassObject() failed");
    
    // try to open the Windows Media Player:
        CComPtr<IClassFactory> pClassFactory;
        HRESULT hr = regFreeGetDllClassObject(QUuid("{6BF52A52-394A-11D3-B153-00C04F79FAA6}"),IID_IClassFactory,(LPVOID*) &pClassFactory);
        if (FAILED(hr))
            qFatal("calling DLLGetClassObject() failed");
    

    To check that you managed to open the dll correctly, one way is to add a call generateDocumentation at the end, like this:

    ,,,
    
    // if we get this far we're in business, let Qt take it from here
        auto comObject = new QAxObject(pUnknown);
        if (nullptr == comObject)
            qFatal("QAxObject creation failed");
    
    // check that we have something live
        qDebug() << comObject->generateDocumentation();
    

    the output (if it works) should have some HTML code (save it to a HTML file to view it properly).

    Finally, you need to match the bitness of your dll (it it's 32-bits you need to compile a 32-bits Qt app and the other way around). Normally the COM infrastructure allows 32-bit/64-bit crossplaying by loading the .dll out-of-process, but since you're doing LoadLbrary() you are closer to the metal.

    Bruce.ZhangB Offline
    Bruce.ZhangB Offline
    Bruce.Zhang
    wrote on last edited by
    #11

    @hskoglund I works for wmp.dll, but don't know why failed on my dll at bellow line:

    if (nullptr == regFreeGetDllClassObject)
            qFatal("wiring up DLLGetClassObject() failed");
    

    And GetLastError code is 126, which is cannot find the DLL, maybe the DLL is invalid? but I can use it in my msvc project.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #12

      If you get an error 126: if you didn't specify a path to the .dll check that it's placed together with the .exe (or one directory level above if you're running from inside Qt Creator).
      To make sure add a qDebug on an explicit .load(), say like this:

      ...
          QLibrary regFreeLib("wmp.dll");
          qDebug() << "dll loaded ok: " << regFreeLib.load();
      ...
      

      Also make sure all the other .dlls that your .dll is dependent on are loaded ok (i.e. another reason for error 126).
      If you're stuck, fire up ProcessMonitor :-)

      Bruce.ZhangB 1 Reply Last reply
      0
      • hskoglundH hskoglund

        If you get an error 126: if you didn't specify a path to the .dll check that it's placed together with the .exe (or one directory level above if you're running from inside Qt Creator).
        To make sure add a qDebug on an explicit .load(), say like this:

        ...
            QLibrary regFreeLib("wmp.dll");
            qDebug() << "dll loaded ok: " << regFreeLib.load();
        ...
        

        Also make sure all the other .dlls that your .dll is dependent on are loaded ok (i.e. another reason for error 126).
        If you're stuck, fire up ProcessMonitor :-)

        Bruce.ZhangB Offline
        Bruce.ZhangB Offline
        Bruce.Zhang
        wrote on last edited by Bruce.Zhang
        #13

        @hskoglund Thanks for reminder, I copied all dlls and can load now, but failed at bellow:

        CComPtr<IClassFactory> pClassFactory;
            HRESULT hr = regFreeGetDllClassObject(QUuid("{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}"), IID_IClassFactory, (LPVOID*) &pClassFactory);
            if (FAILED(hr))
            {
                auto err = GetLastError();
                QString str = QString("GetLastError():%1").arg(err);
                qFatal("calling DLLGetClassObject() failed");
            }
        

        GetLastError() Error Number is 3.

        Part of my .idl file like this:

        [
            uuid(A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD),
            version(1.0),
        ]
        library DataTypesLibraryLib
        {
            importlib("stdole2.tlb");
        
            typedef
            [
                uuid(C15BA150-A8BA-4A10-8C5C-0D65F97A9840),
                version(1.0)
            ]
        
            enum EventTypes
            {
                EVENT_UNKNOWN = 0,
                EVENT_FROM_RECIPE = 10000,
                EVENT_START_HISTORICAL_JOB = 10001,
                EVENT_WEB_POSITION_AND_SPEED = 10005,
                EVENT_BLOB_OVERRUN = 10009,
                EVENT_CUT_SIGNAL = 10019,
                EVENT_START_JOB = 10023,
                EVENT_STOP_JOB = 10024,
                EVENT_START_INSPECTION = 10025,
                EVENT_STOP_INSPECTION = 10026,
                EVENT_WEB_EDGE = 10036,
                EVENT_PAUSE_INSPECTION = 10045,
                EVENT_RESTART_INSPECTION = 10046,
                EVENT_JOB_PASSED = 10049,
                EVENT_JOB_FAILED = 10050,
                EVENT_DOFF_PASSED = 10051,
                EVENT_DOFF_FAILED = 10052,
                EVENT_ROLL_PASSED = 10053,
                EVENT_ROLL_FAILED = 10054,
                EVENT_EXTERNAL_RUNNEXTJOB = 10055,
                EVENT_DENSITY_EVENT = 10079,
                EVENT_WET_CAMERA_STATUS = 10180,
                EVENT_WET_START_CALIBRATION = 10181,
                EVENT_WET_STOP_CALIBRATION = 10182
            } EventTypes;
        
            enum CommandTypes
            {
                COMMAND_UNINITIALIZED = -1,
                COMMAND_START_JOB = 1,
                COMMAND_STOP_JOB,
                COMMAND_LINEPROFILE_START,
                COMMAND_LINEPROFILE_STOP,
                COMMAND_SNAPIMAGE
            };
        
            [
                uuid(0405e972-093d-4f16-9b4f-f9071cc8f9b2)
            ]
            coclass EventData
            {
                [default] interface IEventData;
            };
        }
        
        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #14

          Once you're in the COM world, GetLastError() is less interesting.
          You need the qdebug dump the hr (HResult) that GetDllClassObjet returned. Preferable in hex, something like 0x80040154 will be shown...

          Bruce.ZhangB 1 Reply Last reply
          0
          • hskoglundH hskoglund

            Once you're in the COM world, GetLastError() is less interesting.
            You need the qdebug dump the hr (HResult) that GetDllClassObjet returned. Preferable in hex, something like 0x80040154 will be shown...

            Bruce.ZhangB Offline
            Bruce.ZhangB Offline
            Bruce.Zhang
            wrote on last edited by
            #15

            @hskoglund said in How to call Registeration-Free COM dll?:

            Once you're in the COM world, GetLastError() is less interesting.
            You need the qdebug dump the hr (HResult) that GetDllClassObjet returned. Preferable in hex, something like 0x80040154 will be shown...

            I've got the error code 0x80040111:In this specific case, the error code "80040111" translates to "CLASS_E_CLASSNOTAVAILABLE" Seems the specified class is not correct. I don't know why got this error, the GUID was wrong?

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #16

              Yeah you got bad luck and selected the wrong GUID :-( That one at the top is the library UUID, but we're only interested in coclass-flavored UUIDs (i.e. that is what DllGetClassObject wants).
              They're usually found at the end of an .idl file, in your case:

              ...
               [
                   uuid(0405e972-093d-4f16-9b4f-f9071cc8f9b2)
              // try this one ^
              ]
              coclass EventData
              {
                  [default] interface IEventData;
              };
              
              
              Bruce.ZhangB 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Yeah you got bad luck and selected the wrong GUID :-( That one at the top is the library UUID, but we're only interested in coclass-flavored UUIDs (i.e. that is what DllGetClassObject wants).
                They're usually found at the end of an .idl file, in your case:

                ...
                 [
                     uuid(0405e972-093d-4f16-9b4f-f9071cc8f9b2)
                // try this one ^
                ]
                coclass EventData
                {
                    [default] interface IEventData;
                };
                
                
                Bruce.ZhangB Offline
                Bruce.ZhangB Offline
                Bruce.Zhang
                wrote on last edited by Bruce.Zhang
                #17

                @hskoglund Finally, I can run it now, but with some error output.
                bellow is my code snippet:

                 LPVOID rev = nullptr;
                    CoInitialize(rev);// Add this line because there will be  another output  of missing the CoInitialize. 
                
                    // load a COM flavored DLL without using the registry (here we use the Wrapper example)
                    QLibrary regFreeLib("DataTypesLibrary.dll");
                    qDebug() << "dll loaded ok: " << regFreeLib.load();
                
                    // wire up the DllGetClassObject function so we can call it
                    auto regFreeGetDllClassObject = reinterpret_cast<HRESULT(__stdcall*)(REFCLSID, REFIID, LPVOID*)> (regFreeLib.resolve("DllGetClassObject"));
                
                    if (nullptr == regFreeGetDllClassObject)
                    {
                        auto err = GetLastError();
                        QString str = QString("GetLastError():%1").arg(err);
                        qFatal("wiring up DLLGetClassObject() failed");
                    }
                
                    // try to call it
                    CComPtr<IClassFactory> pClassFactory;
                    HRESULT hr = regFreeGetDllClassObject(QUuid("{0b4be3c3-f304-4f98-a870-e2933dee5b7e}"), IID_IClassFactory, (LPVOID*) &pClassFactory);
                
                    if (FAILED(hr))
                    {
                        auto err = GetLastError();
                        QString str = QString("DLLGetClassObject GetLastError():%1 HRESULT:%2").arg(err).arg(hr, 8,  16, QLatin1Char('0'));
                        qFatal(str.toStdString().c_str());
                    }
                
                    for (int i = 0; i < 1000000; i++)
                    {
                        // and then obtain the IUnknown ptr
                        CComPtr<IUnknown> pUnknown;
                        hr = pClassFactory->CreateInstance(nullptr, IID_IUnknown, (LPVOID*) &pUnknown);
                
                        if (FAILED(hr))
                            qFatal("createInstance() failed");
                
                        // if we get this far we're in business, let Qt take it from here
                        auto comObject = new QAxObject(pUnknown);
                        auto pEventData = reinterpret_cast<DataTypesLibraryLib::IEventData*>(comObject);
                        pEventData->SetCD(20.22);
                        qDebug() << "CD:" << pEventData->CD();
                        delete pEventData;
                
                    }
                
                    qDebug() << "This is the End";
                

                And bellow is the output when exec "pEventData->SetCD(20.22);" each loop.

                mincore\com\oleaut32\typelib\tlibapi.cpp(2279)\OLEAUT32.dll!00007FF8FE894743: (caller: 00007FF8FE87847B) ReturnHr(239969) tid(5a8c) 8002801D Library not registered.
                void __cdecl MetaObjectGenerator::readClassInfo(void): IDispatch 0x28bf7aa0040 does not provide interface information
                CD: 20.22
                

                BTW: I generated the .h & .cpp using "dumpcpp DataTypesLibrary.dll". And DataTypesLibraryLib::IEventData is from the .h file.

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #18

                  Hi, dumpcpp can be a useful tool but it does not support RegistrationFree COM dlls. Usually the .cpp code generated (in DataTypesLibrarylib.cpp) will, in the constructor, include a call to QAxWidget->setControl(), and that call relies on the registry to work :-(
                  And that's probably why you get that error "Library not registered".

                  Once you've started using a QAxObject, best is to avoid stunts like ... reinterpret_cast<DataTypesLibraryLib::IEventData*>(comObject); it will only come back to haunt you :-)

                  I see you're not using the UUID i suggested but another one?

                  Once you gotten a QAxObject up and running, start by checking it's validity by calling generateDocumentation: (i.e. from my code earlier in this topic):

                  / check that we have something live
                      qDebug() << comObject->generateDocumentation();
                  

                  If that works, then try using your comObject say like this:

                  comObject->setProperty("CD",20.22);
                  qDebug() << "CD:" << comObject->property("CD");
                  
                  Bruce.ZhangB 1 Reply Last reply
                  0
                  • hskoglundH hskoglund

                    Hi, dumpcpp can be a useful tool but it does not support RegistrationFree COM dlls. Usually the .cpp code generated (in DataTypesLibrarylib.cpp) will, in the constructor, include a call to QAxWidget->setControl(), and that call relies on the registry to work :-(
                    And that's probably why you get that error "Library not registered".

                    Once you've started using a QAxObject, best is to avoid stunts like ... reinterpret_cast<DataTypesLibraryLib::IEventData*>(comObject); it will only come back to haunt you :-)

                    I see you're not using the UUID i suggested but another one?

                    Once you gotten a QAxObject up and running, start by checking it's validity by calling generateDocumentation: (i.e. from my code earlier in this topic):

                    / check that we have something live
                        qDebug() << comObject->generateDocumentation();
                    

                    If that works, then try using your comObject say like this:

                    comObject->setProperty("CD",20.22);
                    qDebug() << "CD:" << comObject->property("CD");
                    
                    Bruce.ZhangB Offline
                    Bruce.ZhangB Offline
                    Bruce.Zhang
                    wrote on last edited by Bruce.Zhang
                    #19

                    @hskoglund Actually the last GUID is what I pasted. I tried the comObject->generateDocumentation();
                    The output also contains .... Library not registered.

                    
                    mincore\com\oleaut32\typelib\tlibapi.cpp(2279)\OLEAUT32.dll!00007FFCB00B4743: (caller: 00007FFCB009847B) ReturnHr(1) tid(3864) 8002801D Library not registered.
                    void __cdecl MetaObjectGenerator::readClassInfo(void): IDispatch 0x22af47e0000 does not provide interface information
                    mincore\com\oleaut32\typelib\tlibapi.cpp(2279)\OLEAUT32.dll!00007FFCB00B4743: (caller: 00007FFCB009847B) ReturnHr(2) tid(3864) 8002801D Library not registered.
                    mincore\com\oleaut32\typelib\tlibapi.cpp(2279)\OLEAUT32.dll!00007FFCB00B4743: (caller: 00007FFCB009847B) ReturnHr(3) tid(3864) 8002801D Library not registered.
                    "<h1 align=center> Reference</h1>\n<p>The  COM object is a QAxObject with the CLSID .</p>\n<h3>Interfaces</h3>\n<ul>\n</ul>\n<h3>Event Interfaces</h3>\n<ul>\n</ul>\n<h2>Public Slots:</h2>\n<ul>\n</ul>\n<h2>Signals:</h2>\n<ul>\n<li>void <a href=\"#exception\"><b>exception</b></a>(int code, QString source, QString disc, QString help);</li>\n<li>void <a href=\"#propertyChanged\"><b>propertyChanged</b></a>(QString name);</li>\n<li>void <a href=\"#signal\"><b>signal</b></a>(QString name, int argc, void* argv);</li>\n</ul>\n<h2>Properties:</h2>\n<ul>\n<li>QString <a href=\"#objectName\"><b>objectName</b></a>;</li>\n<li>QString <a href=\"#control\"><b>control</b></a>;</li>\n</ul>\n<hr><h2>Member Function Documentation</h2>\n<h3><a name=exception></a>void exception (int code, QString source, QString disc, QString help)<tt> [signal]</tt></h3>\n<p>Connect a slot to this signal:<pre>\n\tQObject::connect(object, SIGNAL(exception(int, QString, QString, QString)), receiver, SLOT(someSlot(int, QString, QString, QString)));</pre>\n\n<h3><a name=propertyChanged></a>void propertyChanged (QString name)<tt> [signal]</tt></h3>\n<p>Connect a slot to this signal:<pre>\n\tQObject::connect(object, SIGNAL(propertyChanged(QString)), receiver, SLOT(someSlot(QString)));</pre>\n\n<h3><a name=signal></a>void signal (QString name, int argc, void* argv)<tt> [signal]</tt></h3>\n<p>Connect a slot to this signal:<pre>\n\tQObject::connect(object, SIGNAL(signal(QString, int, void*)), receiver, SLOT(someSlot(QString, int, void*)));</pre>\n\n<hr><h2>Property Documentation</h2>\n<h3><a name=objectName></a>QString objectName</h3>\n<p>\n<p>Read this property's value using QObject::property:<pre>\n\tQString val = object->property(\"objectName\").toString();\n</pre>\nSet this property' value using QObject::setProperty:<pre>\n\tQString newValue = ...\n\tobject->setProperty(\"objectName\", newValue);\n</pre>\nOr using the <a href=\"#setObjectName\">setObjectName</a> slot.\n\n<h3><a name=control></a>QString control</h3>\n<p>\n<p>Read this property's value using QObject::property:<pre>\n\tQString val = object->property(\"control\").toString();\n</pre>\nSet this property' value using QObject::setProperty:<pre>\n\tQString newValue = ...\n\tobject->setProperty(\"control\", newValue);\n</pre>\nOr using the <a href=\"#setControl\">setControl</a> slot.\n\n"
                    

                    The messages outputs when execute "comObject->generateDocumentation();"

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by
                      #20

                      Hmm if you're testing on a pretty old Windows 10, you might have been bitten by this bug:
                      https://bugreports.qt.io/browse/QTBUG-63789

                      Also I dug up some old code for debugging COM, try these lines:

                      ...
                      // try to call it
                          CComPtr<IClassFactory> pClassFactory;
                          HRESULT hr = regFreeGetDllClassObject(QUuid("{0405e972-093d-4f16-9b4f-f9071cc8f9b2}"),IID_IClassFactory,(LPVOID*) &pClassFactory);
                          if (FAILED(hr))
                              qFatal("calling DLLGetClassObject() failed");
                      
                      // and then obtain the IUnknown ptr
                          CComPtr<IUnknown> pUnknown;
                          hr = pClassFactory->CreateInstance(nullptr,IID_IUnknown,(LPVOID*) &pUnknown);
                          if (FAILED(hr))
                              qFatal("createInstance() failed");
                      
                      // if we get this far we're in business, let Qt take it from here
                          auto comObject = new QAxObject(pUnknown);
                          if (nullptr == comObject)
                              qFatal("QAxObject creation failed");
                      
                      // *** some debugging code
                      // try to obtain a IDispatch ptr
                          CComPtr<IDispatch> pDispatch;
                          comObject->queryInterface(QUuid(IID_IDispatch),(void**) &pDispatch);
                          if (nullptr == pDispatch)
                              qFatal("Error: an IDispatch interface was not found.");
                      
                      // get the ITypeInfo ptr
                          UINT uTypeInfo;
                          hr = pDispatch->GetTypeInfoCount(&uTypeInfo);
                          if (FAILED(hr) || (uTypeInfo < 1))
                              qFatal("Sorry, could not locate any type information");
                          if (1 != uTypeInfo)
                              qFatal("Expected GetTypeInfoCount() to return 1 but alas");
                      
                          CComPtr<ITypeInfo> pTypeInfo;
                          if FAILED(pDispatch->GetTypeInfo(0,LOCALE_SYSTEM_DEFAULT,&pTypeInfo))
                              qFatal("Error: GetTypeInfo() failed");
                      
                      // ok have ITypeInfo, use it to get the ITypeLib
                          CComPtr<ITypeLib> pTypeLib;
                          UINT uTypeInfoIndex;
                          if FAILED(pTypeInfo->GetContainingTypeLib(&pTypeLib,&uTypeInfoIndex))
                              qFatal("Error: GetContainingTypeLib() failed");
                      
                      // if you get this far you comObject is most likely ok (never mind generateDocumentation) so try your dll
                          comObject->setProperty("CD",20.22);
                          qDebug() << "CD:" << comObject->property("CD");
                      
                      Bruce.ZhangB 1 Reply Last reply
                      0
                      • hskoglundH hskoglund

                        Hmm if you're testing on a pretty old Windows 10, you might have been bitten by this bug:
                        https://bugreports.qt.io/browse/QTBUG-63789

                        Also I dug up some old code for debugging COM, try these lines:

                        ...
                        // try to call it
                            CComPtr<IClassFactory> pClassFactory;
                            HRESULT hr = regFreeGetDllClassObject(QUuid("{0405e972-093d-4f16-9b4f-f9071cc8f9b2}"),IID_IClassFactory,(LPVOID*) &pClassFactory);
                            if (FAILED(hr))
                                qFatal("calling DLLGetClassObject() failed");
                        
                        // and then obtain the IUnknown ptr
                            CComPtr<IUnknown> pUnknown;
                            hr = pClassFactory->CreateInstance(nullptr,IID_IUnknown,(LPVOID*) &pUnknown);
                            if (FAILED(hr))
                                qFatal("createInstance() failed");
                        
                        // if we get this far we're in business, let Qt take it from here
                            auto comObject = new QAxObject(pUnknown);
                            if (nullptr == comObject)
                                qFatal("QAxObject creation failed");
                        
                        // *** some debugging code
                        // try to obtain a IDispatch ptr
                            CComPtr<IDispatch> pDispatch;
                            comObject->queryInterface(QUuid(IID_IDispatch),(void**) &pDispatch);
                            if (nullptr == pDispatch)
                                qFatal("Error: an IDispatch interface was not found.");
                        
                        // get the ITypeInfo ptr
                            UINT uTypeInfo;
                            hr = pDispatch->GetTypeInfoCount(&uTypeInfo);
                            if (FAILED(hr) || (uTypeInfo < 1))
                                qFatal("Sorry, could not locate any type information");
                            if (1 != uTypeInfo)
                                qFatal("Expected GetTypeInfoCount() to return 1 but alas");
                        
                            CComPtr<ITypeInfo> pTypeInfo;
                            if FAILED(pDispatch->GetTypeInfo(0,LOCALE_SYSTEM_DEFAULT,&pTypeInfo))
                                qFatal("Error: GetTypeInfo() failed");
                        
                        // ok have ITypeInfo, use it to get the ITypeLib
                            CComPtr<ITypeLib> pTypeLib;
                            UINT uTypeInfoIndex;
                            if FAILED(pTypeInfo->GetContainingTypeLib(&pTypeLib,&uTypeInfoIndex))
                                qFatal("Error: GetContainingTypeLib() failed");
                        
                        // if you get this far you comObject is most likely ok (never mind generateDocumentation) so try your dll
                            comObject->setProperty("CD",20.22);
                            qDebug() << "CD:" << comObject->property("CD");
                        
                        Bruce.ZhangB Offline
                        Bruce.ZhangB Offline
                        Bruce.Zhang
                        wrote on last edited by Bruce.Zhang
                        #21

                        @hskoglund Hi, I test previous debug code, now failed at

                        hr = pDispatch->GetTypeInfo(0, LOCALE_SYSTEM_DEFAULT, &pTypeInfo);
                        
                        if FAILED(hr)
                               qFatal(QString("Error: GetTypeInfo() failed: %1").arg(hr, 8,  16, QLatin1Char('0')).toStdString().c_str());
                        

                        and the hr=0x8002801d

                        1 Reply Last reply
                        0
                        • hskoglundH Offline
                          hskoglundH Offline
                          hskoglund
                          wrote on last edited by hskoglund
                          #22

                          0x8002801d (TYPE_E_LIBNOTREGISTERED) occurs I think because it's trying to read class information from the registry (which is a no-no since we're doing registration-free COM).

                          It could be because the comObject you created is not the top object or that it is dependent on some other COM class to function (maybe test with some other coclass UUIDs listed in your .IDL file, i.e. look for this pattern [
                          uuid(xxxx-xxxx-xx)
                          ]
                          coclass yyyy)

                          It can also be a language/implementation reason, for example if your dll is written in C#, the same version of .NET 8 or .NET Framework needs to be installed on both the dev. PC and the target PC.

                          To test your .dll from C#, try calling stuff in your COM .dll from a test program using the same type of calling that QAxObject does, in C# you do this via the InvokeMember method (example here )

                          Finally, to debug this, download Process Monitor set a filter to exclude everything except the process name of your .exe test app. Look for registry read accesses to HKEY_CLASSES_ROOT :-)

                          Edit: I looked if you could instead use the classes that dumpcpp gives you (from doing a "dumpcpp DataTypesLibrary.dll") but alas they are just inheriting from QAxObject so the same error 0x8002801d will probably occur with them as well.

                          Bruce.ZhangB 1 Reply Last reply
                          0
                          • hskoglundH hskoglund

                            0x8002801d (TYPE_E_LIBNOTREGISTERED) occurs I think because it's trying to read class information from the registry (which is a no-no since we're doing registration-free COM).

                            It could be because the comObject you created is not the top object or that it is dependent on some other COM class to function (maybe test with some other coclass UUIDs listed in your .IDL file, i.e. look for this pattern [
                            uuid(xxxx-xxxx-xx)
                            ]
                            coclass yyyy)

                            It can also be a language/implementation reason, for example if your dll is written in C#, the same version of .NET 8 or .NET Framework needs to be installed on both the dev. PC and the target PC.

                            To test your .dll from C#, try calling stuff in your COM .dll from a test program using the same type of calling that QAxObject does, in C# you do this via the InvokeMember method (example here )

                            Finally, to debug this, download Process Monitor set a filter to exclude everything except the process name of your .exe test app. Look for registry read accesses to HKEY_CLASSES_ROOT :-)

                            Edit: I looked if you could instead use the classes that dumpcpp gives you (from doing a "dumpcpp DataTypesLibrary.dll") but alas they are just inheriting from QAxObject so the same error 0x8002801d will probably occur with them as well.

                            Bruce.ZhangB Offline
                            Bruce.ZhangB Offline
                            Bruce.Zhang
                            wrote on last edited by Bruce.Zhang
                            #23

                            @hskoglund My COM dll was wrote in c++.
                            I tried different UUID with no luck. And also the process monitor shows that the app was not access this registry.

                            the idl file as follows:

                            
                            import "oaidl.idl";
                            import "ocidl.idl";
                            
                             [
                                object,
                                uuid(d5c2a0e4-6b92-4278-ba56-479475ccfc42),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IEventData : IDispatch
                            {
                                [propget, helpstring("property Key")] HRESULT Key([out, retval]long long *pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long long val);
                                [propget, helpstring("property CD")] HRESULT CD([out, retval]double *pVal);
                                [propput, helpstring("property CD")] HRESULT CD([in]double val);
                                [propget, helpstring("property CameraCD")] HRESULT CameraCD([out, retval]double *pVal);
                                [id(2)] HRESULT Clone([out] IDispatch **pVal);
                            };
                            
                            [
                                object,
                                uuid(7e04492a-7143-4add-9ed3-a03bd023d63f),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IFlawData : IDispatch
                            {
                                [propget, helpstring("property Key")] HRESULT Key([out, retval]long long *pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long long val);
                                [propget, helpstring("property Deleted")] HRESULT Deleted([out, retval]VARIANT_BOOL *pVal);
                                [propput, helpstring("property Deleted")] HRESULT Deleted([in]VARIANT_BOOL val);
                                [id(1)] HRESULT Deserialize(unsigned char *pBytes);
                            };
                            
                            [
                                object,
                                uuid(a4df6d7e-28e5-4e9f-8eab-10b2c38a636c),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IImageData : IDispatch
                            {
                                [propget, helpstring("property Key")] HRESULT Key([out, retval]long long *pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long long val);
                                [propget, helpstring("property JobKey")] HRESULT JobKey([out, retval]long *pVal);
                                [propput, helpstring("property JobKey")] HRESULT JobKey([in] long val);
                                [propget, helpstring("property ImageObject")] HRESULT ImageObject([out, retval] VARIANT* pVal);
                                [propput, helpstring("property ImageObject")] HRESULT ImageObject([in] VARIANT val);
                                [propget, helpstring("property Deleted")] HRESULT Deleted([out, retval]VARIANT_BOOL *pVal);
                                [propput, helpstring("property Deleted")] HRESULT Deleted([in]VARIANT_BOOL val);
                                [id(1)] HRESULT Deserialize(unsigned char *pBytes);
                            };
                            
                            [
                                object,
                                uuid(631d7379-8a6c-4941-8ed1-8ad9b34bf558),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface ILineHardwareData : IDispatch
                            {
                                // LineHardware
                                [propget, helpstring("property IP")] HRESULT IP([out, retval]BSTR *pVal);
                                [propput, helpstring("property IP")] HRESULT IP([in]BSTR val);
                                [propget, helpstring("property Port")] HRESULT Port([out, retval]long *pVal);
                                [propput, helpstring("property Port")] HRESULT Port([in] long val);
                                [propget, helpstring("property StopPixel")] HRESULT StopPixel([out, retval]long *pVal);
                                [propput, helpstring("property StopPixel")] HRESULT StopPixel([in] long val);
                            };
                            
                            [
                                object,
                                uuid(512F49E3-6FFE-49FF-9E84-1DAC0650428A),
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IJobData : IDispatch
                            {
                                // TODO! these deserve known dispids
                                [propget, helpstring("property Key")] HRESULT Key([out, retval] long* pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long val);
                                [propget, helpstring("property OperatorName")] HRESULT OperatorName([out, retval] BSTR* pVal);
                                [propput, helpstring("property OperatorName")] HRESULT OperatorName([in] BSTR val);
                                [propget, helpstring("property CompanyName")] HRESULT CompanyName([out, retval] BSTR* pVal);
                                [propput, helpstring("property CompanyName")] HRESULT CompanyName([in] BSTR val);
                                [propget, helpstring("property InspectionType")] HRESULT InspectionType([out, retval] BSTR* pVal);
                                [propput, helpstring("property InspectionType")] HRESULT InspectionType([in] BSTR val);
                                [propget, helpstring("property MaterialType")] HRESULT MaterialType([out, retval] BSTR* pVal);
                                [propput, helpstring("property MaterialType")] HRESULT MaterialType([in] BSTR val);
                                [propget, helpstring("property OrderNumber")] HRESULT OrderNumber([out, retval] BSTR* pVal);
                                [propput, helpstring("property OrderNumber")] HRESULT OrderNumber([in] BSTR val);
                                [propget, helpstring("property JobID")] HRESULT JobID([out, retval] BSTR* pVal);
                                [propput, helpstring("property JobID")] HRESULT JobID([in] BSTR val);
                                [propget, helpstring("property StartDoffNumber")] HRESULT StartDoffNumber([out, retval] long* pVal);
                                [propput, helpstring("property StartDoffNumber")] HRESULT StartDoffNumber([in] long val);
                                [propget, helpstring("property StartDateTime")] HRESULT StartDateTime([out, retval]DATE *pVal);
                                [propput, helpstring("property StartDateTime")] HRESULT StartDateTime([in]DATE val);
                                [propget, helpstring("property EndDateTime")] HRESULT EndDateTime([out, retval]DATE* pVal);
                                [propput, helpstring("property EndDateTime")] HRESULT EndDateTime([in]DATE val);
                                [propget, helpstring("property LeftEdge")] HRESULT LeftEdge([out, retval]double* pVal);
                                [propput, helpstring("property LeftEdge")] HRESULT LeftEdge([in]double val);
                                [propget, helpstring("property RightEdge")] HRESULT RightEdge([out, retval]double* pVal);
                                [propput, helpstring("property RightEdge")] HRESULT RightEdge([in]double val);
                                [propget, helpstring("property JobLength")] HRESULT JobLength([out, retval]double* pVal);
                                [propput, helpstring("property JobLength")] HRESULT JobLength([in]double val);
                                [propget, helpstring("property Comment")] HRESULT Comment([out, retval] BSTR* pVal);
                                [propput, helpstring("property Comment")] HRESULT Comment([in] BSTR val);
                                [propget, helpstring("property Product")] HRESULT Product([out, retval] BSTR* pVal);
                                [propput, helpstring("property Product")] HRESULT Product([in] BSTR val);
                                [propget, helpstring("property Recipe")] HRESULT Recipe([out, retval] BSTR* pVal);
                                [propput, helpstring("property Recipe")] HRESULT Recipe([in] BSTR val);
                                [propget, helpstring("property LineHardware")] HRESULT LineHardware([out, retval] BSTR* pVal);
                                [propput, helpstring("property LineHardware")] HRESULT LineHardware([in] BSTR val);
                                [propget, helpstring("property Lanes")] HRESULT Lanes([out, retval] BSTR* pVal);
                                [propput, helpstring("property Lanes")] HRESULT Lanes([in] BSTR val);
                            };
                            
                            [
                                object,
                                uuid(8691d19e-004d-461e-9a15-a0b6c11e65b7),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IJobQueueData : IDispatch
                            {
                                // TODO! these deserve known dispids
                                [propget, helpstring("property Key")] HRESULT Key([out, retval] long* pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long val);
                                [propget, helpstring("property OperatorName")] HRESULT OperatorName([out, retval] BSTR* pVal);
                                [propput, helpstring("property OperatorName")] HRESULT OperatorName([in] BSTR val);
                                [propget, helpstring("property CompanyName")] HRESULT CompanyName([out, retval] BSTR* pVal);
                                [propput, helpstring("property CompanyName")] HRESULT CompanyName([in] BSTR val);
                                [propget, helpstring("property InspectionType")] HRESULT InspectionType([out, retval] BSTR* pVal);
                                [propput, helpstring("property InspectionType")] HRESULT InspectionType([in] BSTR val);
                                [propget, helpstring("property MaterialType")] HRESULT MaterialType([out, retval] BSTR* pVal);
                                [propput, helpstring("property MaterialType")] HRESULT MaterialType([in] BSTR val);
                                [propget, helpstring("property OrderNumber")] HRESULT OrderNumber([out, retval] BSTR* pVal);
                                [propput, helpstring("property OrderNumber")] HRESULT OrderNumber([in] BSTR val);
                                [propget, helpstring("property JobID")] HRESULT JobID([out, retval] BSTR* pVal);
                                [propput, helpstring("property JobID")] HRESULT JobID([in] BSTR val);
                                [propget, helpstring("property StartDoffNumber")] HRESULT StartDoffNumber([out, retval] long* pVal);
                                [propput, helpstring("property StartDoffNumber")] HRESULT StartDoffNumber([in] long val);
                                [propget, helpstring("property Comment")] HRESULT Comment([out, retval] BSTR* pVal);
                                [propput, helpstring("property Comment")] HRESULT Comment([in] BSTR val);
                                [propget, helpstring("property Iterations")] HRESULT Iterations([out, retval] long* pVal);
                                [propput, helpstring("property Iterations")] HRESULT Iterations([in] long val);
                                [propget, helpstring("property JobOrderNumber")] HRESULT JobOrderNumber([out, retval] long* pVal);
                                [propput, helpstring("property JobOrderNumber")] HRESULT JobOrderNumber([in] long val);
                                [propget, helpstring("property AutoStartDoffNumber")] HRESULT AutoStartDoffNumber([out, retval] BOOL* pVal);
                                [propput, helpstring("property AutoStartDoffNumber")] HRESULT AutoStartDoffNumber([in] BOOL val);
                                [propget, helpstring("property ProductKey")] HRESULT ProductKey([out, retval] LONG* pVal);
                                [propput, helpstring("property ProductKey")] HRESULT ProductKey([in] LONG val);
                                [propget, helpstring("property LaneSetupKey")] HRESULT LaneSetupKey([out, retval] LONG* pVal);
                                [propput, helpstring("property LaneSetupKey")] HRESULT LaneSetupKey([in] LONG val);
                            };
                            
                            [
                                object,
                                uuid(EC7181F6-D03B-4DA5-802C-1B83D562DC3E),
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IProductData : IDispatch
                            {
                                // TODO! these deserve known dispids
                                [propget, helpstring("property Key")] HRESULT Key([out, retval] long* pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long val);
                                [propget, helpstring("property Name")] HRESULT Name([out, retval] BSTR* pVal);
                                [propput, helpstring("property Name")] HRESULT Name([in] BSTR val);
                                [propget, helpstring("property RecipePath")] HRESULT RecipePath([out, retval] BSTR* pVal);
                                [propput, helpstring("property RecipePath")] HRESULT RecipePath([in] BSTR val);
                                [propget, helpstring("property PluginConfigs")] HRESULT PluginConfigs([out, retval] BSTR* pVal);
                                [propput, helpstring("property PluginConfigs")] HRESULT PluginConfigs([in] BSTR val);
                            };
                            
                            [
                            	object,
                            	uuid(88788dff-32ff-4c94-ac7c-3c0723444aeb),
                            	dual,
                            	nonextensible,
                            	pointer_default(unique)
                            ]
                            interface ICommandData : IDispatch
                            {
                                [propput, helpstring("property Command")] HRESULT Command([in] long val);
                                [propget, helpstring("property Value")] HRESULT Value([out, retval]VARIANT *pVal);
                                [propput, helpstring("property Value")] HRESULT Value([in] VARIANT val);
                                [propget, helpstring("property Value2")] HRESULT Value2([out, retval]VARIANT *pVal);
                                [propput, helpstring("property Value2")] HRESULT Value2([in] VARIANT val);
                                [propget, helpstring("property Value3")] HRESULT Value3([out, retval]VARIANT *pVal);
                                [propput, helpstring("property Value3")] HRESULT Value3([in] VARIANT val);
                                [propget, helpstring("property Value4")] HRESULT Value4([out, retval]VARIANT *pVal);
                                [propput, helpstring("property Value4")] HRESULT Value4([in] VARIANT val);
                                [propget, helpstring("property Value5")] HRESULT Value5([out, retval]VARIANT* pVal);
                                [propput, helpstring("property Value5")] HRESULT Value5([in] VARIANT val);
                                // Methods
                                HRESULT SerializeClassToString([out]BSTR *pSerializedString);
                            };
                            [
                                object,
                                uuid(3909d320-59ef-4f64-a795-0188c06bf87e),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface ILaneData : IDispatch
                            {
                                [propget, helpstring("property Description")] HRESULT Description([out, retval] BSTR* pVal);
                                [propput, helpstring("property Description")] HRESULT Description([in] BSTR val);
                                [propget, helpstring("property Width")] HRESULT Width([out, retval]double *pVal);
                                [propput, helpstring("property Width")] HRESULT Width([in]double val);
                                [propget, helpstring("property Enabled")] HRESULT Enabled([out, retval] VARIANT_BOOL* pVal);
                                [propput, helpstring("property Enabled")] HRESULT Enabled([in] VARIANT_BOOL val);
                                [propget, helpstring("property LeftMargin")] HRESULT LeftMargin([out, retval]double *pVal);
                                [propput, helpstring("property LeftMargin")] HRESULT LeftMargin([in]double val);
                                [propget, helpstring("property RightMargin")] HRESULT RightMargin([out, retval]double *pVal);
                                [propput, helpstring("property RightMargin")] HRESULT RightMargin([in]double val);
                            };
                            [
                            	object,
                            	uuid(1c64d549-f760-43ba-8ae1-dbddf1720a54),
                            	dual,
                            	nonextensible,
                            	pointer_default(unique)
                            ]
                            interface ILaneSetupData : IDispatch
                            {
                                // NOTE: Don't move Lanes from the top spot unless you change const int "LANE_OBJECT_ARRAY_INDEX = 0;"
                                // in c:\development\opsisnextgen\BuildCommonFiles\Wintriss\DatabaseLibrary\SQLEngine.cs
                                [propget, helpstring("property Lanes")] HRESULT Lanes([out, retval] SAFEARRAY(VARIANT)* pVal);
                                [propput, helpstring("property Lanes")] HRESULT Lanes([in] SAFEARRAY(VARIANT) val);
                                [propget, helpstring("property Key")] HRESULT Key([out, retval]long *pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long val);
                                [propget, helpstring("property Name")] HRESULT Name([out, retval] BSTR *pVal);
                                [propput, helpstring("property Name")] HRESULT Name([in] BSTR val);
                                [propget, helpstring("property EdgeDetectionType")] HRESULT EdgeDetectionType([out, retval]long *pVal);
                                [propput, helpstring("property EdgeDetectionType")] HRESULT EdgeDetectionType([in] long val);
                                [propget, helpstring("property UsePreSlit")] HRESULT UsePreSlit([out, retval] VARIANT_BOOL* pVal);
                                [propput, helpstring("property UsePreSlit")] HRESULT UsePreSlit([in] VARIANT_BOOL val);
                                [propget, helpstring("property CDReference")] HRESULT CDReference([out, retval]long *pVal);
                                [propput, helpstring("property CDReference")] HRESULT CDReference([in] long val);
                                [propget, helpstring("property NumberOfLanes")] HRESULT NumberOfLanes([out, retval]long *pVal);
                                [propget, helpstring("property UseLeftOffset")] HRESULT UseLeftOffset([out, retval] VARIANT_BOOL* pVal);
                                [propput, helpstring("property UseLeftOffset")] HRESULT UseLeftOffset([in] VARIANT_BOOL val);
                                [propget, helpstring("property LeftWebMargin")] HRESULT LeftWebMargin([out, retval]double *pVal);
                                [propput, helpstring("property LeftWebMargin")] HRESULT LeftWebMargin([in]double val);
                                [propget, helpstring("property RightWebMargin")] HRESULT RightWebMargin([out, retval]double *pVal);
                                [propput, helpstring("property RightWebMargin")] HRESULT RightWebMargin([in]double val);
                                [propget, helpstring("property FirstKnifePosition")] HRESULT FirstKnifePosition([out, retval]double *pVal);
                                [propput, helpstring("property FirstKnifePosition")] HRESULT FirstKnifePosition([in]double val);
                            };
                            [
                                object,
                                uuid(C29B84A8-422B-4460-A608-21B7EE023D0A),
                                dual,
                                nonextensible,
                                pointer_default(unique)
                            ]
                            interface IJobLane : IDispatch
                            {
                                [propget, helpstring("property Key")] HRESULT Key([out, retval] long *pVal);
                                [propput, helpstring("property Key")] HRESULT Key([in] long val);
                                [propget, helpstring("property JobKey")] HRESULT JobKey([out, retval] long *pVal);
                                [propput, helpstring("property JobKey")] HRESULT JobKey([in] long val);
                                [propget, helpstring("property LaneNumber")] HRESULT LaneNumber([out, retval] long *pVal);
                                [propput, helpstring("property LaneNumber")] HRESULT LaneNumber([in] long val);
                                [propget, helpstring("property StartCD")] HRESULT StartCD([out, retval]double *pVal);
                                [propput, helpstring("property StartCD")] HRESULT StartCD([in]double val);
                                [propget, helpstring("property StopCD")] HRESULT StopCD([out, retval]double *pVal);
                                [propput, helpstring("property StopCD")] HRESULT StopCD([in]double val);
                                [propget, helpstring("property Enabled")] HRESULT Enabled([out, retval] VARIANT_BOOL *pVal);
                                [propput, helpstring("property Enabled")] HRESULT Enabled([in] VARIANT_BOOL val);
                            };
                            
                            [
                            	object,
                            	uuid(c50d4146-39e2-406f-81d8-f4961761b61f),
                            	dual,
                            	nonextensible,
                            	pointer_default(unique)
                            ]
                            interface IErrorMessageData : IDispatch
                            {
                                [propget, helpstring("property Message")] HRESULT Message([out, retval]BSTR *pVal);
                                [propput, helpstring("property Message")] HRESULT Message([in]BSTR val);
                                [propget, helpstring("property IPAddress")] HRESULT IPAddress([out, retval]BSTR *pVal);
                                [propput, helpstring("property IPAddress")] HRESULT IPAddress([in]BSTR val);
                                [propget, helpstring("property OriginalData")] HRESULT OriginalData([out, retval]BSTR *pVal);
                                [propput, helpstring("property OriginalData")] HRESULT OriginalData([in]BSTR val);
                                [propget, helpstring("property Port")] HRESULT Port([out, retval]long *pVal);
                                [propput, helpstring("property Port")] HRESULT Port([in] long val);
                                [propget, helpstring("property DateTime")] HRESULT DateTime([out, retval]DATE *pVal);
                                [propput, helpstring("property DateTime")] HRESULT DateTime([in]DATE val);
                                [id(1)] HRESULT Deserialize(unsigned char *pBytes);
                            };
                            
                            [
                                uuid(A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD),
                                version(1.0),
                            ]
                            library DataTypesLibraryLib
                            {
                                importlib("stdole2.tlb");
                            
                                typedef
                                [
                                    uuid(C15BA150-A8BA-4A10-8C5C-0D65F97A9840),
                                    version(1.0)
                                ]
                            
                                enum EventTypes
                                {
                                    EVENT_UNKNOWN = 0,
                                    EVENT_FROM_RECIPE = 10000,
                                    EVENT_START_HISTORICAL_JOB = 10001,
                                    EVENT_WEB_POSITION_AND_SPEED = 10005,
                                    EVENT_BLOB_OVERRUN = 10009,
                                    EVENT_CUT_SIGNAL = 10019,
                                    EVENT_START_JOB = 10023,
                                    EVENT_STOP_JOB = 10024,
                                    EVENT_START_INSPECTION = 10025,
                                    EVENT_STOP_INSPECTION = 10026,
                                    EVENT_WEB_EDGE = 10036,
                                    EVENT_PAUSE_INSPECTION = 10045,
                                    EVENT_RESTART_INSPECTION = 10046,
                                    EVENT_JOB_PASSED = 10049,
                                    EVENT_JOB_FAILED = 10050,
                                    EVENT_DOFF_PASSED = 10051,
                                    EVENT_DOFF_FAILED = 10052,
                                    EVENT_ROLL_PASSED = 10053,
                                    EVENT_ROLL_FAILED = 10054,
                                    EVENT_EXTERNAL_RUNNEXTJOB = 10055,
                                    EVENT_DENSITY_EVENT = 10079,
                                    EVENT_WET_CAMERA_STATUS = 10180,
                                    EVENT_WET_START_CALIBRATION = 10181,
                                    EVENT_WET_STOP_CALIBRATION = 10182
                                } EventTypes;
                            
                                enum CommandTypes
                                {
                                    COMMAND_UNINITIALIZED = -1,
                                    COMMAND_START_JOB = 1,
                                    COMMAND_STOP_JOB,
                                    COMMAND_LINEPROFILE_START,
                                    COMMAND_LINEPROFILE_STOP,
                                    COMMAND_SNAPIMAGE
                                };
                            
                                [
                                    uuid(0405e972-093d-4f16-9b4f-f9071cc8f9b2)
                                ]
                                coclass EventData
                                {
                                    [default] interface IEventData;
                                };
                            
                                [
                                    uuid(b5736d7e-0d93-4a0f-aa7d-33283e3c9a4e)
                                ]
                                coclass FlawData
                                {
                                    [default] interface IFlawData;
                                };
                            
                                [
                                    uuid(B6AFC998-139C-44CE-B431-9CD001774797)
                                ]
                                coclass ImageData
                                {
                                    [default] interface IImageData;
                                    interface IStream;
                                };
                            
                                [
                                    uuid(c6da7cb0-29e5-4df1-be12-ee863daf7797)
                                ]
                                coclass LineHardwareData
                                {
                                    [default] interface ILineHardwareData;
                                };
                            
                                [
                                    uuid(635a7140-dda9-4ccc-846a-03314e9ee5dd)
                                ]
                                coclass JobData
                                {
                                    [default] interface IJobData;
                                };
                                [
                                    uuid(30cbf047-f7ac-43b6-9a7b-5b8edc4ccb45)
                                ]
                                coclass JobQueueData
                                {
                                    [default] interface IJobQueueData;
                                };
                                [
                                    uuid(B1FB3525-376C-49BD-9F69-7C2E7DC26F2B)
                                ]
                                coclass ProductData
                                {
                                    [default] interface IProductData;
                                };
                                [
                            		uuid(976cf999-21ad-4302-8165-57ad5bccd3c1)
                            	]
                            	coclass CommandData
                            	{
                            		[default] interface ICommandData;
                            	};
                            	[
                            		uuid(79cdf1bf-df4f-4720-9bef-b3ed0d3f95a2)
                            	]
                            	coclass LaneSetupData
                            	{
                            		[default] interface ILaneSetupData;
                            	};
                            	[
                            		uuid(2455df8c-ff78-4434-8560-9df1e62bfaca)
                            	]
                            	coclass LaneData
                            	{
                            		[default] interface ILaneData;
                            	};
                                [
                                    uuid(f287dc18-74c9-446c-a753-e8e6b18e58f2)
                                ]
                                coclass JobLane
                                {
                                    [default] interface IJobLane;
                                };
                            	[
                            		uuid(0b4be3c3-f304-4f98-a870-e2933dee5b7e)
                            	]
                            	coclass ErrorMessageData
                            	{
                            		[default] interface IErrorMessageData;
                            	};
                            };
                            
                            import "shobjidl.idl";
                            import "shobjidl.idl";
                            
                            1 Reply Last reply
                            0
                            • hskoglundH Offline
                              hskoglundH Offline
                              hskoglund
                              wrote on last edited by
                              #24

                              Found another code snippet for COM debugging, insert this just before that failing call ..GetTypeInfo():

                              // insert this code right after retrieving the ITypeInfo ptr
                              
                              // check that GetIDsOfNames works
                              //    QString unicodeName = "Clone";        // use this one for IEventData
                                  QString unicodeName = "Deserialize";  // use this one for IErrorMessageData
                                  OLECHAR *name = reinterpret_cast<wchar_t *>(const_cast<ushort *>(unicodeName.utf16()));
                                  DISPID dispid = 0;
                                  hr = pDispatch->GetIDsOfNames(IID_NULL,&name,1,LOCALE_SYSTEM_DEFAULT,&dispid);
                                  if (FAILED(hr))
                                      qFatal() << "Error: GetIDsOfNames() failed" << QString::number((uint) hr,16);
                                  qDebug() << "ok, dispid =" << dispid;
                                
                              // old code     
                                  CComPtr<ITypeInfo> pTypeInfo;
                              ...
                              

                              You could try this both for the coclass ErrorMessageData or if you flip the comments: for coclass EventData.

                              Also: to make clear what's failing:

                              1. On your development PC where the DataTypesLibrary.dll is visible in the registry everything works, both my old debugging code (i.e. GetTypeInfo()) and generateDocumentation(), right?

                              2. On the target PC without any stuff in the registry GetTypeInfo() and generateDocumentation() both fails.

                              P.S. Pls have another go at ProcessMonitor, a trick I use is to insert a call to QMessageBox just before the code to trace, like this:

                                  QMessageBox msgBox;
                                  msgBox.setText("Start Procmon now...");
                                  msgBox.exec();
                              

                              (don't forget to #include "QMessageBox" :-)

                              Bruce.ZhangB 1 Reply Last reply
                              0
                              • hskoglundH hskoglund

                                Found another code snippet for COM debugging, insert this just before that failing call ..GetTypeInfo():

                                // insert this code right after retrieving the ITypeInfo ptr
                                
                                // check that GetIDsOfNames works
                                //    QString unicodeName = "Clone";        // use this one for IEventData
                                    QString unicodeName = "Deserialize";  // use this one for IErrorMessageData
                                    OLECHAR *name = reinterpret_cast<wchar_t *>(const_cast<ushort *>(unicodeName.utf16()));
                                    DISPID dispid = 0;
                                    hr = pDispatch->GetIDsOfNames(IID_NULL,&name,1,LOCALE_SYSTEM_DEFAULT,&dispid);
                                    if (FAILED(hr))
                                        qFatal() << "Error: GetIDsOfNames() failed" << QString::number((uint) hr,16);
                                    qDebug() << "ok, dispid =" << dispid;
                                  
                                // old code     
                                    CComPtr<ITypeInfo> pTypeInfo;
                                ...
                                

                                You could try this both for the coclass ErrorMessageData or if you flip the comments: for coclass EventData.

                                Also: to make clear what's failing:

                                1. On your development PC where the DataTypesLibrary.dll is visible in the registry everything works, both my old debugging code (i.e. GetTypeInfo()) and generateDocumentation(), right?

                                2. On the target PC without any stuff in the registry GetTypeInfo() and generateDocumentation() both fails.

                                P.S. Pls have another go at ProcessMonitor, a trick I use is to insert a call to QMessageBox just before the code to trace, like this:

                                    QMessageBox msgBox;
                                    msgBox.setText("Start Procmon now...");
                                    msgBox.exec();
                                

                                (don't forget to #include "QMessageBox" :-)

                                Bruce.ZhangB Offline
                                Bruce.ZhangB Offline
                                Bruce.Zhang
                                wrote on last edited by Bruce.Zhang
                                #25

                                @hskoglund I tried the below steps on my PC.

                                First, I added the code and it still failed with 0x8002801D error.

                                Below is the log from Process Monitor when exec this line of code:

                                    hr = pDispatch->GetIDsOfNames(IID_NULL, &name, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
                                

                                I add filter operation must starts with "Reg"

                                5:29:48.3317575 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\Software\Microsoft\Rpc\Extensions	SUCCESS	Desired Access: Read
                                5:29:48.3317744 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SOFTWARE\Microsoft\Rpc\Extensions\NdrOleExtDLL	SUCCESS	Type: REG_EXPAND_SZ, Length: 24, Data: combase.dll
                                5:29:48.3317924 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SOFTWARE\Microsoft\Rpc\Extensions	SUCCESS	
                                5:29:48.3318212 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3318302 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\Software\Microsoft\Rpc	SUCCESS	Desired Access: Read
                                5:29:48.3318419 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SOFTWARE\Microsoft\Rpc\MaxRpcSize	NAME NOT FOUND	Length: 16
                                5:29:48.3318539 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SOFTWARE\Microsoft\Rpc	SUCCESS	
                                5:29:48.3318905 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Services\CCG	REPARSE	Desired Access: Read
                                5:29:48.3319008 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Services\CCG	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3319106 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Services\CCG	REPARSE	Desired Access: Read
                                5:29:48.3319179 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Services\CCG	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3319285 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName	REPARSE	Desired Access: Read
                                5:29:48.3319360 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName	SUCCESS	Desired Access: Read
                                5:29:48.3319458 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName	SUCCESS	Type: REG_SZ, Length: 32, Data: DESKTOP-1AJB9L5
                                5:29:48.3319577 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\System\CurrentControlSet\Control\ComputerName\ActiveComputerName	SUCCESS	
                                5:29:48.3319648 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\Setup	SUCCESS	Desired Access: Read
                                5:29:48.3319726 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SYSTEM\Setup\OOBEInProgress	SUCCESS	Type: REG_DWORD, Length: 4, Data: 0
                                5:29:48.3319826 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SYSTEM\Setup	SUCCESS	
                                5:29:48.3319892 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\System\Setup	SUCCESS	Desired Access: Read
                                5:29:48.3319963 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SYSTEM\Setup\SystemSetupInProgress	SUCCESS	Type: REG_DWORD, Length: 4, Data: 0
                                5:29:48.3320058 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SYSTEM\Setup	SUCCESS	
                                5:29:48.3320151 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\TestRegFreeCOM.exe	NAME NOT FOUND	Desired Access: Query Value, Enumerate Sub Keys
                                5:29:48.3320658 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3320726 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\Software\Policies\Microsoft\Windows NT\Rpc	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3320858 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	BUFFER TOO SMALL	Query: Name, Length: 0
                                5:29:48.3320930 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	SUCCESS	Query: Name
                                5:29:48.3321016 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\machine\Software\Policies\Microsoft\Windows NT\Rpc	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3321373 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3321441 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\Software\Microsoft\Rpc	SUCCESS	Desired Access: Query Value
                                5:29:48.3321531 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SOFTWARE\Microsoft\Rpc\IdleTimerWindow	NAME NOT FOUND	Length: 16
                                5:29:48.3321639 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SOFTWARE\Microsoft\Rpc	SUCCESS	
                                5:29:48.3322149 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCU\Software\Classes	SUCCESS	Desired Access: Maximum Allowed, Granted Access: All Access
                                5:29:48.3322969 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKLM	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3323035 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\Software\Microsoft\COM3	SUCCESS	Desired Access: Read
                                5:29:48.3323143 PM	TestRegFreeCOM.exe	18844	RegSetInfoKey	HKLM\SOFTWARE\Microsoft\COM3	SUCCESS	KeySetInformationClass: KeySetHandleTagsInformation, Length: 0
                                5:29:48.3323280 PM	TestRegFreeCOM.exe	18844	RegQueryValue	HKLM\SOFTWARE\Microsoft\COM3\Com+Enabled	SUCCESS	Type: REG_DWORD, Length: 4, Data: 1
                                5:29:48.3323389 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKLM\SOFTWARE\Microsoft\COM3	SUCCESS	
                                5:29:48.3340202 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCR\PackagedCom	SUCCESS	Desired Access: Read
                                5:29:48.3340360 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCR\PackagedCom\TypeLibIndex	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3340657 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCU\Software\Classes	SUCCESS	Desired Access: Maximum Allowed, Granted Access: All Access
                                5:29:48.3340779 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes	SUCCESS	Query: Name
                                5:29:48.3340872 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3340935 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3341005 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCU\Software\Classes\TypeLib	SUCCESS	Desired Access: Maximum Allowed, Granted Access: All Access
                                5:29:48.3341120 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKCU\Software\Classes	SUCCESS	
                                5:29:48.3341200 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes\TypeLib	SUCCESS	Query: Name
                                5:29:48.3341280 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes\TypeLib	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3341335 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes\TypeLib	SUCCESS	Query: HandleTags, HandleTags: 0x0
                                5:29:48.3341406 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCU\Software\Classes\TypeLib\{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}	NAME NOT FOUND	Desired Access: Maximum Allowed
                                5:29:48.3341502 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKCR\TypeLib\{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}	NAME NOT FOUND	Desired Access: Maximum Allowed
                                5:29:48.3341673 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes\TypeLib	BUFFER TOO SMALL	Query: Name, Length: 0
                                5:29:48.3341740 PM	TestRegFreeCOM.exe	18844	RegQueryKey	HKCU\Software\Classes\TypeLib	SUCCESS	Query: Name
                                5:29:48.3341847 PM	TestRegFreeCOM.exe	18844	RegOpenKey	HKLM\SOFTWARE\Microsoft\AppModel\Lookaside\user\software\Classes\TypeLib\{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}	NAME NOT FOUND	Desired Access: Read
                                5:29:48.3341984 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKCU\Software\Classes\TypeLib	SUCCESS	
                                5:29:48.3345887 PM	TestRegFreeCOM.exe	18844	RegCloseKey	HKCU\Software\Classes	SUCCESS	
                                
                                

                                Second, After I registered the DLL like this:

                                regsvr32   xxx.dll
                                

                                Then everything goes fine.

                                1 Reply Last reply
                                0
                                • hskoglundH Offline
                                  hskoglundH Offline
                                  hskoglund
                                  wrote on last edited by
                                  #26
                                  This post is deleted!
                                  1 Reply Last reply
                                  0
                                  • hskoglundH Offline
                                    hskoglundH Offline
                                    hskoglund
                                    wrote on last edited by
                                    #27

                                    Hi, I had written a post above where I more or less gave up, but I made another effort!

                                    It turns out that that ancient Qt enhancement suggestion speaking about manifest files wasn't completely science-fiction. I found this MSDN article and of course some StackOverflow posts helped a lot.

                                    Thanks to your ProcMon trace above we can see it haplessly looking for DataTypesLibrary.dll's type library in the registry. By adding manifest files we can provide a path to that type library.

                                    Actually we need two manifest files. The first you'll add to your TestRegFreeCOM.exe. I'm assuming you're using MSVC 64-bits compiler and ..pro file (not CMake).
                                    Qt already adds an .rc file to your .exe so we also need to remove that (there can only be one manifest). Add this to your TestRegFreeCOM.pro:

                                    CONFIG -= embed_manifest_exe
                                    QMAKE_MANIFEST = $$PWD/TestRegFreeCOM.exe.manifest
                                    

                                    then create a text file TestRegFreeCOM.exe.manifest in your project dir with this:

                                    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                      <dependency>
                                        <dependentAssembly>
                                          <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" 
                                           version="6.0.0.0" 
                                    	publicKeyToken="6595b64144ccf1df"
                                    	language="*"
                                    	processorArchitecture="*" />
                                        </dependentAssembly>
                                      </dependency>
                                      <dependency>
                                        <dependentAssembly>
                                          <assemblyIdentity 
                                            name="DataTypesLibrary.X" 
                                            version="1.0.0.0" 
                                            type="win32" 
                                    	language="*"
                                           processorArchitecture="*" />
                                    </dependentAssembly>
                                      </dependency>
                                      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                                        <security>
                                          <requestedPrivileges>
                                            <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
                                          </requestedPrivileges>
                                        </security>
                                      </trustInfo>
                                    </assembly>
                                    

                                    most of the contents is because we're replacing the Qt standard manifest with our own. The relevant part is where we add a dependentAssembly for the DataTypesLibrary. I think the old MSDN article I mentioned above started this trend of suffixing an .X, don't worry it works :-)

                                    The second manifest file is for the DataTypesLibrary.dll, create a text file called DataTypesLibrary.X.manifest with this:

                                    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                     <assemblyIdentity 
                                        name="DataTypesLibrary.X" 
                                        version="1.0.0.0" 
                                        type="win32"
                                       processorArchitecture="AMD64" />
                                    
                                      <file name="DataTypesLibrary.dll">
                                      <comClass
                                        progid="EventData"
                                        clsid="{0405e972-093d-4f16-9b4f-f9071cc8f9b2}"
                                        threadingModel = "Apartment" />
                                    
                                       <typelib tlbid="{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}"
                                        version="1.0" 
                                        helpdir="" />
                                    
                                      </file>
                                    </assembly>
                                    

                                    then put the DataTypesLibrary.X.manifest and DataTypesLibrary.dll both in the same directory as TestRegFreeCOM.exe.

                                    To test, try something like:

                                    auto comObject = new QAxObject("EventData");
                                    qDebug() << comObject->generateDocumentation();
                                    

                                    If it fails, you can trace the manifest fiddling with the SXSTrace.exe tool, step 1, start the trace in a separate CMD window:
                                    sxstrace trace -logfile:sxstrace
                                    irun TestRegFreeCOM.exe and press Enter to stop the trace
                                    step 2: decode the trace
                                    sxxtrace parse -logfile:sxstrace -outfile:trace.txt
                                    then you can type trace.txt

                                    If this works for you, you owe me a beer :-))

                                    Bruce.ZhangB 2 Replies Last reply
                                    1
                                    • hskoglundH hskoglund

                                      Hi, I had written a post above where I more or less gave up, but I made another effort!

                                      It turns out that that ancient Qt enhancement suggestion speaking about manifest files wasn't completely science-fiction. I found this MSDN article and of course some StackOverflow posts helped a lot.

                                      Thanks to your ProcMon trace above we can see it haplessly looking for DataTypesLibrary.dll's type library in the registry. By adding manifest files we can provide a path to that type library.

                                      Actually we need two manifest files. The first you'll add to your TestRegFreeCOM.exe. I'm assuming you're using MSVC 64-bits compiler and ..pro file (not CMake).
                                      Qt already adds an .rc file to your .exe so we also need to remove that (there can only be one manifest). Add this to your TestRegFreeCOM.pro:

                                      CONFIG -= embed_manifest_exe
                                      QMAKE_MANIFEST = $$PWD/TestRegFreeCOM.exe.manifest
                                      

                                      then create a text file TestRegFreeCOM.exe.manifest in your project dir with this:

                                      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                      <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                        <dependency>
                                          <dependentAssembly>
                                            <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" 
                                             version="6.0.0.0" 
                                      	publicKeyToken="6595b64144ccf1df"
                                      	language="*"
                                      	processorArchitecture="*" />
                                          </dependentAssembly>
                                        </dependency>
                                        <dependency>
                                          <dependentAssembly>
                                            <assemblyIdentity 
                                              name="DataTypesLibrary.X" 
                                              version="1.0.0.0" 
                                              type="win32" 
                                      	language="*"
                                             processorArchitecture="*" />
                                      </dependentAssembly>
                                        </dependency>
                                        <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                                          <security>
                                            <requestedPrivileges>
                                              <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
                                            </requestedPrivileges>
                                          </security>
                                        </trustInfo>
                                      </assembly>
                                      

                                      most of the contents is because we're replacing the Qt standard manifest with our own. The relevant part is where we add a dependentAssembly for the DataTypesLibrary. I think the old MSDN article I mentioned above started this trend of suffixing an .X, don't worry it works :-)

                                      The second manifest file is for the DataTypesLibrary.dll, create a text file called DataTypesLibrary.X.manifest with this:

                                      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                      <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                       <assemblyIdentity 
                                          name="DataTypesLibrary.X" 
                                          version="1.0.0.0" 
                                          type="win32"
                                         processorArchitecture="AMD64" />
                                      
                                        <file name="DataTypesLibrary.dll">
                                        <comClass
                                          progid="EventData"
                                          clsid="{0405e972-093d-4f16-9b4f-f9071cc8f9b2}"
                                          threadingModel = "Apartment" />
                                      
                                         <typelib tlbid="{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}"
                                          version="1.0" 
                                          helpdir="" />
                                      
                                        </file>
                                      </assembly>
                                      

                                      then put the DataTypesLibrary.X.manifest and DataTypesLibrary.dll both in the same directory as TestRegFreeCOM.exe.

                                      To test, try something like:

                                      auto comObject = new QAxObject("EventData");
                                      qDebug() << comObject->generateDocumentation();
                                      

                                      If it fails, you can trace the manifest fiddling with the SXSTrace.exe tool, step 1, start the trace in a separate CMD window:
                                      sxstrace trace -logfile:sxstrace
                                      irun TestRegFreeCOM.exe and press Enter to stop the trace
                                      step 2: decode the trace
                                      sxxtrace parse -logfile:sxstrace -outfile:trace.txt
                                      then you can type trace.txt

                                      If this works for you, you owe me a beer :-))

                                      Bruce.ZhangB Offline
                                      Bruce.ZhangB Offline
                                      Bruce.Zhang
                                      wrote on last edited by
                                      #28

                                      @hskoglund This really works now. That's very kind of you. Pretty much thanks. I owe you a beer^_^.

                                      1 Reply Last reply
                                      0
                                      • Bruce.ZhangB Bruce.Zhang has marked this topic as solved on
                                      • hskoglundH hskoglund

                                        Hi, I had written a post above where I more or less gave up, but I made another effort!

                                        It turns out that that ancient Qt enhancement suggestion speaking about manifest files wasn't completely science-fiction. I found this MSDN article and of course some StackOverflow posts helped a lot.

                                        Thanks to your ProcMon trace above we can see it haplessly looking for DataTypesLibrary.dll's type library in the registry. By adding manifest files we can provide a path to that type library.

                                        Actually we need two manifest files. The first you'll add to your TestRegFreeCOM.exe. I'm assuming you're using MSVC 64-bits compiler and ..pro file (not CMake).
                                        Qt already adds an .rc file to your .exe so we also need to remove that (there can only be one manifest). Add this to your TestRegFreeCOM.pro:

                                        CONFIG -= embed_manifest_exe
                                        QMAKE_MANIFEST = $$PWD/TestRegFreeCOM.exe.manifest
                                        

                                        then create a text file TestRegFreeCOM.exe.manifest in your project dir with this:

                                        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                          <dependency>
                                            <dependentAssembly>
                                              <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" 
                                               version="6.0.0.0" 
                                        	publicKeyToken="6595b64144ccf1df"
                                        	language="*"
                                        	processorArchitecture="*" />
                                            </dependentAssembly>
                                          </dependency>
                                          <dependency>
                                            <dependentAssembly>
                                              <assemblyIdentity 
                                                name="DataTypesLibrary.X" 
                                                version="1.0.0.0" 
                                                type="win32" 
                                        	language="*"
                                               processorArchitecture="*" />
                                        </dependentAssembly>
                                          </dependency>
                                          <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                                            <security>
                                              <requestedPrivileges>
                                                <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
                                              </requestedPrivileges>
                                            </security>
                                          </trustInfo>
                                        </assembly>
                                        

                                        most of the contents is because we're replacing the Qt standard manifest with our own. The relevant part is where we add a dependentAssembly for the DataTypesLibrary. I think the old MSDN article I mentioned above started this trend of suffixing an .X, don't worry it works :-)

                                        The second manifest file is for the DataTypesLibrary.dll, create a text file called DataTypesLibrary.X.manifest with this:

                                        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                                        <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
                                         <assemblyIdentity 
                                            name="DataTypesLibrary.X" 
                                            version="1.0.0.0" 
                                            type="win32"
                                           processorArchitecture="AMD64" />
                                        
                                          <file name="DataTypesLibrary.dll">
                                          <comClass
                                            progid="EventData"
                                            clsid="{0405e972-093d-4f16-9b4f-f9071cc8f9b2}"
                                            threadingModel = "Apartment" />
                                        
                                           <typelib tlbid="{A9D4AEA1-46D8-4E98-B9AA-BE93A21A58AD}"
                                            version="1.0" 
                                            helpdir="" />
                                        
                                          </file>
                                        </assembly>
                                        

                                        then put the DataTypesLibrary.X.manifest and DataTypesLibrary.dll both in the same directory as TestRegFreeCOM.exe.

                                        To test, try something like:

                                        auto comObject = new QAxObject("EventData");
                                        qDebug() << comObject->generateDocumentation();
                                        

                                        If it fails, you can trace the manifest fiddling with the SXSTrace.exe tool, step 1, start the trace in a separate CMD window:
                                        sxstrace trace -logfile:sxstrace
                                        irun TestRegFreeCOM.exe and press Enter to stop the trace
                                        step 2: decode the trace
                                        sxxtrace parse -logfile:sxstrace -outfile:trace.txt
                                        then you can type trace.txt

                                        If this works for you, you owe me a beer :-))

                                        Bruce.ZhangB Offline
                                        Bruce.ZhangB Offline
                                        Bruce.Zhang
                                        wrote on last edited by Bruce.Zhang
                                        #29

                                        @hskoglund Sorry for bother you again. I had other COM dlls written in CSharp. I picked one to operate via dumpcpp, but if I generate .h only using " --nometaobject", then will have link errors. but will succeed when generating both .h and cpp.

                                        The tlb and manifest files as follows:
                                        https://drive.google.com/file/d/1-2240-43cqiw-rmdVIJvBKnMedPGCKau/view?usp=sharing

                                        https://drive.google.com/file/d/1WoWapdes613jN86Eoy6EnrfXL-0fXWax/view?usp=sharing

                                        https://drive.google.com/file/d/1p20BSfeuuFCaFUmhfRZi6lnurLlVBO3x/view?usp=sharing

                                        1 Reply Last reply
                                        0
                                        • hskoglundH Offline
                                          hskoglundH Offline
                                          hskoglund
                                          wrote on last edited by
                                          #30

                                          Do you need to use dumpcpp?
                                          I think if you just write the manifest files using the .idl and try with the usual:

                                          auto comObject = new QAxObject("RecipeManagement");
                                          qDebug() << comObject->generateDocumentation();
                                          

                                          then you should be able to use QAxObject's dynamicall() and setProperty() etc. instead.

                                          Bruce.ZhangB 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved