Solved

About COM and DLLs

Posted on 2000-05-02
5
265 Views
Last Modified: 2013-12-14
Can anybody tell me what's the difference between EXE and DLL's in C++?

Also, how to identity a COM object?
Please give some examples if possible.
0
Comment
Question by:mcli8
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
ZivKatzir earned 100 total points
ID: 2768768
Hi,
 the basic difference is in the way the operating system treats the two files. When a EXE is loaded into memory it recives from the OP a address space, meaning that every variable, function or source code line stays somwhere in the same virtual memory portion.

Reading between the lines you will understand that runing the same EXE several times will create several proccesses each using a different address space.

This is not so when looking at a DLL. A DLL is loaded into memory only once (the first time it is called by any proccess) then it is MAPPED into the address space of each proccess who uses it. This means that only one memroy portion is actualy ocupied but in every proccess there is a pointer to that same memroy portion.

If the DLL containes any DLL scope variables they are the only part of the DLL which is actually being created in every proccess.

Now you will probably ask, so what so good about it ? The answer is in the difference between a regular library and a DLL. A regular library is compiled with the project which uses it, meaning when the project is compiled to an EXE it containes a copy of the library. The direct result is more disk space in use and more memory occupied when the proccess runs.

On the other hand when using a dll only a link to the library is saved with the project, and when running the dll can be loaded and removed at need.

This approach to DLLs is not unique to VC. This the the Windows conception.
When looking close at a DLL written in VC you will discover it containes a DllMain function instead of main and some other functions which deals with counting how many users a DLL has at a certain point of time. Those function enable the operating system to unload the DLL when it is no longer in use. VC wizard creates these functions for you.


Now about COM objects. Compiling a COM object into a DLL is the moast elegant way to make it evailable to many proccess without taking extra resources.

one thing more - there is a very detailed article in msdn about dll's called : DLLs for Beginners by Debabrata Sarma

0
 
LVL 1

Expert Comment

by:Ik_Khan_Pk
ID: 2768778
Some time DLL's also contains the exe extension, but the main difference is that an exe is a complete program not any reusage of the functions that it is using, but dlls are the collection of compiled function that you can use according to your requirement exactly according to your code.
COM Object can not be called without their interface, You can identity a COM with its interface as IDirectDraw4 is an interface to get the current display mode
0
 

Author Comment

by:mcli8
ID: 2769338
Thanks to ZivKatzir.
But I still don't understand how to use a COM Object from the user's point of view, can anybody give more detail on that or illustrate using an example?
0
 

Author Comment

by:mcli8
ID: 2769348
Thanks to ZivKatzir.
But I still don't understand how to use a COM Object from the user's point of view, can anybody give more detail on that or illustrate using an example?
0
 
LVL 1

Expert Comment

by:ZivKatzir
ID: 2769414
Hi, again.
 I don't realy get what you do not understand. Though I'll try and give you a short description of what is a COM object. If this is not what you meant please refine your question.

A COM object is an object which can let it's container learn it's capabilties at run time. Meaning a COM container can use a series of known methods of the object in order to gradualy learn about all what a specific object is capable of.

From the user point of view this is extreamly comfortable. For instance if I create a COM object I can then put it inside a HTML page and let it be viewed by InternetExplorer with no further programing. (this is possible since I.E. is an ActiveX/COM container)

The same way if you write a C project you can use a COM object written by me over a different OS with no effort, you just add it to user project and let the class wizard wrap it with a class for you.

The exact way in which this magical object shipping is made possible is somewhat more complex but if that what you want I will lead you to the documentation.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question