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. QT use DLL from VC6

QT use DLL from VC6

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.3k Views 2 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.
  • Y Offline
    Y Offline
    youfulan2015
    wrote on last edited by
    #1

    I got DLL build by vc6 ,here is the function inside:
    #ifndef DLL_API
    #define DLL_API extern "C" __declspec(dllimport)
    #endif

    #define WIN_API __stdcall

    ....................
    DLL_API void WINAPI HTDrawTopPentagon(HDC hDC,int nCenterX,int nCenterY,COLORREF clr);
    ...................
    in QT I want to use these funtions.
    will it work if I program a QT project like this:
    "
    QLibrary myLib("dll_name");

    typedef int (MyPrototype)(QPixmap ,int,int,QColor);
    MyPrototype myFunction = (MyPrototype) myLib.resolve("HTDrawTopPentagon");
    myFunction test;
    will test work?
    or should i typedef int (*MyPrototype)(HDC ,int,int,COLORREF);in QT?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      msue
      wrote on last edited by
      #2

      The function has no "int" return but "void".

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

        Hi, calling functions in VC6 DLLs is possible, easiest I think is to declare them for example:

        auto HTDrawTopPentagon = (int (WINAPI *)(HDC,int,int,COLORREF)) QLibrary("dll_name").resolve("HTDrawTopPentagon");
        

        then to call it, first you need to have a DC, which I think you cannot get from a QPixmap, to test you can use your MainWindow's winId. Also I think you need to convert from QColor to COLORREF. So perhaps something like this:

        QColor qcolor("red");
        HTDrawTopPentagon(GetDC(HWND(this->winId())),100,100,RGB(qcolor.red(),qcolor.green(),qcolor.blue()));
        

        @msue: Yes I saw that now, but it shouldn't matter.

        Edit: if you're using MinGW compiler, you need to add CONFIG += c++11 to your .pro file.

        1 Reply Last reply
        0

        • Login

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