def Main():
  """The main program function.

  Returns:
    bool: True if successful or False if not.
  """
  argument_parser = argparse.ArgumentParser(description=(
      'Extracts a catalog of Windows Registry keys and values.'))

  argument_parser.add_argument(
      'source', nargs='?', action='store', metavar='PATH', default=None,
      help='path of a Windows Registry file.')

  options = argument_parser.parse_args()

  if not options.source:
    print('Source value is missing.')
    print('')
    argument_parser.print_help()
    print('')
    return False

  logging.basicConfig(
      level=logging.INFO, format='[%(levelname)s] %(message)s')

  with open(options.source, 'rb') as file_object:
    try:
      registry_file = dfwinreg_regf.REGFWinRegistryFile()

      registry_file.Open(file_object)
    except IOError:
      registry_file = None

    if not registry_file:
      try:
        registry_file = dfwinreg_creg.CREGWinRegistryFile()

        registry_file.Open(file_object)
      except IOError:
        registry_file = None

    if not registry_file:
      print('Unable to open Windows Registry file.')
      return False

    # Using dfWinReg to determine Windows native key paths if available.
    registry = dfwinreg_registry.WinRegistry()

    key_path_prefix = registry.GetRegistryFileMapping(registry_file)
    registry_file.SetKeyPathPrefix(key_path_prefix)

    root_key = registry_file.GetRootKey()

    output_writer_object = StdoutWriter()

    if not output_writer_object.Open():
      print('Unable to open output writer.')
      print('')
      return False

    try:
      has_results = False
      if root_key:
        collector_object = catalog.CatalogCollector()
        has_results = collector_object.Collect(root_key, output_writer_object)

    finally:
      output_writer_object.Close()

    if not has_results:
      print('No catalog keys and values found.')

  return True