'MAKING A DLL
$ dll
$ filename "t.dll"
uses rtl32 'or rtl64
print "loading dll"
function hello(int a) export as string
return a*2 " Hello World!"
end function
sub finish() external
print "unloading dll"
terminate
end sub
'TEST THE DLL
extern lib "t.dll"
declare hello(int a) as string
end extern
print hello(123) '246 Hello World!
Hi Charles
I made few DLLs just to try how work and work well
both 32 or 64 even with old A403 version
Dlls are good if we want to protect our work on easy way ;)
but i never use
$ DLL ..i think
just
$ filename "myDLL.dll"
Interesting feature.
How compatible are these with Powerbasic?
Very similar but more wordy. Since 2007 I've forgotten my PowerBasic. Do you have a simple DLL?
o2 has an internal libmain, and if there are no procedures required when the DLL unloads, the Finish procedure is generated internally. So the DLL code can be shortened to:
$ dll
$ filename "t.dll"
uses rtl32 'or rtl64
'print "loading dll"
function hello(int a) export as string
return a*2 " Hello World!"
end function
PS:
PowerBasic:
'
'https://www.garybeene.com/power/code/gbsnippets0807.htm
'
#Compiler PBWin 9, PBWin 10
#Compile DLL
'
Function LibMain (ByVal hInstance&, ByVal fwdReason&, ByVal lpvReserved&) As Long
'... load/unload code as needed
End Function
'
Function Hello ALIAS "hello" (Byval i As Long) EXPORT As String
Function=Str(i*2) + " Hello World!
End Function