advanced vb: object oriented programming - dlls

9
OBJECT ORIENTED PROGRAMMING - DLLS Advanced Visual Basic

Upload: robertbenard

Post on 22-May-2015

1.250 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Advanced VB: Object Oriented Programming - DLLs

OBJECT ORIENTED PROGRAMMING - DLLS

Advanced Visual Basic

Page 2: Advanced VB: Object Oriented Programming - DLLs

Overview

A dynamic-link library (DLL) is an executable file that acts as a shared library of functions. Dynamic linking provides a way for a process to call a function that is not part of its executable code. The executable code for the function is located in a DLL, which contains one or more functions that are compiled, linked, and stored separately from the processes that use them. DLLs also facilitate the sharing of data and resources. Multiple applications can simultaneously access the contents of a single copy of a DLL in memory.

Page 3: Advanced VB: Object Oriented Programming - DLLs

Where you see DLLs

DLLs (direct link libraries) are used throughout the Windows operating system.

You can find many DLLs in the c:\Windows\System32 directory on your computer

Page 4: Advanced VB: Object Oriented Programming - DLLs

Why use DLLs?

Research Question:

Why is it advantageous to use DLLs in programming?

Page 5: Advanced VB: Object Oriented Programming - DLLs

Why use DLLs?

DLLs can be used for many purposes including:

• Sharing of resources• Reduction of hard disk storage space requirements• Easier updates of applications

Page 6: Advanced VB: Object Oriented Programming - DLLs

Creation of a DLL

DLLs can be created easily through Visual Basic.

1. Create a new class library

2. Create a public sub in the class library to be accessed by another application

3. Save

4. Click Build DLL

Public Class Class1Public Sub HelloWorld()

MsgBox("Hello world")End Sub

End Class

Page 7: Advanced VB: Object Oriented Programming - DLLs

Use a DLL

DLLs can be used in Visual Basic by adding them as a resource to an application.

1. Click Project

2. Add Resource

3. Browse for the DLL file you created

4. Add code to your application to access the DLL code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim t As New Class1t.HelloWorld()

End Sub

Page 8: Advanced VB: Object Oriented Programming - DLLs

DLLs

Research Question:

Where might you use a DLL?

Page 9: Advanced VB: Object Oriented Programming - DLLs

Additional Information

For additional information about these topics, please the links provided in Blackboard.