Hi again,
This time I have success. I looked into this wrapper thing, and this is the key to being able to call a dll made in GLBasic. It works and I am elated.
I can't thank you guys enough for your input, this is really totally awesome, and I will be able to build on from here.
Just to share what I have done, so that others may benefit from my effort, and the efforts of all the dll boffs that have posted their stuff on this forum, for people like me to learn from.
The dll source code. This is a project on it's own, and the resulting .dll must be copied into the calling .exe projects ".app" folder.
FUNCTION addem#: number1#, number2#
LOCAL result#
result# = number1# + number2#
RETURN result#
ENDFUNCTION
EXPORT addem
The wrapper source code and the actual program that uses it. It is as Hemlos mentioned, this has to be included in the same project as the calling exe in order for it to work.
Wrapper source
TYPE GLBDLLWRAPPER
INLINE
DECLARE_C_ALIAS(addit, "littledll.dll", "addem", (float, float), float);
ENDINLINE
FUNCTION addem#: num1#, num2#
LOCAL res#
INLINE
if(addit){
PRINT ("DLL FOUND", 20,60);
res = addit(num1, num2);
}else{
PRINT ("DLL NOT FOUND", 20,60);
}
ENDINLINE
RETURN res#
ENDFUNCTION
ENDTYPE
Calling program source code
GLOBAL num1#, num2#, res#
GLOBAL mydll AS GLBDLLWRAPPER
num1# = 123.45
num2# = 234.21
res# = 101.01
res# = mydll.addem(num1#, num2#)
PRINT res#, 20,80
SHOWSCREEN
MOUSEWAIT
I had a lot of reading to do to see how others made their wrappers, and it seems that to embed it into a TYPE is the easiest and best way to go, That's how they seem to do it. And it works perfectly. With the wrapper, the compiled exe can now see the dll, and load it at runtime as is should. And the dll is written in GLBasic, which is what i was after all the time. And it works.
Thanks again for all your help guys. You are the Bomb.
The working exe and dll, as well as their projects are attached to show that it really does work
PS: Edited some typos. :D
[attachment deleted by admin]
Thanks backSpace this it's very usefully, I try sometiago make something whit Dll, but my C++ it's very poor... I think this tutorials can be very good for people whit good skills in C++ and they want try "complex" things whit GLBasic..
Thanks a lot, I will take a look more in deep... :booze: :booze: