RosettaCodeData/Task/Call-a-function-in-a-shared.../FreeBASIC/call-a-function-in-a-shared...

24 lines
695 B
Plaintext

' FB 1.05.0 Win64
' Attempt to call Beep function in Win32 API
Dim As Any Ptr library = DyLibLoad("kernel32.dll") '' load dll
If library = 0 Then
Print "Unable to load kernel32.dll - calling built in Beep function instead"
Beep : Beep : Beep
Else
Dim beep_ As Function (ByVal As ULong, ByVal As ULong) As Long '' declare function pointer
beep_ = DyLibSymbol(library, "Beep")
If beep_ = 0 Then
Print "Unable to retrieve Beep function from kernel32.dll - calling built in Beep function instead"
Beep : Beep : Beep
Else
For i As Integer = 1 To 3 : beep_(1000, 250) : Next
End If
DyLibFree(library) '' unload library
End If
Print
Print "Press any key to quit"
Sleep