Can anyone tell me what is wrong with this method? I’ve been using this to generate a machine ID, and it was working fine for a long time. Now I have a customer with a windows 7 64 machine and gives and error. I don’t have the exact error but something about a sketchup/tools/win32/registry.rb not found.
Does anyone have a windows 7 machine to test this on?
def computer_system_uuid(testing = false)
if Sketchup.platform == :platform_osx
`ioreg -ad2 -c IOPlatformExpertDevice | xmllint --xpath '//key[.="IOPlatformUUID"]/following-sibling::*[1]/text()' -`
else
require 'win32/registry'
key = 'SYSTEM\HardwareConfig'
uuid = ''
config = ''
hardware = nil
begin
hardware = Win32::Registry::HKEY_LOCAL_MACHINE.open(key)
return '' if hardware.nil?
config = hardware['LastConfig']
rescue StandardError => e
puts e.inspect
else
begin
keys = hardware.keys
puts keys.inspect if testing
uuid = config[/[^{}]+/] if keys.include?(config)
rescue StandardError => e
puts e.inspect
else
uuid
end
ensure
hardware.close unless hardware.nil?
end
uuid
end
end
The "win32" folder is at this path (the first in the $LOAD_PATH array): "C:/Program Files/SketchUp/SketchUp 20nn/Tools/RubyStdLib"
(where nn is the major version number.)
However, the standard library was only distributed with SketchUp 2014 and higher.
I do not get any error running require 'win32/registry' at the console, and afterward Win32 is accessible. (if defined?(Win32) would be the simplest test post require to see that the library was loaded.)