# Win32-api 1.0.0

**URL:** <https://www.ruby-forum.com/t/win32-api-1-0-0/114699>\
**Category:** Ruby\
**Created:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/win32-api-1-0-0/114699 "2007-09-17T13:24:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/win32-api-1-0-0/114699/1 "2007-09-17T13:24:22Z")

</div>

Hi all,

The Win32Utils Team is happy to announce the first release of win32-api.

= What is it?  
This is a replacement for the Win32API library that currently ships with  
the Ruby standard library.

= Quick Synopsis  
require ‘win32/api’  
include Win32

# Typical stuff

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

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

puts buf.strip

# Callback example

EnumWindows = API.new(‘EnumWindows’, ‘KP’, ‘L’, ‘user32’)  
GetWindowText = API.new(‘GetWindowText’, ‘LPI’, ‘I’, ‘user32’)  
EnumWindowsProc = API::Callback.new(‘LP’, ‘I’){ |handle, param|  
buf = “\0” \* 200  
GetWindowText.call(handle, buf, 200);  
puts buf.strip  
buf.index(param).nil? ? true : false  
}

EnumWindows.call(EnumWindowsProc, ‘UEDIT32’)

= What are the advantages over Win32API?

- Added callback support!
- Uses the Ruby 1.8.x allocation framework internally
- Now properly under the Win32 namespace
- Argument order change to the constructor that allows sensible defaults
- Better internal documentation
- It’s actually maintained

= How do I get it?  
There are two gems. Use the “mswin32” gem to install a prebuilt binary  
(built via VC++ 6). Use the “plain” gem to build from source if you have  
a compiler installed.

Or, you can download the source directly from the RubyForge project page  
at [http://www.rubyforge.org/projects/win32utils](http://www.rubyforge.org/projects/win32utils).

Enjoy!

The Win32Utils Team
