Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946

Reading .dll file qt



  • I have qlsate.dll . And how can i use function from it ?

    qlsate32.dll (3)
    Ordinal	Hint	Function	EntryPoint	EntryName
    1	1	qlsate	0x00001330	
    2	2	qlsate_results_data	0x00002000	
    3	0	?qlsrpc@@YGHPAURPCHEADER@@PAURPCSEND@@PAURPCRECV@@@Z	0x00001000	
    

    When i checked it it has a qlsate function.
    In visual studio c#

    [DllImport("qlsate32.dll", CharSet = CharSet.Ansi)]
            public static extern int qlsate(ref ATEHEADER udtAteHeader, ref ATEDATA udtAteData);
    

    using style like this but how can i use it in qt ?



  • @jsulm i got some error but it works now

    this is first prototype

    ATEHEADER mudtAteHeader = *new ATEHEADER();
        ATEDATA mudtAteData = *new ATEDATA();
        mudtAteHeader.sSerialNumber = "demo";
        mudtAteHeader.sCellId = "demo2";
        mudtAteHeader.sDateTime = "demo3";
        mudtAteData.iDataLength = 20;
        mudtAteData.iRecordCount = 50;
        mudtAteData.sDataBuffer = "demo4";
    
        QLibrary myLib("qlsate32.dll");
        myLib.load();
        if(myLib.isLoaded())
        {
            qDebug()<< "Dll is opened.";
            typedef int (*MyPrototype)(ATEHEADER udtAteHeader, ATEDATA udtAteData );
            MyPrototype qlsate = (MyPrototype) myLib.resolve("qlsate");
            if (qlsate)
                qDebug()<<qlsate(mudtAteHeader,mudtAteData);
        }
    

    this is second prototype

    ATEHEADER mudtAteHeader = *new ATEHEADER();
        ATEDATA mudtAteData = *new ATEDATA();
        mudtAteHeader.sSerialNumber = "demo";
        mudtAteHeader.sCellId = "demo2";
        mudtAteHeader.sDateTime = "demo3";
        mudtAteData.iDataLength = 20;
        mudtAteData.iRecordCount = 50;
        mudtAteData.sDataBuffer = "demo4";
        if (QLibrary::isLibrary("qlsate32.dll")) {
              QLibrary lib("qlsate32.dll");
              lib.load();
              if (!lib.isLoaded()) {
                qDebug() << lib.errorString();
              }
              if (lib.isLoaded()) {
    
                typedef int (*FunctionPrototype)(ATEHEADER udtAteHeader, ATEDATA udtAteData);
    
                auto function1 = (FunctionPrototype)lib.resolve("qlsate");
    
                int iRetCode;
                if (function1)
                {
    
                    iRetCode = function1(mudtAteHeader,mudtAteData);
    
                }
    
    
                qDebug()<< iRetCode;
                //if (function2) function2(0, "hello world!");
              }
            }
    

    both of them is working thank you.


  • Lifetime Qt Champion

    @V0rtex Do you also have a header file for that DLL? Is this DLL managed (.Net) or pure C/C++? From where do you have this DLL? Is it 32bit or 64bit?
    If you don't have header file check https://doc.qt.io/qt-5/qlibrary.html



  • @jsulm i don't have header file.
    Its DLL managed.
    And it is 32bit.


  • Lifetime Qt Champion

    @V0rtex If it is managed you will have to use UWP Qt version (managed) and also check https://doc.qt.io/qt-5/qlibrary.html.



  • @jsulm

    QLibrary myLib("qlsate32.dll");
        myLib.load();
        if(myLib.isLoaded())
        {
            qDebug()<< "Dll is opened.";
        }
        typedef int (*MyPrototype)(ATEHEADER udtAteHeader, ATEDATA udtAteData );
        MyPrototype qlsate = (MyPrototype) myLib.resolve("qlsate");
        if (qlsate)
            qDebug()<<qlsate(mudtAteHeader,mudtAteData);
    

    i did something like that.
    is it like you describe right ?


  • Lifetime Qt Champion

    @V0rtex Yes. Does it work?



  • @jsulm i got some error but it works now

    this is first prototype

    ATEHEADER mudtAteHeader = *new ATEHEADER();
        ATEDATA mudtAteData = *new ATEDATA();
        mudtAteHeader.sSerialNumber = "demo";
        mudtAteHeader.sCellId = "demo2";
        mudtAteHeader.sDateTime = "demo3";
        mudtAteData.iDataLength = 20;
        mudtAteData.iRecordCount = 50;
        mudtAteData.sDataBuffer = "demo4";
    
        QLibrary myLib("qlsate32.dll");
        myLib.load();
        if(myLib.isLoaded())
        {
            qDebug()<< "Dll is opened.";
            typedef int (*MyPrototype)(ATEHEADER udtAteHeader, ATEDATA udtAteData );
            MyPrototype qlsate = (MyPrototype) myLib.resolve("qlsate");
            if (qlsate)
                qDebug()<<qlsate(mudtAteHeader,mudtAteData);
        }
    

    this is second prototype

    ATEHEADER mudtAteHeader = *new ATEHEADER();
        ATEDATA mudtAteData = *new ATEDATA();
        mudtAteHeader.sSerialNumber = "demo";
        mudtAteHeader.sCellId = "demo2";
        mudtAteHeader.sDateTime = "demo3";
        mudtAteData.iDataLength = 20;
        mudtAteData.iRecordCount = 50;
        mudtAteData.sDataBuffer = "demo4";
        if (QLibrary::isLibrary("qlsate32.dll")) {
              QLibrary lib("qlsate32.dll");
              lib.load();
              if (!lib.isLoaded()) {
                qDebug() << lib.errorString();
              }
              if (lib.isLoaded()) {
    
                typedef int (*FunctionPrototype)(ATEHEADER udtAteHeader, ATEDATA udtAteData);
    
                auto function1 = (FunctionPrototype)lib.resolve("qlsate");
    
                int iRetCode;
                if (function1)
                {
    
                    iRetCode = function1(mudtAteHeader,mudtAteData);
    
                }
    
    
                qDebug()<< iRetCode;
                //if (function2) function2(0, "hello world!");
              }
            }
    

    both of them is working thank you.




Log in to reply