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. Use of a DLL written in Delphi Xe2
QtWS25 Last Chance

Use of a DLL written in Delphi Xe2

Scheduled Pinned Locked Moved Solved General and Desktop
library
7 Posts 4 Posters 2.3k Views
  • 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.
  • ZoptuneZ Offline
    ZoptuneZ Offline
    Zoptune
    wrote on last edited by
    #1

    Hi,

    I have to use functions from a Delphi Xe2 DLL and i'm having some troubles.

    I use QLibrary to dynamically load the DLL at run time. All the functions are found in the DLL by the resolve function but when i call the first function (init function) my app crashes and exit with code 0.

    Maybe the problem comes from my function prototypes definition :

    typedef int (WINAPI *Init_ptr) ();
    

    In the doc :
    "Function Init : integer ; stdcall "
    return 0 if no error

    It's the first time i'm using a library (moreover in Delphi) so i don't know where is the problem.

    Any help/explanation about my problem or about DLL in general will be useful.

    Thx

    jsulmJ 1 Reply Last reply
    0
    • ZoptuneZ Zoptune

      Hi,

      I have to use functions from a Delphi Xe2 DLL and i'm having some troubles.

      I use QLibrary to dynamically load the DLL at run time. All the functions are found in the DLL by the resolve function but when i call the first function (init function) my app crashes and exit with code 0.

      Maybe the problem comes from my function prototypes definition :

      typedef int (WINAPI *Init_ptr) ();
      

      In the doc :
      "Function Init : integer ; stdcall "
      return 0 if no error

      It's the first time i'm using a library (moreover in Delphi) so i don't know where is the problem.

      Any help/explanation about my problem or about DLL in general will be useful.

      Thx

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Zoptune Did you verify that Init_ptr actually points to the function?

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

      ZoptuneZ 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Zoptune Did you verify that Init_ptr actually points to the function?

        ZoptuneZ Offline
        ZoptuneZ Offline
        Zoptune
        wrote on last edited by
        #3

        @jsulm Yes... i think ^^

        typedef int (WINAPI *Init_ptr) ();
        
        Init_ptr Init=NULL;
        if(lib->load()){
            Init=(Init_ptr)lib->resolve("Init");
        }
        if(Init!=NULL){
            int res=Init();  // The app crashes here
        }
        

        Am I doing something wrong ?

        jsulmJ kshegunovK 2 Replies Last reply
        0
        • ZoptuneZ Zoptune

          @jsulm Yes... i think ^^

          typedef int (WINAPI *Init_ptr) ();
          
          Init_ptr Init=NULL;
          if(lib->load()){
              Init=(Init_ptr)lib->resolve("Init");
          }
          if(Init!=NULL){
              int res=Init();  // The app crashes here
          }
          

          Am I doing something wrong ?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Zoptune Looks good. Do you have a stack trace?

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

          1 Reply Last reply
          2
          • ZoptuneZ Zoptune

            @jsulm Yes... i think ^^

            typedef int (WINAPI *Init_ptr) ();
            
            Init_ptr Init=NULL;
            if(lib->load()){
                Init=(Init_ptr)lib->resolve("Init");
            }
            if(Init!=NULL){
                int res=Init();  // The app crashes here
            }
            

            Am I doing something wrong ?

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @Zoptune
            By the way, is there a special reason for not leaving the OS loader to resolve the symbols instead of explicitly doing it with QLibrary?

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            1
            • lemmelL Offline
              lemmelL Offline
              lemmel
              wrote on last edited by lemmel
              #6

              @Zoptune
              Your doc doesn't seems to be helpful.

              Are you sure that this library is operational with your build ? I know that Windows doesn't like to mix library build mixed (one with CRT of Visual Studio 2003, with another library using the crt of Visual Studio 2015).

              Furthermore « crash » is not helpful, because the cause of the crash maybe intern to your library (i.e. you make a good call, but the library doesn't initialize well); don't you have an error message/code ?

              Did you test to load that library with a regular and plain hello world in visual studio ?

              Hope all my questions will help you.

              P.S. : I suppose that you don't have the code of the library but must use it ? Can't you ask the support an C++ example ?

              1 Reply Last reply
              1
              • ZoptuneZ Offline
                ZoptuneZ Offline
                Zoptune
                wrote on last edited by
                #7

                @jsulm
                @kshegunov
                @lemmel

                Thx all for your replys. The problem came from inside the function of the DLL.

                In fact, the library allow me to do some task on a machine.
                This machine is connected to my LAN.

                The problem was that the machine has a fixed IP address and this IP was out of my LAN.
                Had to use Wireshark to find the problem ^^

                Thx for help :)

                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