Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

About COM and DLLs

Posted on 2000-05-02
5
266 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ standard library based binary archive format 6 104
NOTEPAD++ Meaning of (+) and (-) Icons 6 143
Best IDE for PHP starters 11 134
Need some help with mailto 16 20
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

809 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