PDA

Click to See Complete Forum and Search --> : api?


xstopx81
Sep 15th, 2000, 01:32 PM
I was just wondering... how the hell do some of these people come up with those weird api functions.. and what is an api function? post some common and rare apis here!!

parksie
Sep 15th, 2000, 01:51 PM
An API function is one that comes as part of an Application Programming Interface, supplied with the product. In most cases (for VB anyway) this is the Win32 API. The functions are stored inside a DLL, and VB loads them at runtime.

xstopx81
Sep 15th, 2000, 03:06 PM
and where can we find all these functions listed?

parksie
Sep 15th, 2000, 03:09 PM
VB comes with a viewer which contains all the VB definitions. For documentation, check out MSDN on http://msdn.microsoft.com/library

Look under "Platform SDK" for the details, organised by category.

parksie
Sep 16th, 2000, 12:45 AM
Yeah, including the dreaded "As Any". I usually use the viewer definitions, then if it doesn't work, go to the header files and write my own.

Sep 16th, 2000, 02:11 AM
Here is a way to determine if an API Function is available.


Private Declare Function LoadLibrary Lib "kernel32" _
Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long

Private Declare Function GetProcAddress Lib "kernel32" _
(ByVal hModule As Long, ByVal lpProcName As String) As Long

Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
Code:


Public Function APIFunctionPresent(ByVal FunctionName _
As String, ByVal DllName As String) As Boolean

Dim bAvail as boolean
bAvail = APIFunctionPresent("GetDiskFreeSpaceExA", "kernel32")

Dim lHandle As Long
Dim lAddr As Long

lHandle = LoadLibrary(DllName)
If lHandle <> 0 Then
lAddr = GetProcAddress(lHandle, FunctionName)
FreeLibrary lHandle
End If

APIFunctionPresent = (lAddr <> 0)

End Function

Sam Finch
Sep 16th, 2000, 12:05 PM
What's wrong with the as Any Keyword, It's really useful I thought.