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
GetVersion = API.new('GetVersion')
CloseHandle = API.new('CloseHandle', 'L')
GetWindowsDirectory = API.new('GetWindowsDirectory', 'LI', 'I')
GetComputerNameEx = API.new('GetComputerNameEx', 'PPP', 'I', 'kernel32')
GetUserName = API.new('GetUserName',['LPTSTR','LPDWORD'],'BOOL','advapi32')
puts GetVersion.dll_name puts GetVersion.function_name puts GetVersion.prototype puts GetVersion.return_type module Windows
module Foo
API.auto_namespace = 'Windows::Foo'
API.auto_constant = true
API.auto_method = true
API.auto_unicode = true
API.new('GetComputerName', 'PP', 'B')
end
end
module Windows
module Foo
GetComputerName = Win32API.new('kernel32', 'GetComputerName', 'PP', 'I')
GetComputerNameA = Win32API.new('kernel32', 'GetComputerNameA', 'PP', 'I')
GetComputerNameW = Win32API.new('kernel32', 'GetComputerNameW', 'PP', 'I')
def GetComputerName(p1, p2)
GetComputerName.call(p1, p2) != 0
end
def GetComputerNameA(p1, p2)
GetComputerName.call(p1, p2) != 0
end
def GetComputerNameW(p1, p2)
GetComputerName.call(p1, p2) != 0
end
end
end
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
http://www.rubyforge.org/projects/win32utils.
Copyright
(C) 2007-2009, Daniel J. Berger
License
Artistic 2.0
Author
Daniel Berger