def return_string( encode = nil )
      lambda do |api, *args|
        WinGui.enforce_count( args, api.prototype, -2)
        args += [string = buffer, string.length]
        num_chars = api.call(*args)
        return nil if num_chars == 0
        string = string.force_encoding('utf-16LE').encode(encode) if encode
        string.rstrip
      end
    end
def return_string( encode = nil )
      lambda do |api, *args|
        WinGui.enforce_count( args, api.prototype, -2)
        args += [string = buffer, string.length]
        num_chars = api.call(*args)
        return nil if num_chars == 0
        string = string.force_encoding('utf-16LE').encode(encode) if encode
        string.rstrip
      end
    end
Procedure that returns (possibly encoded) string as a result of api function call
 or nil if zero characters was returned by api call