Results 1 to 12 of 12

Thread: using com dll

  1. #1
    Join Date
    Jul 2011
    Posts
    4
    Qt products
    Qt4

    Default using com dll

    in vs2010 c++ i used the following code to use some functions in a dll file that i don't have its header

    Qt Code:
    1. #import "dll path"
    2. HRESULT hr = CoInitialize(NULL);
    3. if (hr==S_OK)
    4. {cout<<"INITIALIZED\n";}
    5.  
    6. Trans_ATLLib::ITransCriptPtr Trans;
    7. hr = Trans.CreateInstance(__uuidof(Trans_ATLLib::TransCript));
    8. if (hr==S_OK)
    9. {cout<<"INSTANCE CREATED\n";}
    10.  
    11. hr =Trans->EnableLastCharTashkeel(true);
    12. if (hr==S_OK)
    13. {cout<<"EnableLastCharTashkeel DONE\n";}
    14.  
    15. hr =Trans->EnableEmphaticLAM_RAA(true);
    16. if (hr==S_OK)
    17. {cout<<"EnableEmphaticLAM_RAA DONE\n";}
    18.  
    19. VARIANT_BOOL test;
    20. test = Trans->SetText(arabic_string);
    21. if (test==0)
    22. {cout<<"error in setting the arabic sting\n";}
    23.  
    24. string result;
    25. result = Trans->GetResult();
    26.  
    27. istringstream iss(result);
    28. vector<string> phonemes;
    29. copy(istream_iterator<string>(iss),istream_iterator<string>(),back_inserter<vector<string> >(phonemes));
    30. return phonemes;
    31.  
    32. }
    To copy to clipboard, switch view to plain text mode 

    but i found that qt doesn't use the same method

    can any one help me in calling these functions in qt

    thanks in advance
    Last edited by wysota; 24th September 2011 at 22:13. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using com dll

    Look at QAxBase and related classes in the QAxContainer module.

    There is a tutorial on using ActiveX / COM in Qt. Look for ActiveQt.

  3. #3
    Join Date
    Jul 2011
    Posts
    4
    Qt products
    Qt4

    Default Re: using com dll

    can you explain in more details as i am very new to qt and if possible can you give me an example

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using com dll


  5. #5
    Join Date
    Jul 2011
    Posts
    4
    Qt products
    Qt4

    Default Re: using com dll

    sorry but i told you that this is the first time for me with qt
    if possible can you convert the above code to qt code

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using com dll

    No. I don't have time to do my job *and* yours. The purpose of this forum is to give advice and help so people can learn to do things themselves.

    All of us were new to Qt once. We learned enough about Qt to be able to give help to others by reading and looking at the examples, making mistakes, and understanding what we did wrong.

    If we simply gave you all the fish you wanted, you would never learn how to catch fish yourself, would you?

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: using com dll

    Qt does not stop you using generic Windows code to interact with ActiveX/COM objects. If you have working code then use that.

    Qt does provide some support for ActiveX objects so that they can be more easily used in Qt user interfaces and programs, or so that Qt components can be made for use outside.

  8. #8
    Join Date
    Jul 2011
    Posts
    4
    Qt products
    Qt4

    Default Re: using com dll

    Quote Originally Posted by d_stranz View Post
    No. I don't have time to do my job *and* yours. The purpose of this forum is to give advice and help so people can learn to do things themselves.

    All of us were new to Qt once. We learned enough about Qt to be able to give help to others by reading and looking at the examples, making mistakes, and understanding what we did wrong.

    If we simply gave you all the fish you wanted, you would never learn how to catch fish yourself, would you?
    no i just said the words in the wrong way
    i mean what is the corresponding steps in qt (how to load ,create instance,......)
    any way i worked around it by using the vs code as a exe file with little changes

    thank you and of course you are totally right

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: using com dll

    The best example of automating an ActiveX/COM control/exe is the Qutlook example in the docs. This example uses the dumpcpp tool to give you neat proxy classes to hide the more unpleasant aspects of ActiveX. You should browse the classes provided by the dumpcpp output for your COM object.

  10. #10
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: using com dll

    Hello, all. I, too, am a new user looking to call a COM dll file. Wish I had read this thread before jumping around, but I managed to get it to work a little using QAxObject. But I cannot get functions with return parameters to return values to me, other than for int&. This COM works on C#, but not with Qt. Am I doing this right?

    Qt Code:
    1. //void GetVersionNumber (int&)
    2. QVariantList params; params.append(0);
    3. object->dynamicCall("GetVersionNumber(int&)", params);
    4. std::cout << "params = " << params[0].toInt() << std::endl;
    5. //returns 64. Great!
    6.  
    7. //void GetInstSoftwareVersion (QString&)
    8. QVariantList params;
    9. params.append("xx");
    10. ptr->dynamicCall("GetInstSoftwareVersion(QString &)", params);
    11. std::cout << "GetInstSoftwareVersion:sarray[0] = " << params[0].toString().toStdString() << std::endl;
    12. //returns "xx" and not e.g. "1.00" Why??? Driving me nuts!
    To copy to clipboard, switch view to plain text mode 

    Thank you in advance.
    Last edited by wysota; 24th September 2011 at 22:14. Reason: missing [code] tags

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: using com dll

    I would assume "GetInstSoftwareVersion" takes a different parameter type than QString since the latter is a Qt type that is unknown to other frameworks. I suggest you consult the manual for this "GetInstSoftwareVersion" call.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    paulanon (26th September 2011)

  13. #12
    Join Date
    Sep 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: using com dll

    Thank you for the response.
    The manual uses "BSTR FAR*" I do not know what "FAR" is, but "BSTR" is handled by Qt (http://doc.qt.nokia.com/latest/qaxbase.html). Is there a way to know this is a problem or not?

    I am thinking the parameter is handled by Qt since the generated API for this DLL library says to use QString&:

    1) The documentation says:
    long GetInstSoftwareVersion(BSTR FAR* pbstrInstSoftwareVersion)

    2) If I use Qt dumpcpp.exe, the header generated shows:
    class MSFILEREADERLIB_EXPORT IXRawfile : public QAxObject
    { ...
    inline void GetInstSoftwareVersion(QString& pbstrInstSoftwareVersion);
    ...};


    3) If I use:
    QAxObject * ptr = new QAxObject ( "MSFileReader.XRawfile", 0 );
    std::cout << ptr->generateDocumentation().toStdString() << std::endl;

    I get:
    void GetInstSoftwareVersion (QString& pbstrInstSoftwareVersion) [slot]
    method GetInstSoftwareVersion
    Connect a signal to this slot:
    QObject::connect(sender, SIGNAL(someSignal(QString&)), object, SLOT(GetInstSoftwareVersion(QString&)));
    Or call the function directly:
    QVariantList params = ...
    object->dynamicCall("GetInstSoftwareVersion(QString&)", params);
    Last edited by paulanon; 26th September 2011 at 23:51.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.