Code Examples
  Home arrow Code Examples arrow Page 2 - Dynamic Link Libraries Inside-Out
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Dynamic Link Libraries Inside-Out
By: Digvijay Chauhan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 56
    2004-09-15

    Table of Contents:
  • Dynamic Link Libraries Inside-Out
  • Advantages and Disadvantages of Using DLLs
  • What Does the DLL Contain?
  • The DLL Entry Point Function: DllMain
  • Types of DLL Linking
  • Resource Only DLLs
  • Dynamic Link Library Redirection
  • Points of Interest
  • Troubleshooting and Common Errors

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Dynamic Link Libraries Inside-Out - Advantages and Disadvantages of Using DLLs


    (Page 2 of 9 )

    Advantages/Disadvantages of Using DLLs

    • Low Memory Usage -- The code and data that we compile in a DLL is shared among the applications that use the DLL. Moreover depending on the way you load a DLL in your application, it’ll be loaded only when needed. Either way it uses less memory.

    The code inside the DLL is resident in the read-only sections and loaded in memory pages marked as read-only. It allows the system to map the DLL into the address space of the processes that uses it. Yes, the DLL is loaded just once, and if a process requests using it, the operating system just maps the DLL to calling application’s address space.

    • Reduced Swapping -- Imagine two processes using the same DLL and one of them finishes its job and exits. But the DLL won’t unload now because the DLL manages its lifetime by keeping a reference count of the processes that use it. It unloads itself as soon as the reference count drops to zero, a stage where any process is not using it.
     
    Now assume that a new process begins and requests the system to load the same DLL that is now being used by an already running application. So what happens next? Does the system load the DLL again? No! Certainly not. The currently loaded DLL has all its code and data in memory and the system just maps this to the address space of the new process and it works just fine. So it saved a lot of work on the operating system’s part, which would have involved reading the DLL code and data from the disk file.

    • Use as an Off the Shelf Component -- Once you’ve built a DLL after proper design, you may use it in any application you find suitable. Think of it as a component that you’re very sure about in terms of functionality. You just drop this in one of your projects, and it should work fine.

    Imagine a DLL implementation that provides all the calculations which are required while developing a graphics rendering application. This DLL can now be used in any project that requires these calculations.

    • Interoperable between Languages -- The DLL written in one language might be used in applications written in a different language. It’s common for developers to write optimized routines in assembler and package them as a DLL and later call them from a C++ or Visual Basic application.

    On a developer's part, it’s unfortunate that most of the languages provide support for using the DLLs but only a few let one create them. But still it’s a benefit that one may use a DLL written by someone else. This doesn’t only allows one to focus on the business logic and be away from the hassle of writing some complex routines, but also freedom from the debugging and testing of this module. Imagine performing I/O in a Visual Basic application using a DLL that uses the inportb and outportb instructions from the native CRT library. DLLs make writing such interoperable code a breeze.

    • Can Provide After Market Support -- What if you find after shipping a product that it needed some alterations. It’s a troublesome job to rebuild and redistribute the whole application to all the buyers. But it can be avoided if you design your application in well-defined modules packaged into DLLs. You could just make the DLL available as an upgrade to the whole package and the product should work fine. Read on the disadvantages which might fake this point, but I’ll say that it’s just the way you write your code.

    • The DLL Hell -- It’s the biggest trouble that DLLs sometimes cause. You might have encountered situations where a program fails to load, displaying some error such as “The ordinal abc could not be located in the dynamic-link library xyz.dll.”  Or you install a new application and some other programs starts to malfunction or even fails to load. These are just the symptoms of DLL hell on your machine. The most common source being a irresponsibly made install program that doesn't check versions before copying DLLs into the system directory. This may also happen if a newer DLL has replaced an older one and has major changes in the functionality. DLLs should be backward-compatible, but it's the proper design of the application that ensures backward compatibility and in most cases is hard to achieve.

    More Code Examples Articles
    More By Digvijay Chauhan


       · hi,Its Ravi Verma from India. This article on dll is really a master piece....
       · hi,Its Ravi Verma from India. This article on dll is really a master piece....
       · hey you indian,you have my job. stop outsourcing now
       · Where are the pictures in this article?Best RegardsHolland
       · I Jon't have a job either
       · Companies hire only talented deserving people......
       · Yes very True,That's why 'I QUIT' and don't have a job. They don't know how to...
       · the article could have been better if mapping of dll to address space have been...
       · Great article, thanks for sharing...
     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT