Calling functions in DLLs

<< Click to Display Table of Contents >>

Calling functions in DLLs

To call a function in a DLL, it must first be declared with a Declare statement. If the procedure to be called does not return a value, it is declared as a Sub, otherwise as a Function.

Example:

Declare Function GetPrivateProfileString Lib "Kernel32" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer

Declare Sub InvertRect Lib "User32" (ByVal hDC As Integer, aRect As Rectangle)

Once the procedure has been declared, it can be used like any other BASIC function or statement.