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. is there anyone familiar with COM? I met problem when changed project from MFC to Qt
Forum Updated to NodeBB v4.3 + New Features

is there anyone familiar with COM? I met problem when changed project from MFC to Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
29 Posts 6 Posters 3.2k Views 2 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    You should give more details about what you are using and how you are using it.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu
      wrote on last edited by
      #3

      in that dll, it fail to CoInitializeEx

      APIImp::APIImp():m_pData(NULL)
      {
      	//if(!SUCCEEDED(CoInitialize(NULL)))
      	if(!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
      	{
      		assert(0 && "fail to CoInitializeEx");
      		return;
      	}
      
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        So it's a dll you have control over ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        O 1 Reply Last reply
        0
        • O Offline
          O Offline
          opengpu
          wrote on last edited by
          #5

          yes, i have the dll project, and i added that assert.
          but i donot think i can change the code.

          1 Reply Last reply
          0
          • O Offline
            O Offline
            opengpu
            wrote on last edited by
            #6

            why CoInitializeEx fail in tha DLL? it works in MFC app, and i also donot see anything init or special work.
            sorry, i am not quite familia with COM

            1 Reply Last reply
            0
            • SGaistS SGaist

              So it's a dll you have control over ?

              O Offline
              O Offline
              opengpu
              wrote on last edited by
              #7

              @SGaist better donot change the DLL code...

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Do you have several calls to CoInitializeEx ?
                Are you properly calling CoUninitialize when you're done with your COM stuff ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • O Offline
                  O Offline
                  opengpu
                  wrote on last edited by
                  #9

                  @SGaist said in anyone familiar with COM? i met problem when changed project from MFC to Qt:

                  CoInitializeEx

                  just one time in DLL

                  APIImp::~APIImp()
                  {
                  	release();
                  	CoUninitialize();
                  }
                  
                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    opengpu
                    wrote on last edited by
                    #10
                    class APIImp {
                    private:
                    DataCOMLib::_DataCOMPtr	m_pData;
                    
                    1 Reply Last reply
                    0
                    • O Offline
                      O Offline
                      opengpu
                      wrote on last edited by
                      #11

                      CppAPIImp::initialize()
                      {
                      CreateInstance(__uuidof(DataCOMLib::DataCOM), NULL, CLSCTX_ALL);
                      QueryInterface
                      FindConnectionPoint
                      QueryInterface
                      Advise

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        opengpu
                        wrote on last edited by
                        #12

                        APIImp::release()
                        {
                        cancelRequest
                        Unadvise
                        Release

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

                          Hi, what error do you get from your CoInitializeEx() call? Try something like:

                          HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
                          qDebug() << hr;
                          
                          
                          O 1 Reply Last reply
                          2
                          • hskoglundH hskoglund

                            Hi, what error do you get from your CoInitializeEx() call? Try something like:

                            HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
                            qDebug() << hr;
                            
                            
                            O Offline
                            O Offline
                            opengpu
                            wrote on last edited by
                            #14

                            @hskoglund that DLL with COM is not Qt program...

                            mrjjM 1 Reply Last reply
                            0
                            • O opengpu

                              @hskoglund that DLL with COM is not Qt program...

                              mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @opengpu
                              Hi
                              then use std::cout to show the HRESULT.
                              It can give hints about why its not loading,.

                              What im a bit puzzled about if that is the same DLL used in the MFC app, and you did not change
                              the actual DLL code. why should it then stop working?

                              1 Reply Last reply
                              2
                              • O Offline
                                O Offline
                                opengpu
                                wrote on last edited by
                                #16

                                the DLL is the same...
                                and i wiil log out the errorcode

                                1 Reply Last reply
                                0
                                • O Offline
                                  O Offline
                                  opengpu
                                  wrote on last edited by
                                  #17

                                  anyone familiar ?

                                  mrjjM 1 Reply Last reply
                                  0
                                  • O opengpu

                                    anyone familiar ?

                                    mrjjM Offline
                                    mrjjM Offline
                                    mrjj
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @opengpu
                                    did you get HRESULT hr out ?

                                    O 1 Reply Last reply
                                    0
                                    • mrjjM mrjj

                                      @opengpu
                                      did you get HRESULT hr out ?

                                      O Offline
                                      O Offline
                                      opengpu
                                      wrote on last edited by
                                      #19

                                      @mrjj HRESULT = -2147417850

                                      mrjjM 1 Reply Last reply
                                      0
                                      • O opengpu

                                        @mrjj HRESULT = -2147417850

                                        mrjjM Offline
                                        mrjjM Offline
                                        mrjj
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #20

                                        @opengpu
                                        ok. super. Hopefully mr hskoglund can get something out of that.

                                        1 Reply Last reply
                                        0
                                        • aha_1980A Offline
                                          aha_1980A Offline
                                          aha_1980
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          https://en.m.wikipedia.org/wiki/HRESULT describes tools to decode HRESULTs

                                          Qt has to stay free or it will die.

                                          1 Reply Last reply
                                          1

                                          • Login

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