Description

This is a drop-in replacement for the Win32API library currently part of
Ruby's standard library.

Synopsis

require 'win32/api'
include Win32

buf = 0.chr * 260
len = [@buf.length].pack('L')

GetUserName = API.new('GetUserName', 'PP', 'I', 'advapi32')
GetUserName.call(buf, len)

puts buf.strip

Differences between win32-api and Win32API

* Argument order change. The DLL name is now last, not first.
* Removed the 'N' and 'n'. Always use 'L' for longs now.
* Sensible default arguments for the prototype, return type and DLL name.
* Reader methods for the function name, prototype, return type and DLL.
* Removed the support for lower case prototype and return types. Always
  use capital letters.

Developer’s Notes

The current Win32API library that ships with the standard library has been
slated for removal from Ruby 2.0 and it will not receive any updates in the
Ruby 1.8.x branch. I have far too many libraries invested in it to let it
die at this point.

In addition, the current Win32API library was written in the bad old Ruby
1.6.x days, which means it doesn't use the newer allocation framework.
There were several other refactorings that I felt it needed to more closely
match how it was actually being used in practice.

The first order of business was changing the order of the arguments. By
moving the DLL name from first to last, I was able to provide reasonable
default arguments for the prototype, return type and the DLL. Only the
function name is required now.

There was a laundry list of other refactorings that were needed: sensical
instance variable names with proper accessors, removing support for lower
case prototype and return value characters that no one used in practice,
better naming conventions, the addition of RDoc ready comments and,
especially, callback support.

Most importantly, we can now add, modify and fix any features that we feel
best benefit our end users.

Documentation

The source file contains inline RDoc documentation. If you installed
this file as a gem, then you have the docs.

Warranty

This package is provided "as is" and without any express or
implied warranties, including, without limitation, the implied
warranties of merchantability and fitness for a particular purpose.

Known Bugs

None that I'm aware of. Please submit any bug reports to the project page
at http://www.rubyforge.org/projects/win32utils.

Copyright

(C) 2003-2007 Daniel J. Berger
All Rights Reserved

License

Ruby's

Authors

Daniel J. Berger
Park Heesob