Ø DLL is a
binary file that provides a library of functions, objects and resources.
Ø All the API
functions are contained in DLL.
Ø Functions present
in DLLs can be linked during execution.
Ø Several
applications can share these function.
Ø Since
linking is done dynamically the functions do not become a part of the
executable file and thus have no effect on the size of the file.
Ø It is
possible to create user defined DLLs.
Ø Features:
a. Sharing of
common code between different executable files.
b. Breaking an
application into component parts to provide a way to easily upgrade
application’s components.
c.
Keeping resource data out of an application’s
executable, but still readily accessible to an application.
Ø Types Of DLL:
MFC Extension DLL:
· Supports
C++ interface.
· The DLL can
export whole classes and the client can construct objects of those classes or
derive classes from them.
· Dynamically
links to the code in the DLL version of the MFC library.
· Extension DLLs are quite small in
size.(simple extension DLL are 10KB in size, which loads quickly)
MFC Regular DLL:
· Can export
only C-style functions.
· It can’t
export C++ classes, member functions, or overloaded functions because every C++
compiler has its own method of decoding names.
· One can choose to statically link or
dynamically link to the MFC library.
· Statically linked regular DLL is about 144KB
in size.
· In case of dynamic linking, the size is
about 17KB .
Ø Steps to create DLL:
For Creating own DLL
file we have, the steps to be followed are:
1. Start Visual C++,
Goto File->New->Select the Win32
Dynamic Link-Library->Specify the Project Name (Like SanDLL). Click on OK button.
2. Choose A simple DLL
project->Click on Finish button.
3.
Go to FileView then select SanDLL.CPP file from source file. Write the
following function just like as follows:
int
_stdcall Decrease(int f)
return(f-1);
}
Save the Current CPP
file.
4. Go to File->New
and select Text File, give the file name as the project name (like SanDLL.def).
Write
the following code in the opening source editor.
LIBRARY
SanDLL
EXPORTS
Decrease
@1
After
that we save and build the project.
5:
Copy the .dll file that you create (Like SanDLL) from Debug folder to the Window’s
System directory.
For
Example.
For
Creating the DLL file we have to follow the following steps:
7:
Write the following code in coding
section and execute your application.
Private
Declare Function Decrease Lib "SanDLL" (ByVal a As Integer) As
Integer
Private
Sub Command1_Click()
Dim
a As Integer
a
= CInt(Text1.Text)
a
= Decrease(a)
Label2.Caption
= "Decremented Value is:" & a
End
Sub
No comments:
Write comments