Create Qt DLL usable from VB
-
Hi,
I try to create a Qt QLL who can be used from VB script.
I create a lbrary Qt project.
Here is my test.cpp:#include "test.h" DWORD __stdcall DllRegisterServer() { return 0; } DWORD __stdcall DllUnregisterServer() { return 0; } DWORD __stdcall runApp() { return 0; }
Here is my test.h:
#ifndef TEST_H #define TEST_H #include <windows.h> extern "C" DWORD __stdcall DllRegisterServer(); extern "C" DWORD __stdcall DllUnregisterServer(); extern "C" DWORD __stdcall runApp(); #endif // TEST_H
And here is my .h file:
TARGET = testapp TEMPLATE = lib DEFINES += QT_DEPRECATED_WARNINGS CONFIG += c++11 SOURCES += \ test.cpp HEADERS += \ test.h # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
My Dll build with success and with no error.
I can execute the command regsvr32 on my dll with success.
But from my VB script I can't call runApp() function.
Vba error when i call the dll:
My VB script:
Option Explicit Public Declare PtrSafe Function runApp Lib "C:\Users\212721485\Documents\build-Qtdll_test-Desktop_Qt_5_12_0_MinGW_64_bit-Debug\debug\Qtdll_test.dll" () As LongPtr Public Sub testRunApp() Dim lRetCode As LongPtr lRetCode = runApp MsgBox "runApp a retourné le code " & lRetCode, vbOKOnly Or vbSystemModal Or vbInformation, "test de DLL" End Sub
This code works fine in Visual Studio but not in QtCreator... Why ?
-
@Bastien
Your error message, which is shown truncated, shows a full path name, and a "file not found" message:- What is the full path in the message, and does it exist?
- I don't know, but if it is a DLL, and if that DLL does exist but it has dependencies on other DLLs which are not found, might that give the same error message? In which case, maybe the path where it is set to search for additional DLLs is different within VS than outside, and that is why it only works from VS?
-
I build with MinGW on Qt Creator. And when I use DLL, I've the error.
I didn't ask you that. I know that. That's why I asked you:
And when you build it in Visual Studio you are using the MinGW compiler, not the MSVC one, just like you show you are using from Qt Creator, right?
So I asked you what compiler you are using from Visual Studio, not Qt Creator.
Having to make a guess and assuming you use MinGW from Qt Creator but MSVC from VS, I imagine that is precisely the answer to your:
This code works fine in Visual Studio but not in QtCreator... Why ?