Ah I see, it worked for, but you don't know how it works.
Well saying you looked at it 1000 times doesn't mean you don't understand. I've read MS WinAPI manual only a trillion times, but it doesn't mean I didn't understand it (well most of it at least...)
I'll write some quick tips later on, I'm a bit in a hurry right now.
Here we go:
export double add(double number1, double number2)
{
return(double)number1+number2;
}
That is what roach wrote.
'export' makes sure that the function is going to be available to outside programs.
'double' is the data type that the dll function would return back (in GM there is string and real). It is possible that dlls return nothing (in that case they are procedures not functions). BUT GM craches! It needs that the dll returns something to continue! Also, it is used in GML external_define(...).
'add' is the funcion's name. It will also be used in the following gml: external_define(dllname,
functionname,...), make sure it is a valid name, that is avoid special symbols spaces and numbers, ex "45" is wrong while "func45" is right, instead of spaces you could consider using underscores (_) which do work correctly.
Next, there is a list of variables inside round brackets. These arepassed to the dll from GM. Make sure that the data type corresponds to that of GM.
That's all there is to it. I suggest you don't get too ambitious with it. Try learning c++ better then try making your dll.
That's all I can help. The rest is learning by trial and error on your side.
Edited by uuf6429, 18 May 2008 - 05:34 PM.