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. General Programming
  3. C / C++ / MFC
  4. Export functions in an exe

Export functions in an exe

Scheduled Pinned Locked Moved C / C++ / MFC
question
18 Posts 7 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.
  • D Offline
    D Offline
    DarrollWalsh
    wrote on last edited by
    #1

    How do you export functions in an exe? There is no def file to use. What I want to be able to do is use an exe the same way as I do an dll. I want to be able to do the same thing as the excel.exe file. Any ideas? Darroll Not one person lives in the present. Only the past. I can prove it.

    R S G 3 Replies Last reply
    0
    • D DarrollWalsh

      How do you export functions in an exe? There is no def file to use. What I want to be able to do is use an exe the same way as I do an dll. I want to be able to do the same thing as the excel.exe file. Any ideas? Darroll Not one person lives in the present. Only the past. I can prove it.

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

      You just export all funktions the same way you do in a DLL! That's what I've learned from CP! :) Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

      D 1 Reply Last reply
      0
      • R Rickard Andersson20

        You just export all funktions the same way you do in a DLL! That's what I've learned from CP! :) Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

        D Offline
        D Offline
        DarrollWalsh
        wrote on last edited by
        #3

        From what I know about dlls is: If my functions aren't in the def file, I cannot get a pointer to the functoins. Do you not need it in an exe? Also, will I need to export the entire class? If anyone has done this and would care to share please do. Darroll Not one person lives in the present. Only the past. I can prove it.

        R J 2 Replies Last reply
        0
        • D DarrollWalsh

          From what I know about dlls is: If my functions aren't in the def file, I cannot get a pointer to the functoins. Do you not need it in an exe? Also, will I need to export the entire class? If anyone has done this and would care to share please do. Darroll Not one person lives in the present. Only the past. I can prove it.

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

          Darroll wrote: From what I know about dlls is: If my functions aren't in the def file You could be right! I haven't tried exporting functions from an exe yet! :~ <Rickard is hiding him self /> Darroll wrote: Also, will I need to export the entire class? You can't export member functions of an class. You'll need to make them static if so... I hope... PS. This is my message number 700!!!!! Nish, I get closer to you!! :-D Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

          1 Reply Last reply
          0
          • D DarrollWalsh

            How do you export functions in an exe? There is no def file to use. What I want to be able to do is use an exe the same way as I do an dll. I want to be able to do the same thing as the excel.exe file. Any ideas? Darroll Not one person lives in the present. Only the past. I can prove it.

            S Offline
            S Offline
            Stephane Rodriguez
            wrote on last edited by
            #5

            ¿De qué se ríe un tonto? De ver reír a otro tonto.


            She's so dirty, she threw a boomerang and it wouldn't even come back.

            D 1 Reply Last reply
            0
            • S Stephane Rodriguez

              ¿De qué se ríe un tonto? De ver reír a otro tonto.


              She's so dirty, she threw a boomerang and it wouldn't even come back.

              D Offline
              D Offline
              DarrollWalsh
              wrote on last edited by
              #6

              __Stephane Rodriguez__ wrote: ¿De qué se ríe un tonto? De ver reír a otro tonto. Can someone translate this to English? Did you just call me an idiot? Darroll Not one person lives in the present. Only the past. I can prove it.

              S 1 Reply Last reply
              0
              • D DarrollWalsh

                __Stephane Rodriguez__ wrote: ¿De qué se ríe un tonto? De ver reír a otro tonto. Can someone translate this to English? Did you just call me an idiot? Darroll Not one person lives in the present. Only the past. I can prove it.

                S Offline
                S Offline
                Stephane Rodriguez
                wrote on last edited by
                #7

                Ok, too bad you don't guess it. I am saying the discussion you and Rickard are having is making my day. Thanks a lot.


                She's so dirty, she threw a boomerang and it wouldn't even come back.

                D R 2 Replies Last reply
                0
                • S Stephane Rodriguez

                  Ok, too bad you don't guess it. I am saying the discussion you and Rickard are having is making my day. Thanks a lot.


                  She's so dirty, she threw a boomerang and it wouldn't even come back.

                  D Offline
                  D Offline
                  DarrollWalsh
                  wrote on last edited by
                  #8

                  Glad we could make you laugh. Darroll Not one person lives in the present. Only the past. I can prove it.

                  1 Reply Last reply
                  0
                  • S Stephane Rodriguez

                    Ok, too bad you don't guess it. I am saying the discussion you and Rickard are having is making my day. Thanks a lot.


                    She's so dirty, she threw a boomerang and it wouldn't even come back.

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

                    I would be glad if someone could try export a function and tell me if it worked for you! Cheers! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

                    S 1 Reply Last reply
                    0
                    • R Rickard Andersson20

                      I would be glad if someone could try export a function and tell me if it worked for you! Cheers! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

                      S Offline
                      S Offline
                      Stephane Rodriguez
                      wrote on last edited by
                      #10

                      A .def file only eliminates the need to add __declspec(dllexport) attributes alongside with each function you export. Exporting functions does not work for an exe : there is no __declspec(process) attribute. Attempting to export a .exe function using dllexport will just prompt the loading of the .dll file, which does not exist! Export interfaces instead. That's what COM is about.


                      She's so dirty, she threw a boomerang and it wouldn't even come back.

                      S P 3 Replies Last reply
                      0
                      • S Stephane Rodriguez

                        A .def file only eliminates the need to add __declspec(dllexport) attributes alongside with each function you export. Exporting functions does not work for an exe : there is no __declspec(process) attribute. Attempting to export a .exe function using dllexport will just prompt the loading of the .dll file, which does not exist! Export interfaces instead. That's what COM is about.


                        She's so dirty, she threw a boomerang and it wouldn't even come back.

                        S Offline
                        S Offline
                        Simon Steele
                        wrote on last edited by
                        #11

                        Interesting! I used to export functions from my Delphi .exe files but had no idea that I couldn't do it in C++ - I would have had to discover that at somepoint and no doubt tear some hair out in the process. I'll have to go back to having a separate DLL to export the functions. Shame. -- Simon Steele Programmers Notepad - http://www.pnotepad.org/

                        1 Reply Last reply
                        0
                        • S Stephane Rodriguez

                          A .def file only eliminates the need to add __declspec(dllexport) attributes alongside with each function you export. Exporting functions does not work for an exe : there is no __declspec(process) attribute. Attempting to export a .exe function using dllexport will just prompt the loading of the .dll file, which does not exist! Export interfaces instead. That's what COM is about.


                          She's so dirty, she threw a boomerang and it wouldn't even come back.

                          S Offline
                          S Offline
                          Simon Steele
                          wrote on last edited by
                          #12

                          In fact, I have just exported some functions from a .exe in Visual C++ and used them from a DLL! I defined them in a .def file in the .exe project and then used GetProcAddress to import them in the .dll (obviously giving the DLL function the HMODULE of my running .exe). I can send anyone who's interested the project files. -- Simon Steele Programmers Notepad - http://www.pnotepad.org/

                          R D 2 Replies Last reply
                          0
                          • S Simon Steele

                            In fact, I have just exported some functions from a .exe in Visual C++ and used them from a DLL! I defined them in a .def file in the .exe project and then used GetProcAddress to import them in the .dll (obviously giving the DLL function the HMODULE of my running .exe). I can send anyone who's interested the project files. -- Simon Steele Programmers Notepad - http://www.pnotepad.org/

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

                            Simon Steele wrote: I have just exported some functions from a .exe in Visual C++ and used them from a DLL! Lopok everyone! I told ya it was possible! Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++!

                            1 Reply Last reply
                            0
                            • S Simon Steele

                              In fact, I have just exported some functions from a .exe in Visual C++ and used them from a DLL! I defined them in a .def file in the .exe project and then used GetProcAddress to import them in the .dll (obviously giving the DLL function the HMODULE of my running .exe). I can send anyone who's interested the project files. -- Simon Steele Programmers Notepad - http://www.pnotepad.org/

                              D Offline
                              D Offline
                              DarrollWalsh
                              wrote on last edited by
                              #14

                              Simon Steele wrote: I can send anyone who's interested the project files. Send me the project please. Darroll Not one person lives in the present. Only the past. I can prove it.

                              1 Reply Last reply
                              0
                              • D DarrollWalsh

                                From what I know about dlls is: If my functions aren't in the def file, I cannot get a pointer to the functoins. Do you not need it in an exe? Also, will I need to export the entire class? If anyone has done this and would care to share please do. Darroll Not one person lives in the present. Only the past. I can prove it.

                                J Offline
                                J Offline
                                Joel Lucsy
                                wrote on last edited by
                                #15

                                try something like class __declspec(dllexport) ABCD { public: void junk(){} } and if you have a simple function: int _declspec(dllexport) myfunction(); and variables: int _declspec(dllexport) myvariable; Joel Lucsy (jjlucsy@concentric.net)

                                1 Reply Last reply
                                0
                                • S Stephane Rodriguez

                                  A .def file only eliminates the need to add __declspec(dllexport) attributes alongside with each function you export. Exporting functions does not work for an exe : there is no __declspec(process) attribute. Attempting to export a .exe function using dllexport will just prompt the loading of the .dll file, which does not exist! Export interfaces instead. That's what COM is about.


                                  She's so dirty, she threw a boomerang and it wouldn't even come back.

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

                                  If you view depends on Excel you can see that Excel exports functions. Both Exes and DLLs are written in the PE format. The only difference between them is their entry point that either makes them standalone execuatable or not. So you will be able to load and EXE and map function addresses in that EXE at runtime just like it was a DLL.


                                  Build a man a fire, and he will be warm for a day
                                  Light a man on fire, and he will be warm for the rest of his life!

                                  S 1 Reply Last reply
                                  0
                                  • P Paul M Watt

                                    If you view depends on Excel you can see that Excel exports functions. Both Exes and DLLs are written in the PE format. The only difference between them is their entry point that either makes them standalone execuatable or not. So you will be able to load and EXE and map function addresses in that EXE at runtime just like it was a DLL.


                                    Build a man a fire, and he will be warm for a day
                                    Light a man on fire, and he will be warm for the rest of his life!

                                    S Offline
                                    S Offline
                                    Stephane Rodriguez
                                    wrote on last edited by
                                    #17

                                    Paul Watt (kilowatt) wrote: So you will be able to load and EXE and map function addresses in that EXE at runtime just like it was a DLL. Faking the OS by using an EXE as if it was a DLL leads you to unexpected problems. Allright, the vtable is exported and reflected by quickview or other PE viewers. Allright, you may even call a method on it. And if you are lucky, this will even work. Indeed, The process boundary and load context enabled by a standard exe launch is totally different than with a DLL (loaded in the same address space). In other words, the DLL has no context at all. You'll meet soon a guy called time chkesp.c complaining about such a use. In addition, the executable must be designed to be able to respond to your calls. Don't forget that once a process is launched, it is doing something, and is not necessarily able to respond outside calls. That's one of the benefits of using COM instead. The process life cycle raises a bunch of other troubles, but I let you discover them. Good luck!


                                    She's so dirty, she threw a boomerang and it wouldn't even come back.

                                    1 Reply Last reply
                                    0
                                    • D DarrollWalsh

                                      How do you export functions in an exe? There is no def file to use. What I want to be able to do is use an exe the same way as I do an dll. I want to be able to do the same thing as the excel.exe file. Any ideas? Darroll Not one person lives in the present. Only the past. I can prove it.

                                      G Offline
                                      G Offline
                                      Gary R Wheeler
                                      wrote on last edited by
                                      #18

                                      You are a lot better off making your EXE a local COM server, than trying to call in to it as if it were a DLL. COM handles all of the process/context issues for you, and you don't have to worry about calling differences between DLL's, and all that stuff. By the way: it's easy to make an existing application act as a COM server as well as continue its normal activity. Gary R. Wheeler

                                      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