Spitting DLLs

Started by Charles Pegge, February 04, 2025, 08:50:28 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Charles Pegge


'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!

Zlatko Vid

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"

Theo Gottwald

Interesting feature.
How compatible are these with Powerbasic?

Charles Pegge

#3
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