# File lib/windows/api.rb, line 203
      def initialize(func, proto='V', rtype='L', dll='kernel32')
         @function_name = func
         @prototype     = proto
         @return_type   = rtype == 'B' ? 'I' : rtype
         @dll_name      = dll
         @boolean       = rtype == 'B' ? true : false
         
         begin
            @api = Win32::API.new(func, proto, rtype, dll)
         rescue RuntimeError => err
            raise Error, err
         end
         
         api_a = nil
         api_w = nil
         
         # If the auto_unicode option is set, and the func is not already
         # an explicit ANSI or Unicode function name, generate Win32::API
         # objects for those functions as well. Ignore errors because not
         # all functions have explicit ANSI or Unicode equivalents.
         # 
         if Windows::API.auto_unicode
            begin
               if func[-1].chr != 'A'
                  api_a = Win32::API.new("#{func}A", proto, rtype, dll)
               end
            rescue RuntimeError
            end
         
            begin
               if func[-1].chr != 'W'
                  api_w = Win32::API.new("#{func}W", proto, rtype, dll)
               end
            rescue RuntimeError
            end
         end
         
         # Automatically define a constant matching the function name if the
         # auto_constant option is set.
         # 
         if Windows::API.auto_constant && Windows::API.auto_namespace
            if Windows::API.auto_namespace != 'Windows'
               namespace = class_for(Windows::API.auto_namespace)
            else
               namespace = Windows::API.auto_namespace
            end
            
            namespace.const_set(func, @api)
            
            # Automatically define the explicit ANSI and Unicode functions
            # as constants as well, if appropriate.
            # 
            if Windows::API.auto_unicode
               namespace.const_set("#{func}A", api_a) if api_a
               namespace.const_set("#{func}W", api_w) if api_w
            end
         end
         
         # Automatically define a method in the auto_namespace if the
         # auto_method option is set. The explicit ANSI and Unicode methods
         # are added as well if the auto_unicode option is set to true.
         # 
         if Windows::API.auto_method && Windows::API.auto_namespace
            if proto == 'V'
               proto = ''
            else
               n = 0
               if proto.is_a?(String)
                  proto = proto.split('').map{ |e|
                     n += 1
                     e.downcase + n.to_s
                  }.join(', ')
               else
                  proto = proto.map{ |e|
                     n += 1
                     e.downcase + n.to_s
                  }.join(', ')
               end
            end

            if @boolean
               string = "module \#{Windows::API.auto_namespace}\ndef \#{func}(\#{proto})\n\#{func}.call(\#{proto}) != 0\nend\n"
                  
               if api_a
                  string << %Q{
                     def #{func}A(#{proto})
                        #{func}A.call(#{proto}) != 0
                     end
                  }
               end
               
               if api_w
                  string << %Q{
                     def #{func}W(#{proto})
                        #{func}W.call(#{proto}) != 0
                     end
                  }
               end
               
               string << 'end'
            else
               string = "module \#{Windows::API.auto_namespace}\ndef \#{func}(\#{proto})\n\#{func}.call(\#{proto})\nend\n"
                  
               if api_a
                  string << %Q{
                     def #{func}A(#{proto})
                        #{func}A.call(#{proto})
                     end
                  }
               end
               
               if api_w
                  string << %Q{
                     def #{func}W(#{proto})
                        #{func}W.call(#{proto})
                     end
                  }
               end
               
               string << 'end'
            end
            
            eval(string)
         end
      end