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. Importing a Managed DLL into Qt C++ Project
Forum Updated to NodeBB v4.3 + New Features

Importing a Managed DLL into Qt C++ Project

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.2k Views 1 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.
  • K Offline
    K Offline
    kandrey89
    wrote on last edited by
    #1

    Hi,

    I have a "managed" DLL from Newport for a Cornerstoneā„¢ 130 1/8 m Monochromator device.
    How can I import this managed DLL into my Qt C++ project, I prefer to code in Qt Creator? I believe it is a .NET managed DLL.
    I do not have header files or etc, only the single DLL file.
    Also, how do I find out what functions I can call using this DLL and how to call those functions?

    Example code would be appreciated!

    Thanks

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

      Hi, if the DLL is intact then it's (relatively) easy to find what the functions in it are. If you have Qt installed with Visual Studio (not MinGW) then you can do like this:
      (Googled for that Newport/Cornerstone DLL, I'm guessing it's called CyUSB.dll :-)

      Start a Visual Studio developer cmd prompt.
      Cd to where CyUSB.dll is
      TLBEXP CyUSB.dll

      This will give you a CyUSB.tlb which you can #import into your Qt app:
      Start an empty Widgets app in QtCreator. In mainwindow.cpp insert
      @
      #import "c:/DirToTheTlb/CyUSB.tlb"
      @

      Build the app, open the debug build directory (assuming you built in debug mode) and open the cyusb.tlh file in Notepad, you'll see the API.

      To actually call, easiest is to register the CyUSB.dll for COM and use Qt's pretty good COM support.

      1 Reply Last reply
      3
      • M Offline
        M Offline
        MeekTheGeek
        wrote on last edited by
        #3

        Can you provide an example/screenshot of what the contents of the generated .tlh file look like in this case?

        When I tried it (I did use the MinGW version, I got a TLH file with the following contents.

        // Created by Microsoft (R) C/C++ Compiler Version 12.00.31101.0 (b530d70d).
        //
        // d:\program files\new focus\new focus picomotor application\bin\build-trymaketlh-desktop_qt_5_10_1_msvc2013_64bit-debug\debug\cmdlib8742.tlh
        //
        // C++ source equivalent of Win32 type library D:\program files\New Focus\New Focus Picomotor Application\Bin\CmdLib8742.tlb
        // compiler-generated file created 09/26/18 at 10:08:05 - DO NOT EDIT!

        #pragma once
        #pragma pack(push, 8)

        #include <comdef.h>

        namespace CmdLib8742 {

        //
        // Forward references and typedefs
        //

        struct __declspec(uuid("8e4e74aa-7e10-43ad-9995-9c56483422ea"))
        /* LIBID */ __CmdLib8742;

        } // namespace CmdLib8742

        #pragma pack(pop)

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

          Hi, sorry I don't have that .dll but here is one example

          1 Reply Last reply
          2

          • Login

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