Using .NET dll via QT
-
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.
-
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? -
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... -
-
I believe you're looking for this: https://doc.qt.io/qt-5/activeqt-index.html
Disclaimer: I haven't worked with it. -
@Bean_Noodle
From @kshegunov's link, in the Examples you'll want to look at https://doc.qt.io/qt-5/activeqt-dotnet.html. -
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.