help with dll
Blitz3D Forums/Blitz3D Beginners Area/help with dll
| ||
i need help with call dll, i need call dll with undefined type parameter and before get this undefined type. example beacuse i am spanish and my english is not very good ;) type user field year end type ; Insert one.user = new user one.year = 1977 insertLib "test", one ; This is a call dll ; Get one.user = getLib "test" ; This is a call dll the idea is create a tree indexed for searchs and get/set pointer of types. in de file decls the integer is %, float is # and string is $, but the type? |
| ||
a type parameter should have a * at the end of it. |
| ||
thanks perturbatio, but i cant get pointer this is the code of file decls ; dibLib.decls .lib "dibLib.dll" ; Funciones para controlar arboles binarios libTree_Insert%( index$, dato* ):"_libTree_Pointer@8" libTree_Get*( index$ ):"_libTree_GetPointer@4" the decls libTree_Insert work, but libTree_Get no work, blitz3d show me a error message and crash, i cant use return a pointer? |
| ||
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. |
| ||
this is two problems, copy data and pointers is 32bits but the dll crashed with windows 64bits, the .net show me warning with this, if i can set/get int_64 the solution is easy but i cant, if i copy data the blitz3d app have two or more equals data by call libTree_Get and is very slow with huge data, i need set/get pointers or int64 i need help!!! :( i make a tree indexed in blitz3d if i no found solution, but is posible call a function in blitz3d with undefined type and return this? example for my query -------------------- ; types type fich1 field str$ end type type fich2 field inte% end type ; get data, ??? what type for the function is correct for fich1 and fich2? function get.????( str$, dato.???? ) .... end function ; test test0.fich1 = new test0 test1.fich1 = get( "test", test0 ) test2.fich2 = get( "test", test1 |
| ||
i find solution my problem with undocument functions, this resolve the problem: ; declaration type Type prueba Field nombre$ End Type ; set values test.prueba = New prueba test\nombre$ = "a ver si rula.... works!!" ; get the handle of type and set null, the handle is always 32bits in blitz3d :) ; i call dll with this integer value phandle% = Handle( test ) test = Null ; get type from handle, i get int in call dll and convert this int to type testfinal.prueba = Object.prueba( phandle ) ; test message Print testfinal\nombre$ WaitKey |
| ||
i make the dll, in worklogs find it ;) the dll have the name of dibLib.dll |