func init if(linked("RegistryKey")) // add using module sys.add_use('Microsoft.Win32') // defines an instance of RegistryKey this.setfield('root', d("RegistryKey")) // initialize properties if(linked("NewRegistryKey") and linked("doCreateSubKey")) sys.add_var('rk', 'RegistryKey') end if(linked("onError")) sys.add_use('System.IO') sys.add_use('System.Security') this.setfield('ex', 'ex' + this.id) end end end func make_rk(data) return(this.root + '.CreateSubKey(' + d("Key") + ', RegistryKeyPermissionCheck.' + this.props("PermissionCheck").value + ', RegistryOptions.' + this.props("RegistryOptions").value + ')') end func doCreateSubKey(data) if(linked("RegistryKey")) linked("onError") ? blk.println('try {').inc() : '' if(linked("NewRegistryKey")) blk.println(this.rk, ' = ', make_rk(data), ';') event("onRegistryKey", this.rk) else event("onRegistryKey", make_rk(data)) end if(linked("onError")) blk.dec().println('} catch(IOException ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end end func doDeleteSubKey(data) if(linked("RegistryKey")) linked("onError") ? blk.println('try {').inc() : '' blk.println(this.root, '.DeleteSubKey(', d("Key"), ', ', lower(this.props("ThrowOnMissingSubKey").value), ');') if(linked("onError")) blk.dec().println('} catch(SecurityException ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end end func doDeleteSubKeyTree(data) if(linked("RegistryKey")) linked("onError") ? blk.println('try {').inc() : '' blk.println(this.root, '.DeleteSubKeyTree(', d("Key"), ', ', lower(this.props("ThrowOnMissingSubKey").value), ');') if(linked("onError")) blk.dec().println('} catch(SecurityException ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end end func doDeleteValue(data) if(linked("RegistryKey")) linked("onError") ? blk.println('try {').inc() : '' blk.println(this.root, '.DeleteValue(', d("Value"), ', ', lower(this.props("ThrowOnMissingSubKey").value), ');') if(linked("onError")) blk.dec().println('} catch(SecurityException ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end end func NewRegistryKey if(linked("RegistryKey")) if(linked("doCreateSubKey")) return(this.rk) else return(make_rk()) end end end