Module: AMS::Registry

Defined in:
registry.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) delete(full_path, rel_to_su_reg_path = true) Also known as: remove

Delete registry key or value.

Parameters:

  • full_path (String)
  • rel_to_su_reg_path (Boolean) (defaults to: true)

    Whether to acquire path relative to the registry path of the current SketchUp application or from the beginning.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



88
89
90
91
92
# File 'registry.rb', line 88

def delete(full_path, rel_to_su_reg_path = true)
  data = format_path(full_path, rel_to_su_reg_path, true)
  return false unless data
  AMS::C.delete_registry(data[0], data[1], data[2])
end

+ (Array<String>) get_keys(full_path, rel_to_su_reg_path = true)

Get all keys or 'folders' found in the specified registry path.

Parameters:

  • full_path (String)
  • rel_to_su_reg_path (Boolean) (defaults to: true)

    Whether to acquire path relative to the registry path of the current SketchUp application or from the beginning.

Returns:

  • (Array<String>)

Since:

  • 2.0.0



103
104
105
106
107
108
109
110
111
# File 'registry.rb', line 103

def get_keys(full_path, rel_to_su_reg_path = true)
  data = format_path(full_path, rel_to_su_reg_path, false)
  return [] unless data
  keys = AMS::C.get_registry_keys(data[0], data[1])
  for i in 0...keys.length
    keys[i] = keys[i].unpack('C*').pack('U*')
  end
  keys
end

+ (Hash{String => Fixnum, Bignum, String}) get_values(full_path, rel_to_su_reg_path = true)

Get all values or 'files' and their data found in the specified registry path.

Parameters:

  • full_path (String)
  • rel_to_su_reg_path (Boolean) (defaults to: true)

    Whether to acquire path relative to the registry path of the current SketchUp application or from the beginning.

Returns:

  • (Hash{String => Fixnum, Bignum, String})

    { value name => value_data, … }

Since:

  • 2.0.0



121
122
123
124
125
126
127
128
129
130
131
# File 'registry.rb', line 121

def get_values(full_path, rel_to_su_reg_path = true)
  data = format_path(full_path, rel_to_su_reg_path, false)
  return {} unless data
  hash = AMS::C.get_registry_values(data[0], data[1])
  encoded_hash = {}
  hash.each { |k,v|
    v = v.unpack('C*').pack('U*') if v.is_a?(String)
    encoded_hash[k.unpack('C*').pack('U*')] = v
  }
  encoded_hash
end

+ (String, ...) read(full_path, rel_to_su_reg_path = true) Also known as: get

Get data associated with the registry path.

Examples:

Read registry relative to base root:

read('HKEY_CURRENT_USER/Environment/TEMP', false)

Read registry relative to SketchUp registry path:

read('Application/RunCounterSU', true)

Parameters:

  • full_path (String)
  • rel_to_su_reg_path (Boolean) (defaults to: true)

    Whether to acquire path relative to the registry path of the current SketchUp application or from the beginning.

Returns:

  • (String, Fixnum, Bignum, nil)

    Associated data or nil if the specified path is invalid.

Since:

  • 2.0.0



54
55
56
57
58
59
60
# File 'registry.rb', line 54

def read(full_path, rel_to_su_reg_path = true)
  data = format_path(full_path, rel_to_su_reg_path, true)
  return unless data
  res = AMS::C.read_registry(data[0], data[1], data[2])
  res = res.unpack('C*').pack('U*') if res.is_a?(String)
  res
end

+ (Boolean) write(full_path, value, rel_to_su_reg_path = true) Also known as: set

Set data associated with the registry path.

Parameters:

  • full_path (String)
  • value (Object)
  • rel_to_su_reg_path (Boolean) (defaults to: true)

    Whether to acquire path relative to the registry path of the current SketchUp application or from the beginning.

Returns:

  • (Boolean)

    success

Since:

  • 2.0.0



72
73
74
75
76
77
# File 'registry.rb', line 72

def write(full_path, value, rel_to_su_reg_path = true)
  data = format_path(full_path, rel_to_su_reg_path, true)
  return false unless data
  value = value.unpack('U*').pack('C*') if value.is_a?(String)
  AMS::C.write_registry(data[0], data[1], data[2], value)
end