How do I call Windows DLL functions from Ruby?
c, dll, ruby, windows
Solution
Have a look at `Win32API` stdlib. It's a fairly easy (but arcane) interface to the Windows 32 API, or DLLs.
Documentation is here, some examples here. To give you a taste:
require "Win32API"
def get_computer_name
name = " " * 128
size = "128"
Win32API.new('kernel32', 'GetComputerName', ['P', 'P'], 'I').call(name, size)
name.unpack("A*")
end
Problem
I want to access functions within a DLL using Ruby. I want to use the low-level access of C while still retaining the simplicity of writing Ruby code. How do I accomplish this?