Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 03-19-2003, 09:55 AM   #1 (permalink)
Travis Dane
Code Monkey
 
Travis Dane's Avatar
 
Join Date: Feb 2003
Location: Netherlands
Posts: 89
Travis Dane is on a distinguished road
Send a message via ICQ to Travis Dane
Dynamic Link Library's

It's recommended to understand the Static Link Library's Tutorial.
As explained in the Static Link Library's Tutorial as Library can store alot
of information in 1 file and so i won't go further into this, Let's focus on DLL's instead.

DLL's are the same as SLL's but DLL's are called upon during Run-Time instead of Compile-Time,
This means the user will always have to have the DLL's used in the program to run it.
The main advantage of DLL's are that you can replace them with newer versions and thus update your
program without having to re-release it.

Creating DLL's with VC++ 6.0:

Quote:

Create a new Project, Select the Project Type as DLL Dynamic Link Library.
Creating DLL's with VC++ .NET:

Quote:

Create a new Project, Select "Win32 Application" as the Project Type, Select "Application Settings",
Select "DLL" under "Application Type", Select "Empty Project" as "Additional Options".
Now creating a DLL, We will create 2 DLL's to demonstrate how you can replace one with another to
update your Application.

First DLL:

Code:
 #include <iostream> // Include the newest input-output stream header

 using namespace std; // So we won't have to specify this namespace to use it's functions
 
 __declspec(dllexport)void HelloMessage(void) /* Here we define the function, Notice what's before it's definition, This way
                                                 The compiler knows this function is going to be exported by means of a DLL*/
 {
   cout << "Hello World!" << endl; // A nice message
 }
Second DLL:

Code:
 #include <iostream> // Include the newest input-output stream header

 using namespace std; // So we won't have to specify this namespace to use it's functions

 __declspec(dllexport)void HelloMessage(void) /* Here we define the function, Notice what's before it's definition, This way
                                                 The compiler knows this function is going to be exported by means of a DLL*/
 {
	cout << "Hello You!" << endl;  // Another nice message
 }
The Console test Program:

Code:
 #pragma comment(lib,"test.lib") /* We need to include the produced library that came along with the DLL because
                                   the compiler needs the info of the function's at Compile-Time */

 #include <iostream> // Include the newest input-output stream header
 #include <conio.h>

 using namespace std; // So we won't have to specify this namespace to use it's functions

 __declspec(dllexport)void HelloMessage(void); /* The function that is stored in the DLL, We need to define that
											    because the program won't know this function until Linking-Time */

 int main(void) // The program's entry point
 {
	HelloMessage();

	getch();  // Prevent the program from exiting premature
	return 0; // Return succes
 }
Now i've excuted the test program first the first DLL in the same directory wich produced "Hello World!" and then the
second wich produced "Hello You!".

Now DLL's are quite compiler specific so it might be that some compilers don't support it or don't work with this
tutorial, The code in this Tutorial has been tested with VC++ 6.0 and VC++ .NET, Feel free to ask any question about the
tutorial or DLL's.
__________________
OpenGL, DirectX
Travis Dane is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic allocation..urgent help needed!!! kashif Standard C, C++ 4 04-21-2003 08:50 AM
dynamic select menues sde HTML, XML, Javascript, AJAX 5 02-15-2003 09:05 AM
I am a newb, how do you set multiple parts of an image as a link? I sniper baby HTML, XML, Javascript, AJAX 5 02-10-2003 06:40 PM


All times are GMT -8. The time now is 07:36 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting