How can Qt program call a Windows DLL
-
wrote on 4 Oct 2012, 00:57 last edited by
Is it possible for Qt program to call a Windows DLL? Does it support implicit or explicit linking method?
-
wrote on 4 Oct 2012, 01:08 last edited by
Well, what you call a "Qt program" still is a C++ program, except that it's using the Qt Library.
This means you can use use a DLL as you always do in a C++ program: In any .cpp file that needs to call the DLL, include the .h file that corresponds to the DLL. Also link you binary against the import library (.lib for MSVC, .a for MinGW/GCC) for that DLL - how exactly is IDE-dependent. There is nothing Qt-specific about this.
If you want to load a DLL at runtime, you can again do this as in any Windows C++ program: Use LoadLibrary() in combination with GetProcAddress() from the Win32 API. You may also use Qt's QLibrary class for the exactly same purpose, which may be more convenient (and more portable), if you use Qt anyway.
See also:
-
wrote on 5 Oct 2012, 01:18 last edited by
Since I use Qt Creator to manage the project, if I using the implicit method to import the DLL library. How should I modify the project in Qt Creator. Or should I edit the .pro file directly?
2/3