Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A wrapper for win32-api that simplifies and automates common idioms

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

== Description
   This is a wrapper for Win32::API that simplifies various idioms typically
   used by people who use Win32::API.

== Synopsis
   require 'windows/api'
   include Windows
   # Defaults to 'V' prototype, 'L' return type and 'kernel32' library
   GetVersion ='GetVersion')
   # Defaults to 'L' return type and 'kernel32' library
   CloseHandle ='CloseHandle', 'L')
   # Defaults to 'kernel32' library
   GetWindowsDirectory ='GetWindowsDirectory', 'LI', 'I')
   # Explicitly state every argument
   GetComputerNameEx ='GetComputerNameEx', 'PPP', 'I', 'kernel32')
   # Use long data type names
   GetUserName ='GetUserName',['LPTSTR','LPDWORD'],'BOOL','advapi32')
   # Attributes for possible inspection
   puts GetVersion.dll_name      # 'kernel32'
   puts GetVersion.function_name # 'GetVersion'
   puts GetVersion.prototype     # ['V']
   puts GetVersion.return_type   # 'L'

   # Automatic method generation

   # This code....
   module Windows
      module Foo
         API.auto_namespace = 'Windows::Foo'
         API.auto_constant  = true
         API.auto_method    = true
         API.auto_unicode   = true
         'GetComputerName', 'PP', 'B')

   # Is the same as this code...
   module Windows
      module Foo
         GetComputerName  ='kernel32', 'GetComputerName', 'PP', 'I')
         GetComputerNameA ='kernel32', 'GetComputerNameA', 'PP', 'I')
         GetComputerNameW ='kernel32', 'GetComputerNameW', 'PP', 'I')

         def GetComputerName(p1, p2)
  , p2) != 0

         def GetComputerNameA(p1, p2)
  , p2) != 0

         def GetComputerNameW(p1, p2)
  , p2) != 0

== Advantages over plain Win32::API
   * Automatic constant generation.
   * Automatic definition of ANSI and Unicode method wrappers, including
     special handling for boolean methods.
   * Ability to use more familiar Windows data types, e.g. DWORD.
   * Automatic handling of msvcrt vs msvcrXX via MSVCRT_DLL constant.

== More documentation
   See the RDoc documentation, which should have been automatically generated
   if you installed this as a gem.

== Bugs
   None that I'm aware of. Please submit any bugs to the project page at

== Copyright
   (C) 2007-2009, Daniel J. Berger

== License
   Artistic 2.0

== Author
   Daniel Berger
Something went wrong with that request. Please try again.