Restored from previous forum. Originally posted by Hi-Toro.
Blitz's DLL support is deliberately very minimal, requiring you to pass data in banks, but you can do just about anything if you're willing to work with it...
· Create your PB DLL with all the procedures looking something like this (always with the same parameters as here):
Code: Select all
ProcedureDLL Example (*in, insize, *out, outsize)
MessageRequester ("DLL Test", "You passed: " + PeekS (*in), #MB_ICONINFORMATION)
EndProcedure
*in is the first bank passed in Blitz's CallDLL (see below), *out is the optional second bank. insize and outsize are the bank sizes, which are automatically passed to the DLL function...
Set Compiler Options to 'Shared DLL' and create the DLL (at the moment, it appears in the PureBasic/Compilers folder as 'purebasic.dll'; this might change I think). Copy it into the same folder as your Blitz source.
· In Blitz, you have to create a bank of the required size, then pass it in your DLL call...
Code: Select all
message$ = "This came from Blitz!"
bank = CreateBank (Len (message$))
CallDLL ("purebasic", "_Example", bank)
FreeBank bank ; DON'T FORGET THIS!
I read that PB no longer requires you to call functions with an underscore now, though haven't tried it yet; you might have to remove that. Although you can pass a second bank with CallDLL, I personally just fill in the *in bank (in the PB code) if I need to pass stuff back.
NOTE: The above code hasn't been tested! I'll check back tomorrow hopefully, in case I've made any stupid mistakes...
--
See ya,
James L Boyd.
http://www.hi-toro.com/
--