Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Reading .dll file qt

    General and Desktop
    2
    8
    207
    Loading More Posts
    • 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.
    • V
      V0rtex last edited by

      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 1 Reply Last reply Reply Quote 0
      • V
        V0rtex @jsulm last edited by

        @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.

        1 Reply Last reply Reply Quote 2
        • jsulm
          jsulm Lifetime Qt Champion @V0rtex last edited by

          @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

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply Reply Quote 1
          • V
            V0rtex @jsulm last edited by

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

            jsulm 1 Reply Last reply Reply Quote 0
            • jsulm
              jsulm Lifetime Qt Champion @V0rtex last edited by

              @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.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              V 1 Reply Last reply Reply Quote 1
              • V
                V0rtex @jsulm last edited by

                @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 ?

                jsulm 1 Reply Last reply Reply Quote 0
                • jsulm
                  jsulm Lifetime Qt Champion @V0rtex last edited by

                  @V0rtex Yes. Does it work?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  V 2 Replies Last reply Reply Quote 1
                  • V
                    V0rtex @jsulm last edited by

                    @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.

                    1 Reply Last reply Reply Quote 2
                    • V
                      V0rtex @jsulm last edited by

                      @jsulm by the way can you look at this topic
                      https://forum.qt.io/topic/122405/unknown-module-s-in-qt-opcua/5

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post