Importing a Managed DLL into Qt C++ Project



  • 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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.