Class Win32::API
Parent: Object

Methods

call   new  

Classes and Modules

Class Win32::API::Callback
Class Win32::API::Error

Constants

VERSION = 1.0.5   The version of this library, returned as a String

Attributes

dll_name  [R]  The name of the DLL that exports the API function
function_name  [R]  The name of the function
prototype  [R]  The prototype, returned as an array of characters
return_type  [R]  The return type, returned as a single character, P, L, I, V or B

Public Class methods

Creates and returns a new Win32::API object. The function is the name of the Windows function.

The prototype is the function prototype for function. This can be a string or an array of characters. The possible valid characters are ‘I’ (integer), ‘L’ (long), ‘V’ (void), ‘P’ (pointer), or ‘K’ (callback). The default is void (‘V’).

The return argument is the return type for the function. The valid characters are the same as for the prototype. The default is ‘L’ (long).

The dll is the name of the DLL file that the function is exported from. The default is ‘kernel32’.

If the function cannot be found then an API::Error is raised (a subclass of RuntimeError).

Public Instance methods

Calls the function pointer with the given arguments (if any). Note that, while this method will catch some prototype mismatches (raising a TypeError in the process), it is not fulproof. It is ultimately your job to make sure the arguments match the prototype specified in the constructor.

For convenience, nil is converted to NULL, true is converted to TRUE (1) and false is converted to FALSE (0).