Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. C / C++ / MFC
  3. Call a function in a DLL

Call a function in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
9 Posts 5 Posters 0 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.
  • R Offline
    R Offline
    Rickard Andersson20
    wrote on last edited by
    #1

    I've created a DLL but how can I call all my functions in that DLL from an EXE? ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

    M L M 3 Replies Last reply
    0
    • R Rickard Andersson20

      I've created a DLL but how can I call all my functions in that DLL from an EXE? ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      MFC or ATL? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      R 1 Reply Last reply
      0
      • R Rickard Andersson20

        I've created a DLL but how can I call all my functions in that DLL from an EXE? ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3
        1. Add lib file produced by DLL project to exe project: Project - Settings - Link - Object/library modules 2) Include exported h-file to your exe project 3) Call Dll functions 4) Ensure that Dll is available in runtime via PATH.
        1 Reply Last reply
        0
        • M Mazdak

          MFC or ATL? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
          Wish You Were Here-Pink Floyd-1975

          R Offline
          R Offline
          Rickard Andersson20
          wrote on last edited by
          #4

          Well, I want to do it with Win32 or MFC. Can you show me in Win32, do that! :) ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

          M 1 Reply Last reply
          0
          • R Rickard Andersson20

            I've created a DLL but how can I call all my functions in that DLL from an EXE? ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

            M Offline
            M Offline
            Masaaki Onishi
            wrote on last edited by
            #5

            Hello, the codegurus around the world. ;) There are at lease two ways to call the functions in DLL. One is to use LoadLibrary and GetProcessAdoc(?) to get the address of the function in DLL. The other way is to implicity call the function in DLL by registering the function name in DLL at def file. Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

            -Masaaki Onishi-

            R 2 Replies Last reply
            0
            • R Rickard Andersson20

              Well, I want to do it with Win32 or MFC. Can you show me in Win32, do that! :) ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

              M Offline
              M Offline
              Mazdak
              wrote on last edited by
              #6

              So you mean you use Win32 Dynamic-Link Library project ro write dll? So first as you now you have to register your dll. include your yourdll_idl.h and yourdll_idl_i.c in your class,then you can use your methos: Is that enough or you need more? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
              Wish You Were Here-Pink Floyd-1975

              1 Reply Last reply
              0
              • M Masaaki Onishi

                Hello, the codegurus around the world. ;) There are at lease two ways to call the functions in DLL. One is to use LoadLibrary and GetProcessAdoc(?) to get the address of the function in DLL. The other way is to implicity call the function in DLL by registering the function name in DLL at def file. Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

                -Masaaki Onishi-

                R Offline
                R Offline
                Rickard Andersson20
                wrote on last edited by
                #7

                Aah! The first way you said was exactly what I was looking for! I post a new message if I get some trouble with the functions... thnx ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

                1 Reply Last reply
                0
                • M Masaaki Onishi

                  Hello, the codegurus around the world. ;) There are at lease two ways to call the functions in DLL. One is to use LoadLibrary and GetProcessAdoc(?) to get the address of the function in DLL. The other way is to implicity call the function in DLL by registering the function name in DLL at def file. Please, don't send me your email about your questions directly. Have a nice day! Sonork - 100.10571:vcdeveloper ;)

                  -Masaaki Onishi-

                  R Offline
                  R Offline
                  Rickard Andersson20
                  wrote on last edited by
                  #8

                  Well, I have a question right now: What kind of type will my varible that holds the address have? I can't declare a: FARPROC myfunc = GetProcAddress(....); and then call my function: myfunc(); ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

                  P 1 Reply Last reply
                  0
                  • R Rickard Andersson20

                    Well, I have a question right now: What kind of type will my varible that holds the address have? I can't declare a: FARPROC myfunc = GetProcAddress(....); and then call my function: myfunc(); ------------------------------------ Rickard Andersson, Suza Computing ICQ#: 50302279 I'm from the winter country SWEDEN! ------------------------------------

                    P Offline
                    P Offline
                    Paul M Watt
                    wrote on last edited by
                    #9

                    Declare a function pointer that has the same prototype of the function that you want to call: Example: // If the DLL function looks like this: int GetWindowText(HWND hWnd, LPTSTR lpString, int nMaxCount); //Define this function pointer: int (*GetWindowTextPtr)(HWND, LPTSTR, int); // Now with your code you can do this. FARPROC myfunc = GetProcAddress(....); GetWindowTextPtr func = (GetWindowTextPtr)myfunc; myfunc(hWnd, szString, count);

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups