You probably know that FFI enables you to use existing and custom native
libraries by writing only Ruby code.
You probably know that a Ruby FFI extension is multi-platform,
multi-implementation and will work without changes on Ruby, JRuby, and
any other Ruby implementation that supports FFI.
You may even know that FFI has been part of JRuby for awhile.
But you may not know that mswin32 and mingw32 binary MRI RubyGems exist
for Windows users and they support both 1.8 and 1.9 environments.
Installation is just a “gem install ffi” away!
While using FFI with the Windows API works great, documentation has been
a bit sparse. We’d like to change this and have started to collect
typical usage examples at
The goal of the wiki page is not to try to cover everything or show off
just puzzler-style code. Rather, we’d like to provide common examples
for the use cases you’ll likely encounter when working with the Windows
API from Ruby. You know, the 80% story.
So what’s the point to all of this?
We’d like more real-world Windows FFI examples and I’m asking for your
help in adding these examples, especially intermediate and advanced
- Show off “core” examples that can be conceptually reused
- Try to keep the C part of the example to less than 35 LOC
- Take relevant shortcuts in favor of highlighting the core idea (eg -
full FFI::Struct definition really needed?)
- Add unnecessary code (e.g. - free) if it hilites fundamental FFI
- Confirm that your C code compiles and runs
- Validate that your Ruby FFI code runs on MRI 1.8, 1.9 and JRuby in
1.8 and 1.9 modes
- Reuse the side-by-side Textile wiki markup sections for your examples
Feel free to edit the wiki page but be warned that the Textile + HTML +
inline CSS is twitchy and non-DRY. I’m pushing the wiki page past what
it was meant to do, but don’t be scared off as GitHub version controls
these pages…it’s really hard to really mess things up.
If you have a cool contribution, but can’t update the wiki page, please
create a http://gist.github.com/ or a http://pastie.org/ or an email and
reply back to this message on our Google Group at
To unsubscribe from this list, please visit: