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. Other Discussions
  3. The Weird and The Wonderful
  4. You will be on board if you answer this...

You will be on board if you answer this...

Scheduled Pinned Locked Moved The Weird and The Wonderful
questioncareer
30 Posts 21 Posters 5 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.
  • V VallarasuS

    In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

    Coz, it does not have a main method - He said!

    R Offline
    R Offline
    RafagaX
    wrote on last edited by
    #21

    If i asked this question i would expect this answer: "Both CAN be run, usually a DLL is intended to be used inside another program, that's why normally you don't run a dll directly." But an acceptable answer will be: "DLLs are intended to be used inside programs, while EXEs are programs themselves"

    CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

    1 Reply Last reply
    0
    • K Keith Barrow

      VallarasuS wrote:

      Wait! What would you answer if such question was fired at you?

      Probably the answer they were looking for: An exe requires a fixed entry point, so the loader can work out where start execution. A dll lacks this entry point and therefore the loader can't work out where to start. Other than that, I don't think there are any important differences between an exe and dll, though I could be wrong about that.

      Sort of a cross between Lawrence of Arabia and Dilbert.[^]
      -Or-
      A Dead ringer for Kate Winslett[^]

      P Offline
      P Offline
      patbob
      wrote on last edited by
      #22

      DllMain() [edit] Oh, and check out the /ENTRY option on the linker too.

      We can program with only 1's, but if all you've got are zeros, you've got nothing.

      1 Reply Last reply
      0
      • V VallarasuS

        In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

        Coz, it does not have a main method - He said!

        U Offline
        U Offline
        User 3150502
        wrote on last edited by
        #23

        Also, a DLL doesn't have its own stack, by default. An exe does.

        1 Reply Last reply
        0
        • V VallarasuS

          In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

          Coz, it does not have a main method - He said!

          N Offline
          N Offline
          Naoya Yamaguchi
          wrote on last edited by
          #24

          On Windows, there are cases where you can run a function in a dll with rundll32.exe if the function's takes no args and its return type is void. In other words, the function needs to be as much of a standalone as an exe file. For example, in Powersell, PS> rundll32.exe advapi32.dll,ProcessIdleTasks PS> rundll32.exe user32.dll,LockWorkStation

          C 1 Reply Last reply
          0
          • V VallarasuS

            In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

            Coz, it does not have a main method - He said!

            K Offline
            K Offline
            KP Lee
            wrote on last edited by
            #25

            I confess I didn't read the tag line either. There's a bit of a problem with the semantics of the statement too. I'd agree that you can't start an execution from a dll (from other comments, I'd be wrong about that too, but don't know how), but you definitely do run dll code.

            1 Reply Last reply
            0
            • V VallarasuS

              In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

              Coz, it does not have a main method - He said!

              C Offline
              C Offline
              Chad3F
              wrote on last edited by
              #26

              Well.. technically, if it is the right kind of DLL, you can.. using rundll32.exe (which has been included in at least the last few versions of windows). It lets you execute any entry-point style (think WinMain signature) named code symbol. I guess it was easier for M$ to write a few DLL's with many functions, rather than dozens (or hundreds/thousands) of individual linked EXE's, each for a specific purpose.

              1 Reply Last reply
              0
              • N Naoya Yamaguchi

                On Windows, there are cases where you can run a function in a dll with rundll32.exe if the function's takes no args and its return type is void. In other words, the function needs to be as much of a standalone as an exe file. For example, in Powersell, PS> rundll32.exe advapi32.dll,ProcessIdleTasks PS> rundll32.exe user32.dll,LockWorkStation

                C Offline
                C Offline
                Chad3F
                wrote on last edited by
                #27

                No, they can take args using similar parameters to what WinMain() does. Just that some functions don't use them.

                void CALLBACK
                EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);

                N 1 Reply Last reply
                0
                • C Chad3F

                  No, they can take args using similar parameters to what WinMain() does. Just that some functions don't use them.

                  void CALLBACK
                  EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);

                  N Offline
                  N Offline
                  Naoya Yamaguchi
                  wrote on last edited by
                  #28

                  How would you use rundll32.exe to run that function then?

                  C 1 Reply Last reply
                  0
                  • N Naoya Yamaguchi

                    How would you use rundll32.exe to run that function then?

                    C Offline
                    C Offline
                    Chad3F
                    wrote on last edited by
                    #29

                    You mean how to run one with arguments? They just follow the entry point name (with a space delimiter). An example can be seen on http://support.microsoft.com/kb/164787[^]

                    1 Reply Last reply
                    0
                    • V VallarasuS

                      In an interview an year ago I was asked with this question. When you can 'Run' an exe file, why can't a 'dll'? :confused::confused::confused: I was speechless and said 'it was not intended to be' but to no avail. It was clear the interview panel wasn't prepared for interviewing and I managed to to get the interviewers answer! Wait! What would you answer if such question was fired at you?

                      Coz, it does not have a main method - He said!

                      J Offline
                      J Offline
                      Jorgen Sigvardsson
                      wrote on last edited by
                      #30

                      rundll32.exe, although there are no guarantees that it will work (depending on the DLL's entry points)

                      -- Kein Mitleid Für Die Mehrheit

                      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