Hi,
I'm currently trying to write a DLL in FreeBASIC for calling from VB.
However, VB seems to load the DLL but cannot find my exported procedure
whatever I try.
This is my FB source (VBTest.bas):
DECLARE FUNCTION AddNumbers STDCALL ( _
BYVAL operand1 AS INTEGER, BYVAL operand2 AS INTEGER ) _
AS INTEGER
FUNCTION AddNumbers STDCALL ( _
BYVAL operand1 AS INTEGER, BYVAL operand2 AS INTEGER ) _
AS INTEGER EXPORT
RETURN operand1 + operand2
END FUNCTION
Compilation using
fbc.exe -dll -export VBTest.bas
results in a file VBTest.dll.
Then my VB code:
Declare Function AddNumbers _
Lib "VBTest.dll" _
(ByVal operand1 As Long, ByVal operand2 As Long) _
As Long
Sub main()
Debug.Print AddNumbers(1, 2)
End Sub
This fails with an error message saying that AddNumbers() cannot be found
in VBTest.dll. Obviously this is a correct error description because when
I
try this:
Sub main()
Dim hLib&, l&
hLib = LoadLibrary("VBTest.dll")
If hLib Then
l = GetProcAddress(hLib, "AddNumbers")
FreeLibrary hLib
End If
End Sub
then LoadLibrary() succeeds but GetProcAddress() returns 0.
I tried some variations like using an ALIAS clause but none of them
helped.
Anybody knows what I'm doing wrong here?
Any help much appreciated.
Wolfgang


|