What is the purpose of a DLL?

This is a discussion on What is the purpose of a DLL? within the C++ Programming forums, part of the General Programming Boards category; I've seen them all over the place, what are they and what do they do?...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    49

    Question What is the purpose of a DLL?

    I've seen them all over the place, what are they and what do they do?
    DJGPP-Complier
    Windows 98-(Shouldn't need to explain)

    I like plants.

  2. #2
    Registered User Azmeos's Avatar
    Join Date
    Jun 2003
    Posts
    65

  3. #3
    Registered User codingmaster's Avatar
    Join Date
    Sep 2002
    Posts
    309
    dll=Dynamic Link Library

    Is a library module, which is not linked as a part of the program and is loaded dynamically at runtime

    You can store your code in dll's

    for example a lot of functions..........

    So you can write a game.....
    and u have u functions in the dll's

    It's faster, when u edit some code, for example you can store you graphics engine for your game in the dll and you need to edit it you edit the function for the dll and don't need to recompile the whole prog..... cause u can load the dll at runtime

  4. #4
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Additionally, multiple programs can use the same DLLs, cutting down disk space required for executables.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  5. #5
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I think that the Windows API (Application Programming Interface) functions are implimented via DLLs. DirectX is probably a bunch of DLLs too.

    My company has 3 or 4 different peices of similar hardware. They all run the same basic program, but each gets a different DLL (and driver). This seems opposite of how DLLs are usually used. Usually, many programs use the same DLL.

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    17
    API uses DLL's, so does DirectX and some other libraries.

  7. #7
    Confused
    Join Date
    Nov 2002
    Location
    Warwick, UK
    Posts
    209
    When you open a DLL file in a text editor, you see a bunch of what looks like crap, but it's actually the functions or your progam under text format. Try something like this and compare it with any DLL on your computer :

    Code:
    // PROGRAM whatsadll.cpp
    // COMPILED AS whatsadll.exe
    
    #include <fstream.h>
    #include <iostream.h>
    #include <conio.c> // For getch();
    
    ifstream fin;
    ofstream fout;
    
    char content;
    
    int main() 
    {
    
    fin.open("whatsadll.exe", ios::in); // Open your own program
    fout.open("whatsadll.dll", ios::out); // Create a dll file for your program
    
    while(fin.get(content))
    {
    cout << content;
    fout << content;
    } /* Grab all data under text form from your program and write it to screen and to a file. */
    
    fin.close();
    fout.close();
    // Don't forget to close your files.
    
    cout << "\n\nProgram executed.";
    char a = getch(); /* To enable a pause to read what's on screen until someone hits a button */
    
    return 0;
    }

    Chances are, what's on screen will not look what's in the file, because you'll have things like \a which will cause a beep when running but will not be written on screen, but will be in the file. Otherwise, they look the same.

    My result :
    Code:
    MZ                @                                       	!L!This program cannot be run in DOS mode.
    
    $       PE  L /= \ 	   8 F  X          `   @  
                                                                
    `                                                                                                                  .text   D     F                `  `.data   P   `  
       J             @  .bss    0   p                       .idata  `        
    T             @  
                                                                                                                     
                  UEPPcA PEPh`A h `A E    Z  
    ]ÉUPPTcA tYA $A uQt"TcA Q 
    QRP  $  $A tTcA Q@QRP  
    $  ]Ít& TcA QQRP  $  $A 
    뎐&    '    UVS1E1ۋ  =     =  sE=  
    te[^] PPj j]  ttރ
    jЃPPjj7     PPj j%  tt
    jPPjj  u  =  t=  
    tnt& USh@     R}
      `A  `A QRP  z  $J  &    '    UjA 1]Ð    UjA 
    ]g&    UEPE    EPh  `A 
    f`A Pj  P  
    EPE    EPh  j j  P  
    jjo  ÉU8EPj]  
    Pj  EfEEfEEPEPEU)Pj 
    j  P#  EPEP  
    ÐU8EPj  P  Ef
    EEfEEPEPEUPj j  
    P  E֍PREԍPRo   U帄
      7  S        MIfȋMIى%  	ȋMIfʋMIى	ʉEUEPDž    PDž    fDžP 
    fDž P_Pj  P  
    h@ EP  E    E    EU)
    9E~YE    EU)9E~9EUЋU
    э    ]ىڍ_
    EEE뛍v EU     xU
    EHfEEHfEEPj  P
      ÐU帄  _  Sh@  j _P      
        MIfȋMIى%  	ȋMIfʋMIى
    	ʉEUE    
    E    EU)9E~   E    EU)
    9EEUЀ8 u fE    Mʉ
    ȍ_M]يE    Mʉȍf 
    EE|EXEPDž    PDž    fDžP fDž P_PjP  P}  
    xÉUEEEPj  
    PP  Ív UEPj  P-  
    UE`A Ef`A Pj  
    P  ÉUE`A `A 
    UPjr  P  ÉU
    (EPjI  PV  UBÉ
    U(EPj  P"  UBwhatsadll.exe whatsadll.dll 
    
    Program executed. U$S  h  jh:@ h pA 
    5 h  jhH@ hpA !5 hpA hPpA 
      ËP# u7v pA Ph0`A _  pA PhpA G  랉h pA 
      hpA 
      hV@ h0`A     E11 ]U
    }  uQ} t'jh pA 
     jhpA  %jhpA   jh 
    pA   3ios PsA    `7ostream 7istream 11fstreambase sA    @@sA P  @8ifstream sA    @`sA P  
    @8ofstream 11_ios_fields Uh  jÉUh  j ÉU   WVSǝ  
    \} tJEPU@PeA @@ BP    @    @    f@  @   @   @    \AEE    
    Em@@ `EAU@cA } u1}
    cA    UPM)cA f
    EȃUXR*  \AE_E    E
    m@@ `E_AUXu@
    @ @ @    @    f@  @   @   @    \A A AEu\B`Džd    
    h_h@H@ ``J} t


    You can read pieces of intelligent things in there by looking carefully The beginning says "This program cannot be run in DOS mode.", the end has "ifstream" and "ostream" in them...
    Last edited by Korhedron; 07-12-2003 at 02:58 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  3. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  4. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 04:29 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21