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. Using .NET dll via QT
Forum Update on Monday, May 27th 2025

Using .NET dll via QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 623 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.
  • B Offline
    B Offline
    Bean_Noodle
    wrote on 8 Dec 2020, 10:33 last edited by
    #1

    I am hardly trying to use Laser Control dll file based on .NET on QT.
    I registered dll file on server, made tlb file, and imported it with using command

    @ #import "Litron.Control.CWLasers.tlb" no_namespace named_guids @

    after that, I used this command

    @

    struct cwDiodeLaserPIV;
    cwDiodeLaserPIV Laser=NULL;
    CoInitialize(NULL);
    HRESULT hr = CoCreateInstance(CLSID_cwDiodeLaserPIV, NULL, CLSCTX_INPROC_SERVER, IID__cwDiodeLaserPIV, reinterpret_cast<void
    *>(&Laser));

    @ *I added ActiveQT header file also to use CoCreateInstance

    when i Check whether this code works with this,

    @
    if(SUCCEEDED(hr))
    { qDebug()<<"Calling dll is succeded"; }
    else
    { qDebug()<<"Calling dll is failed"; }
    @

    "Calling dll is failed" is come out.
    But, When i use same code in Visual Studio C++, "Calling dll is succeded" is come out.
    furthermore, even calling dll is succeeded, I couldn't call the function of dll at VS.

    Here are some Questions.

    1. I used struct cwDiodeLaserPIV. because in tlh file, cwDiodeLaserPIV is declared with struct command.
      but actually, when i see the inner part of dll, cwDiodeLaserPIV was declared with class command.
      Why this happen? Can I use it with struct declaration?

    2. When I write down the code at QT, CLSID_ and IID_ part, There were no directory that automatically connected.
      On the Other hand, at VS, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are automatically found by VS
      Say again, at QT, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are not found in list of directory that automatically connected when i write down CLSID_ or IID_. Why this happen? Can 't I use this way at QT?

    ++ I refered https://forum.qt.io/topic/108642/how-to-include-a-com-tlb-library-in-my-c-project/2 and made cpp and header file using dumpcpp. but it seems there aren't enough function in it.

    I am such a vanilla on QT and Programming. So, example code would be very helpful
    Thanks very much...

    K J 2 Replies Last reply 8 Dec 2020, 11:38
    0
    • B Bean_Noodle
      8 Dec 2020, 10:33

      I am hardly trying to use Laser Control dll file based on .NET on QT.
      I registered dll file on server, made tlb file, and imported it with using command

      @ #import "Litron.Control.CWLasers.tlb" no_namespace named_guids @

      after that, I used this command

      @

      struct cwDiodeLaserPIV;
      cwDiodeLaserPIV Laser=NULL;
      CoInitialize(NULL);
      HRESULT hr = CoCreateInstance(CLSID_cwDiodeLaserPIV, NULL, CLSCTX_INPROC_SERVER, IID__cwDiodeLaserPIV, reinterpret_cast<void
      *>(&Laser));

      @ *I added ActiveQT header file also to use CoCreateInstance

      when i Check whether this code works with this,

      @
      if(SUCCEEDED(hr))
      { qDebug()<<"Calling dll is succeded"; }
      else
      { qDebug()<<"Calling dll is failed"; }
      @

      "Calling dll is failed" is come out.
      But, When i use same code in Visual Studio C++, "Calling dll is succeded" is come out.
      furthermore, even calling dll is succeeded, I couldn't call the function of dll at VS.

      Here are some Questions.

      1. I used struct cwDiodeLaserPIV. because in tlh file, cwDiodeLaserPIV is declared with struct command.
        but actually, when i see the inner part of dll, cwDiodeLaserPIV was declared with class command.
        Why this happen? Can I use it with struct declaration?

      2. When I write down the code at QT, CLSID_ and IID_ part, There were no directory that automatically connected.
        On the Other hand, at VS, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are automatically found by VS
        Say again, at QT, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are not found in list of directory that automatically connected when i write down CLSID_ or IID_. Why this happen? Can 't I use this way at QT?

      ++ I refered https://forum.qt.io/topic/108642/how-to-include-a-com-tlb-library-in-my-c-project/2 and made cpp and header file using dumpcpp. but it seems there aren't enough function in it.

      I am such a vanilla on QT and Programming. So, example code would be very helpful
      Thanks very much...

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 8 Dec 2020, 11:38 last edited by
      #2

      I believe you're looking for this: https://doc.qt.io/qt-5/activeqt-index.html
      Disclaimer: I haven't worked with it.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • B Bean_Noodle
        8 Dec 2020, 10:33

        I am hardly trying to use Laser Control dll file based on .NET on QT.
        I registered dll file on server, made tlb file, and imported it with using command

        @ #import "Litron.Control.CWLasers.tlb" no_namespace named_guids @

        after that, I used this command

        @

        struct cwDiodeLaserPIV;
        cwDiodeLaserPIV Laser=NULL;
        CoInitialize(NULL);
        HRESULT hr = CoCreateInstance(CLSID_cwDiodeLaserPIV, NULL, CLSCTX_INPROC_SERVER, IID__cwDiodeLaserPIV, reinterpret_cast<void
        *>(&Laser));

        @ *I added ActiveQT header file also to use CoCreateInstance

        when i Check whether this code works with this,

        @
        if(SUCCEEDED(hr))
        { qDebug()<<"Calling dll is succeded"; }
        else
        { qDebug()<<"Calling dll is failed"; }
        @

        "Calling dll is failed" is come out.
        But, When i use same code in Visual Studio C++, "Calling dll is succeded" is come out.
        furthermore, even calling dll is succeeded, I couldn't call the function of dll at VS.

        Here are some Questions.

        1. I used struct cwDiodeLaserPIV. because in tlh file, cwDiodeLaserPIV is declared with struct command.
          but actually, when i see the inner part of dll, cwDiodeLaserPIV was declared with class command.
          Why this happen? Can I use it with struct declaration?

        2. When I write down the code at QT, CLSID_ and IID_ part, There were no directory that automatically connected.
          On the Other hand, at VS, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are automatically found by VS
          Say again, at QT, CLSID_cwDiodeLaserPIV and IID__cwDiodeLaserPIV are not found in list of directory that automatically connected when i write down CLSID_ or IID_. Why this happen? Can 't I use this way at QT?

        ++ I refered https://forum.qt.io/topic/108642/how-to-include-a-com-tlb-library-in-my-c-project/2 and made cpp and header file using dumpcpp. but it seems there aren't enough function in it.

        I am such a vanilla on QT and Programming. So, example code would be very helpful
        Thanks very much...

        J Offline
        J Offline
        JonB
        wrote on 8 Dec 2020, 12:04 last edited by JonB 12 Aug 2020, 12:04
        #3

        @Bean_Noodle
        From @kshegunov's link, in the Examples you'll want to look at https://doc.qt.io/qt-5/activeqt-dotnet.html.

        K 1 Reply Last reply 9 Dec 2020, 00:45
        2
        • J JonB
          8 Dec 2020, 12:04

          @Bean_Noodle
          From @kshegunov's link, in the Examples you'll want to look at https://doc.qt.io/qt-5/activeqt-dotnet.html.

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 9 Dec 2020, 00:45 last edited by
          #4

          I'd say https://doc.qt.io/qt-5/activeqt-container.html is a much better hit. As far as I can tell the OP wants to embed a COM object into a Qt application.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          1/4

          8 Dec 2020, 10:33

          • Login

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