..


Sponsored Links

Using DLL in C + +

Article written by Stefano Cancedda
Page 1 of 4

A DLL, by definition, is a dynamically loaded library (D ynamic L ink L ibrary). As the library is a file that exports data, resources and code, visible to the programmer when they are imported.
The actual loading of imported items is always done at runtime (execution time), in two fundamental ways:

  • loading (loading) is done before using the resource imported for the first time
  • loading occurs immediately after the resource has been imported, so when the program starts
The use of dynamic libraries offers several operational advantages. Consider a sample library that contains the simple function
 



 int factorial (int base);

 
The efficient code that performs the calculation in question is well known, and the function is used relatively frequently. Without the use of libraries, each program that uses the function should contain within it the prototype and the code in explicit form.
The use of the library allows the easy import of the prototype, while the source code that implements the function is obscure to the programmer (the library is a compiled file, similar to the executable file).

Offers several advantageous properties stand out from the DLL: firstly, the modularity of the library content is independent of any program, it guarantees maximum portability (any program can use the resources offered by simply importing). A DLL is also imported from a program written in a programming language different from that which was complilata, then you gain flexibility.
A DLL is always updated, if you encounter problems in the implementation errors or trivial to implement best, you can rewrite and recompile the only library; to update each of the programs that use it will only need to replace the DLL file called.

The DLLs are shared libraries, it often happens that some very frequent, such as system functions are called from a significant part of programs. In this case there is a considerable saving of physical space because the code is imported into the secondary memory only once. Without a library would be required to have a copy of the resource users for each program.
A program may require the execution of a service only to a limited phase of its operation. Dynamic loading allows a library function is loaded and released at runtime, so you can rationalize and optimize resource utilization, especially in difficult cases where you have limited resources.
Finally, note the code protection: the fact that the DLL is compiled provides the programmer the ability to distribute its product, such a function, ensuring that the user can use it without knowing the implementation, which can then be kept secret.

Structure of a DLL
A DLL has a structure similar to an executable file, divided into three main sections as outlined below.
When the library is loaded and run immediately to the code for 'Entry Point: the DllMain (an EXE file has the entry point function Main).
The rest of the exported file consists of items commonly functions, the programmer can import directly and independently from the main program.

In the same category ...
E-Learning
Ruby and Ruby on Rails (Course) Ruby and Ruby on Rails (Course)
Create software and Web applications with Ruby and RoR. From 39 €.
SQL and Database (Course) SQL and Database (Course)
Create and manage relational databases. From 39 €.
Web Marketing (Course) Web Marketing (Course)
Site promotion, search engines and marketing. From 39 €.
Sponsored Links