Home > Language Reference > Functions > System functions
RemoveLibrary Function
Unloads a shared library.
Syntax
Public Sub RemoveLibrary(ByVal iRefNum As Integer)
| Parameter | Description |
| iRefNum | Reference number for the library to unload. |
Remarks
This function unloads a library previously loaded with the LoadLibrary function and frees up all memory and system resources used by this library. The iRefNum parameter is the reference number of the unloaded library and should be a value returned by thr LoadLibrary function.
Before unloading the library, you should make sure that it is not being used. If the library is a system library like NetLib for example, you should never unload it. On the other hand, if it is not a system library, it should provide a simple way of knowing if it is still being used. For instance, a function in the MathLib library returns the number of applications currently using it. You mustn't unload it unless this number is equal to one.
The following example is an extract the MathLibSinus sample and shows how to load and unload the shared MathLib library. This code should be copied into a module:
Private Const sysLibTrapOpen as Long = &HA801
Private Const sysLibTrapClose as Long = &HA802
Private iRefNum as Integer
Private Declare Function MathLibOpen(ByVal iRef as Integer, ByVal iVersion as Integer) as Integer Trap sysLibTrapOpen
Private Declare Function MathLibClose(ByVal iRef as Integer, ByRef iUseCount as Integer) as Integer Trap sysLibTrapClose
Public Sub MLInit()
Dim e as Integer
iRefNum=LoadLibrary("MathLib","libr","MthL")
e=MathLibOpen(iRefNum,1)
If e<>0 Then Err.Raise 100, "Can't open MathLib"
End Sub
Public Sub MLClose()
Dim e as Integer, u as Integer
If iRefNum<>0 Then
e=MathLibClose(iRefNum,u)
If e<>0 And u=0 Then RemoveLibrary(iRefNum)
End If
End SubYou can also refer to the Shared libraries chapter in the Programmer's Guide for more information on developing shared libraries and communication between HB++ and C.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |