help with dll

Blitz3D Forums/Blitz3D Beginners Area/help with dll

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You can't return a pointer * from a library function. You must return an int%.

That int% will be the actual memory address of what you need. Then you must use RtlMoveMemory from kernel32.dll to copy the data at the memory address into a structure that Blitz can read, like a custom type or a bank. Like this:

In your decls file:
; .lib "dibLib.dll"
; Functions to control binary trees
; libTree_Insert%( index$, dato* ):"_libTree_Pointer@8"
; libTree_Get%( index$ ):"_libTree_GetPointer@4"

; .lib "kernel32.dll"
; CopyMemory(Dest*, Src%, Length%):"RtlMoveMemory"

In your Blitz code:
bnk = CreateBank(length) ; This should be big enough to get the data at the memory address
addr = libTree_Get("test")
CopyMemory(bnk, addr, BankSize(bnk))

You could also use a custom type instead of a bank.