GFFI - DLLs Done Right
Ever wished that Game Maker's dll system wasn't so limited? Four string arguments not enough? Want to pass an argument that's not a double? Sick of having to compile a dll to wrap a single measly WinAPI function? GFFI might be what you've been looking for.
FFI stands for Foreign Function Interface. In plain English, GFFI essentially adds new "builtin" functions to your game which provide better dll functionality. As well as supporting C-style char* strings and double, it also supports all the other basic C data types such as: char, int, long, float etc. On top of this, you can even work with C arrays and structs from Game Maker - it's possible to both create them and read existing ones returned by a dll. Overall, the functionality provided is similar to Python's ctypes module and .NET's P/Invoke system.
Usage is simple, simply merge the provided file with your game. Empty scripts are provided to keep the syntax checker happy, they also contain documentation. The actual functions are "injected" by the GFFI dll using parts of Gmapi when the game runs. For those of you wondering about performance, it should be close to external_call. There is a small amount of overhead because everything is dynamic, but all the typecasting to and from double is normally manually done anyway in a handwritten wrapper .
Probably the biggest limitation is Game Maker's 16 argument limit. This means most of the time, defining a dll function is limited to functions with 13 or fewer arguments. I can add extended functions using ds_list if the need is there, but most of the time 13 is an excessive amount of arguments anyway. The second "limitation" is that this dll cannot interact with .NET assemblies (which aren't really true dlls anyway). Game Maker is not truly object oriented and so it's essentially impossible to do this. There's a .NET layer dll floating around that can work around the problem by calling a static function in a handwritten wrapper assembly.
A big thanks to GearGOD and Messy Mind for hosting, you can download it >Here<. Source is included, it's licensed under LGPL so it's usable in commercial games.
I hope people find this DLL useful, I used it as an opportunity to learn some C (and then hastily tacked on a C++ library). I've included a few basic examples of usage - it's perfect for making a few WinAPI calls without writing an ad-hoc wrapper dll.
Update: GM8 was released shortly after I posted this. I've added GM8 support to Version 1.1
Edited by Clam, 06 March 2010 - 12:20 AM.