The following source code demonstrates at its simplest how to send and receive long integers from a DLL created with PB\DLL, called from various different languages.
The DLL has just one function - PBFUNCTION, which accepts two parameters. The first parameter is the "sent" number, which you provide. When the function is invoked, the DLL will set the second parameter to 2 times the value of the first parameter, so this is the out or "receive" parameter. A better name for this function would be MultiplyByTwo instead of PBFUNCTION.
I would like to specially thank Semen Matusovski and Tom Hanlin for steering me in the right direction with these other bizarre languages
Also a special thanks to Sven Blumenstein for his excellent MASM32 version, cheers!
Please feel free to post demo calling code from other languages!
[This message has been edited by Wayne Diamond (edited September 18, 2001).]
The DLL has just one function - PBFUNCTION, which accepts two parameters. The first parameter is the "sent" number, which you provide. When the function is invoked, the DLL will set the second parameter to 2 times the value of the first parameter, so this is the out or "receive" parameter. A better name for this function would be MultiplyByTwo instead of PBFUNCTION.
I would like to specially thank Semen Matusovski and Tom Hanlin for steering me in the right direction with these other bizarre languages

Also a special thanks to Sven Blumenstein for his excellent MASM32 version, cheers!

Please feel free to post demo calling code from other languages!
Code:
[b]'PBDLL.BAS - The Powerbasic DLL we want to call from other languages[/b] #COMPILE DLL "pbdll.dll" FUNCTION LibMain(BYVAL hInstance AS LONG, _ BYVAL fwdReason AS LONG, _ BYVAL lpvReserved AS LONG) EXPORT AS LONG LibMain = 1 'success! END FUNCTION FUNCTION PBFUNCTION (BYREF NumberIn AS LONG, BYREF NumberOut AS LONG) EXPORT AS INTEGER MSGBOX "PBFUNCTION(" & TRIM$(STR$(NumberIn)) & ", " & TRIM$(STR$(NumberOut)) & ") called!" NumberOut = NumberIn * 2 'Return the number received multiplied by 2 FUNCTION = 1 'Return 1 to indicate the functions success END FUNCTION
[This message has been edited by Wayne Diamond (edited September 18, 2001).]
Comment