views:

2520

answers:

10

I want to know the exact difference between the dll and exe file.

+2  A: 

An exe is an executible program whereas A DLL is a file that can be loaded and executed by programs dynamically.

Bhushan
Why somebody gave negative? I would appreciate if I know the reason as well otherwise what is the point of down voting?
Bhushan
Someone probably felt that your answer was not detailed enough.
JesperE
+1  A: 

An EXE is visible to the system as a regular Win32 executable. Its entry point refers to a small loader which initializes the .NET runtime and tells it to load and execute the assembly contained in the EXE. A DLL is visible to the system as a Win32 DLL but most likely without any entry points. The .NET runtime stores information about the contained assembly in its own header.

dll is a collection of resusable functions where as an .exe is an executable which may call these fucntions

rahul
+1  A: 

DLL is In-process component and EXE is out of process component.

adatapost
+17  A: 

EXE:

  1. Its a executable file
  2. There is only single main entry
  3. When a system launches new exe, a new process is created
  4. The entry thread is called in context of main thread of that process.

DLL:

  1. Its a Dynamic Link Library
  2. There are many entry points.
  3. The system loads a DLL into the context of an existing thread

For More Details: http://www.c-sharpcorner.com/Interviews/Answer/Answers.aspxQuestionId=1431&MajorCategoryId=1&MinorCategoryId=1 http://wiki.answers.com/Q/What_is_the_difference_between_an_EXE_and_a_DLL

Reference: http://www.dotnetspider.com/forum/34260-What-difference-between-dll-exe.aspx

Firstthumb
Actually, there is only one Entry point in a DLL if it is an Unmanaged DLL. The question was not .NET specific IMO.
Aamir
The system loads a DLL into an existing PROCESS, not thread. Every DLL in a process can get a notification when a thread starts or stops, via a `LibMain` function.
Daniel Earwicker
Your points 1 and 2 are not 100% correct. Since you can use LoadLibraryEx on an exe or dll that means you can use the GetProcAddress to load an entry point from an exe or a dll.So in that regard both exe and dll files can be dynamically linked and can have any number of entry points.
jussij
A: 

The major exact difference between DLL and EXE that DLL hasn't got an entry point and EXE does. If you are familiar with c++ you can see that build EXE has main() entry function and DLL doesn't :)

faya
Don't think so. Look here http://msdn.microsoft.com/en-us/library/ms682596(VS.85).aspx
Aamir
+24  A: 

I don't know why everybody is answering this question in context of .NET. The question was a general one and didn't mention .NET anywhere.

Well, the major differences are:

EXE

  1. An exe always runs in its own address space i.e., It is a separate process.
  2. The purpose of an EXE is to launch a separate application of its own.

DLL

  1. A dll always needs a host exe to run. i.e., it can never run in its own address space.
  2. The purpose of a DLL is to have a collection of methods/classes which can be re-used from some other application.
  3. DLL is Microsoft's implementation of a shared library.

The file format of DLL and exe is essentially the same. Windows recognizes the difference between DLL and EXE through PE Header in the file. For details of PE Header, You can have a look at this Article on MSDN

Aamir
So, if you wanted you coudl rename and edit the header of the fikle to turn a dll into an exe and vice versa?
RCIX
+4  A: 

This answer was a little more detailed than I thought but read it through.

DLL:
In most cases, a DLL file is a library. There are a couple of types of libraries, dynamic and static - read about the difference. DLL stands for dynamic link library which tells us that it's a part of the program but not the whole thing. It's made of reusable software components (library) which you could use for more than a single program. Bear in mind that it's always possible to use the library source code in many applications using copy-paste, but the idea of a DLL/Static Library is that you could update the code of a library and at the same time update all the applications using it - without compiling.

For example:
Imagine you're creating a Windows GUI component like a Button. In most cases you'd want to re-use the code you've written because it's a complex but a common component - You want many applications to use it but you don't want to give them the source code You can't copy-paste the code for the button in every program, so you decide you want to create a DL-Library (DLL).

This "button" library is required by EXEcutables to run, and without it they will not run because they don't know how to create the button, only how to talk to it.

Likewise, a DLL cannot be executed - run, because it's only a part of the program but doesn't have the information required to create a "process".

EXE:
An executable is the program. It knows how to create a process and how to talk to the DLL. It needs the DLL to create a button, and without it the application doesn't run - ERROR.

hope this helps....

Hannson
+9  A: 

The difference is that an EXE has an entry point, a "main" method that will run on execution.

The code within a DLL needs to be called from another application.

Robin Day
Simple Answer..!!
pvaju896
+1  A: 

The .exe is the program. The .dll is a library that a .exe (or another .dll) may call into.

What sakthivignesh says can be true in that one .exe can use another as if it were a library, and this is done (for example) with some COM components. In this case, the "slave" .exe is a separate program (strictly speaking, a separate process - perhaps running on a separate machine), but one that accepts and handles requests from other programs/components/whatever.

However, if you just pick a random .exe and .dll from a folder in your Program Files, odds are that COM isn't relevant - they are just a program and its dynamically-linked libraries.

Using Win32 APIs, a program can load and use a DLL using the LoadLibrary and GetProcAddress API functions, IIRC. There were similar functions in Win16.

COM is in many ways an evolution of the DLL idea, originally concieved as the basis for OLE2, whereas .NET is the descendant of COM. DLLs have been around since Windows 1, IIRC. They were originally a way of sharing binary code (particularly system APIs) between multiple running programs in order to minimise memory use.

Steve314
+1  A: 

dll and exe's are capable of having entry point...... dont remember multi thread's are available in dll..

Rajakumar