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!!
Printable View
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!!
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.
and where can we find all these functions listed?
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.
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.
Here is a way to determine if an API Function is available.
Code: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
What's wrong with the as Any Keyword, It's really useful I thought.