Windows API and DLLs --- Part-I
An introduction to Windows API and DLLs!!! Part II on PSC!!! Part III coming soon
Original Author: Deepanjan Datta
Code
Windows Full form : API --- Application Programming The Windows API is a collection of routines available to you, So many Windows API routines exist that just about All Windows API routines are stored in files called DLLs. Note : Most DLL files have '.DLL' extension. Any program you write has access to the Windows DLLs. Following are the three most common DLLs : USER32.DLL --- Contains functions that control the GDI32.DLL --- Contains functions that control output KERNEL32.DLL --- Contains functions that control the There are other DLLs such as COMDLG.DLL, MAPI32.DLL, Using the 'Declare' Calling Windows API routines requires a statement called The 'Declare' statement performs the following tasks : Specifies where the API function is located Identifies arguments needed by the API function by number Specifies whether or not the API function returns a value The following format describes the subroutine procedure version Here are two examples : (ByVal lpBuffer As String, ByVal nSize As Long) As Here is an example for calling a simple API routine: This example sounds the speaker Private Sub cmdBeep_Click() 'You need to have a command button named Dim Beeper As Variant Beeper=MessageBeep(1) End Sub
API
Interface
DLL --- Dynamic Link Library
the Visual Basic programmer. In a way, these API routines are like internal
functions of Visual Basic.
anything you can do from Windows, you can do from a Visual Basic application by
calling the appropriate Windows API routine.
Several thousand API routines are available for use.
Windows environment and the user's interface, such as cursors, menus,
windows etc.
to the screen and other devices.
internal Windows hardware and software interface.
NETAPI32.DLL, WINMM.DLL etc.
statement
'Declare'.
and data type
of the 'Declare' statement :
Declare Sub procName Lib
"libName" [Alias "alias"] [([ByVal] var1 [As dataType]
[, [ByVal] var2 [As dataType]] ... [, [ByVal] varN [As dataType])]
Declare Function GetWindowsDirectory Lib
"kernel32" Alias "GetWindowsDirectoryA"_
Long
Declare Sub GetSystemInfo Lib
"kernel32" (lpSystemInfo As SystemInfo)
Private Declare Function MessageBeep Lib "user32"
(ByVal wType As Long) As Long
cmdBeep for this example to work
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.