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. How to use a dll function
Forum Updated to NodeBB v4.3 + New Features

How to use a dll function

Scheduled Pinned Locked Moved General and Desktop
20 Posts 5 Posters 12.4k Views 1 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.
  • A Offline
    A Offline
    andre
    wrote on last edited by
    #6

    Well, basically, all you need to do is change the type of target in your .pro file. Take a look at the qmake documentation for details on the different types of targets. However, you also need to make sure you actually export the functions in the right way. It depends on what kind of library you want to export how this works in detail.

    Perhaps you need to explain a bit more detail what you want to achieve. A plugin is not the same as a library you want to link against at compile time, for instance. Volker already gave some options in this.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aldoduju
      wrote on last edited by
      #7

      what I want is to write functions essaduas delphi for Qt, they were written within a dll. I would like to create a dll with these functions and add to my project and make use of functions. they lit externally. understand?

      code
      @function ReadString(lpAddress:DWORD):string;
      var
      i: Cardinal;
      begin
      Result := ''; // Inicia o resultado como nulo, caso não exista nada nesse address.
      for i := 0 to 65535 do begin // Começa o loop
      if PBYTE(lpAddress)^ = 0 then Break; // Se o primeiro byte for 0 (sem caracteres), sai do loop.
      Result := Result + Chr(PBYTE(lpAddress)^); // Retorno da função = Retorno (caso já esteja depois do segundo loop + Caractere resultante do Chr (que retorna um caractere de um código ASCII especificado).
      Inc(lpAddress); // Vai pro próximo caractere/byte.
      end;
      end;

      procedure WriteByte(lpAddress:DWORD;Value:Byte);
      begin
      PBYTE(lpAddress)^ := Value; // O conteúdo do pointer definido no parâmetro "lpAddress", em byte, vai ser igual ao definido no parâmetro "Value".
      end;
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #8

        Ok, so it really is about making use of an external .dll in a Qt application. What about Gerolfs contribution above isn't clear in this context? The point is that you need to make sure you export your application in a way that makes reuse from another application in another language possible. How you do that, is not Qt specific but something you need to look into for delphi.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aldoduju
          wrote on last edited by
          #9

          I'll try to be clear, I would like to write a dll in transposing this procedure for Qt C + + Qt if it is not possible in this case I tereria that make use of it externally.

          one has to create a dll with this procedure implemented in Qt?

          graciously

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #10

            No, you can use external dll's in Qt (or any other C++) applications. However, that dll needs to meet certain criteria, depending on the way you wish to use that dll. Gerolf talked about these criteria, and I suggest you search in dephi resources how to achieve this. The keyword to search for is exporting functions.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aldoduju
              wrote on last edited by
              #11

              and changed the focus, I noticed that it is easier to make the dll in the same Qt.

              I wonder what kind of data to corespondete (Cardinal of Delphi) to Qt?

              graciously

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #12

                Sorry, I don't understand the question.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aldoduju
                  wrote on last edited by
                  #13

                  code in the above described i: = Cardinal.

                  Cardinal is a type of data used in Delphi, I wonder what kind of data coresponding Qt

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    andre
                    wrote on last edited by
                    #14

                    Basically, it is an unsigned 32 bits integer, in the current version of Delphi, if I can trust what a quick Google search tells me. quint32 would be the compatible type in Qt on all platforms.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      goetz
                      wrote on last edited by
                      #15

                      Are you asking for advice on how to port the Delphi/Pascal code to C++/Qt?

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        giesbert
                        wrote on last edited by
                        #16

                        If I understood correctly, you want to use existing Delphi/Pascal code within Qt? Or is it more like what Volker asked?

                        Nokia Certified Qt Specialist.
                        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #17

                          [quote author="aldoduju" date="1300650793"]and changed the focus, I noticed that it is easier to make the dll in the same Qt.

                          I wonder what kind of data to corespondete (Cardinal of Delphi) to Qt?
                          [/quote]
                          From this posting, I gather that aldoduju has changed his mind, and now instead of wanting to use a delphi-build dll in a Qt program, now wants to port his code to Qt and build the dll in Qt.

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            aldoduju
                            wrote on last edited by
                            #18

                            Yes, at first I wanted to use to access the dll made ​​in Delphi, now I want to create this dll
                            code in C + + Qt

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              shisen
                              wrote on last edited by
                              #19

                              hi aldoduju..

                              i also want to create a dll in Qt and call an mfc dll made by msvc..if u had any progress can i get some proper pointers

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                giesbert
                                wrote on last edited by
                                #20

                                hi shisen, what you ask is a new topic. please open a new thread for it. Thanks.

                                Nokia Certified Qt Specialist.
                                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                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