You are visitor number
Nico's Introduction to API Programming for VB
This is the property of Nico Michael . This information is my original work and may not be reproduced without my prior consent.
2 Starting the API Text
Viewer
Start the API Text Viewer from the Visual Basic Folder
3 Selecting the Win32api Text File
In the WINAPI directory you will find a file WIN32API.TXT
From the file menu choose Load Text File and select WIN32API.TXT
4 Selecting and adding functions of API objects
In the Avaniable Items List Box select the desired Item/Function (Beep)
and press the Add button
Press the Public or Private Option Button to declare the functions publically or privately
5 Creating wrapper functions around the API Calls
In the API Text Viewer in the Select Items text box you highlight the Function generated
and paste it into your code above your wrapper function to declare the API Function
Public Declare Function GetDiskFreeSpace Lib "kernel32"
Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As
String,
lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long,
lpTotalNumberOfClusters As Long) As Long
Function MyDiskFreeSpaceBytes ( sPath as String ) as Double
Dim sDrive As strting
Dim lReturn as Long
Dim I1 ' Sectors per Cluster
Dim I2 ' Bytes per Sector
Dim I3 'Number of Free Clusters
Dim I4 'Total number of Clusters
sDrive=Left(sPath,1) & ":\"
IReturn=GetDiskFreeSpace (I1,I2,I3,I4 )
MyDiskFreeSpaceBytes =I1*I2*I3
End Function
6 Creating a Wrapper Classes
around API calls
Add a Class to you project in the class you decalre the API
Call as Private and
declare your wrapper functions as public
Option Explicit
Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal
dwDuration As Long) As Long
Public Function lBeep(ByVal lFreeq As Long, ByVal lDuration As Long)
lBeep = Beep(lFreeq, lDuration)
End Function
You call the API calls by using object instances of your Class
Return to Nico's Visual Basic Page
(http://www.geocities.com/SiliconValley/Peaks/2852/VB_Charts.html)
This page hosted by Get your own Free Home Page