You are on page 1of 10

VB system programming in

Practice

By

Gouri V

1
Introduction to API
VB - A Serious windows development
tool
What are Windows APIs?

Simple VB API Example

Static and Dynamic linking

What is a DLL?

2
 API declaration and syntax-
[Public | Private] Declare Sub|Function
name Lib “libname” Alias “aliasname”]
[([arglist])] [As type]
Ex.
Public Declare Function GetTickCount _
Lib "kernel32.dll" () As Long
 Where does system locates a DLL?
 DLL disadvantages
 Right choice – A design issue in analysis
phase.

3
Some classic fundas to follow
using API
 Using the Any keyword
Declare Sub CopyMemory Lib “kernel32” _
Alias “RtlMoveMemory” (lpvDest As Any, _
lpvSource As any, ByVal cbCopy As Long)
 UDTs and API calls
Private Declare Sub GlobalMemoryStatus _
Lib "kernel32" (lpBuffer As MEMORYSTATUS)
 Currency Variables
 Window Handles
 Boolean Return Values
 Limitations of VB to use WIN32 API’s

4
Exploring WIN32 API
 Let’s begin to explore…
 Kernel32.dll, user32.dll, gdi32.dll
 Kernel32 overview
 Memory management
 Multithreading
 File operations
 Process control
 Kill running Spyware by Process control
 CreateToolhelp32Snapshot - Takes a snapshot of the
processes and the heaps, modules, and threads used by the
processes; returns handle to snapshot.
 Process32First - Retrieves information about the first process
encountered in a system snapshot.
 Process32Next - Retrieves information about the next process
recorded in a system snapshot.

5
 Test Previous instance of Appliaction by
CreateMutex
Public Declare Function CreateMutex _
Lib "kernel32.dll" _
Alias "CreateMutexA" (lpMutexAttributes As Any, _
ByVal bInitialOwner As Boolean, _
ByVal lpName As String) As Long

 Save, save and save your work often!

6
User32 Calls and Gdi32 Calls

 User32.dll is primarily responsible for, but not
limited to:
 Windows Management

 Menus

 Controls

 Win32 Handles
 Gdi32.dll call are primarily responsible for, but
not limited to, graphical manipulations.
 Windows Messages
 Subclassing

7
More interesting about windows
messages
 Window Procedures
 Window Classes
 Queued Messages
 Message Loops
 Nonqueued Messages

8
Real time system utilities and
challenges
 Remove invalid file extensions
 Find out and remove Spywares on your PC
 Make your PC junk free
 Remove missing softwares
 Delete malicious startup entries
 Scanning cookies

9
?
Thanks!!

10