def def_api(function, params, returns, options={}, &define_block)
      name, aliases = generate_names(function, options)
      boolean = options[:boolean]
      zeronil = options[:zeronil]
      proto = params.respond_to?(:join) ? params.join : params # Convert params into prototype string
      api = Win32::API.new(function, proto.upcase, returns.upcase, options[:dll] || DEFAULT_DLL)

      define_method(function) {|*args| api.call(*args)} # define CamelCase method wrapper for api call

      define_method(name) do |*args, &runtime_block|    # define snake_case method with enhanced api
        return api if args == [:api]
        return define_block[api, *args, &runtime_block] if define_block
        WinGui.enforce_count(args, proto)
        result = api.call(*args)
        result = runtime_block[result] if runtime_block
        return result != 0 if boolean         # Boolean function returns true/false instead of nonzero/zero
        return nil if zeronil && result == 0  # Zeronil function returns nil instead of zero
        result
      end
      aliases.each {|ali| alias_method ali, name }        # define aliases
    end
def def_api(function, params, returns, options={}, &define_block)
      name, aliases = generate_names(function, options)
      boolean = options[:boolean]
      zeronil = options[:zeronil]
      proto = params.respond_to?(:join) ? params.join : params # Convert params into prototype string
      api = Win32::API.new(function, proto.upcase, returns.upcase, options[:dll] || DEFAULT_DLL)

      define_method(function) {|*args| api.call(*args)} # define CamelCase method wrapper for api call

      define_method(name) do |*args, &runtime_block|    # define snake_case method with enhanced api
        return api if args == [:api]
        return define_block[api, *args, &runtime_block] if define_block
        WinGui.enforce_count(args, proto)
        result = api.call(*args)
        result = runtime_block[result] if runtime_block
        return result != 0 if boolean         # Boolean function returns true/false instead of nonzero/zero
        return nil if zeronil && result == 0  # Zeronil function returns nil instead of zero
        result
      end
      aliases.each {|ali| alias_method ali, name }        # define aliases
    end
Defines new method wrappers for Windows API function call:
   - Defines method with original (CamelCase) API function name and original signature (matches MSDN description)
   - Defines method with snake_case name (converted from CamelCase function name) with enhanced API signature
       When the defined wrapper method is called, it checks the argument count, executes underlying API
       function call and (optionally) transforms the result before returning it. If block is attached to
       method invocation, raw result is yielded to this block before final transformations
   - Defines aliases for enhanced method with more Rubyesque names for getters, setters and tests:
       GetWindowText -> window_test, SetWindowText -> window_text=, IsZoomed -> zoomed?

 You may modify default behavior of defined method by providing optional &define_block to def_api.
   If you do so, instead of directly calling API function, defined method just yields callable api
   object, arguments and (optional) runtime block to your &define_block and returns result coming out of it.
   So, &define_block should define all the behavior of defined method. You can use define_block to:
   - Change original signature of API function, provide argument defaults, check argument types
   - Pack arguments into strings for [in] or [in/out] parameters that expect a pointer
   - Allocate string buffers for pointers required by API functions [out] parameters
   - Unpack [out] and [in/out] parameters returned as pointers
   - Explicitly return results of API call that are returned in [out] and [in/out] parameters
   - Convert attached runtime blocks into callback functions and stuff them into [in] callback parameters

 Accepts following options:
   :dll:: Use this dll instead of default 'user32'
   :rename:: Use this name instead of standard (conventional) function name
   :alias(es):: Provides additional alias(es) for defined method
   :boolean:: Forces method to return true/false instead of nonzero/zero
   :zeronil:: Forces method to return nil if function result is zero