?
Solved

About COM and DLLs

Posted on 2000-05-02
5
Medium Priority
?
269 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
[X]
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
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
ZivKatzir earned 300 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

764 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