A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Contacts
Logo. www.xtramaina.com  
Home Search E-mail
ActiveCompanion Usage/Wrappers/Registry key

ActiveCompanionSet xtras for Macromedia Director

Registry Key Wrapper

Registry key wrapper is provided by VbScriptXtra for handling operations with system registry. It is useful for checking some installation details of ActiveX or OLE objects. Also it can be used for storing user's preferences in system registry. See sample here.

Registry data wrapper is free. You may download ActiveCompanionSet and use the Registry key wrapper. Read the License agreement for more details.

To explicitly create this wrapper use xtra-level CreateWrapper method:
registryKeyWrapper = xtra("VbScriptXtra").CreateWrapper( #RegistryKey )

Newly created Registry key wrapper is not initialized. It has to be opened first.

Once registry key is opened, its named values are available either by name or by index via array-like syntax or GetAt and SetAt methods. Names of values that belong to the registry keys are available through ValueNames property.

To open subordinate key use OpenSubKey method. Names of subordinate keys are available through SubKeyNames property.

The sample looks for applications that start with every system boot right after user login.
vb = xtra("VbScriptXtra")

-- Create wrapper
key = vb.CreateWrapper( #RegistryKey )

-- Open it
key.Open( "HKEY_LOCAL_MACHINE", \
   "SOFTWARE\Microsoft\Windows\CurrentVersionRun", \
   #KEY_READ )
if key.Failed then exit

-- Iterate through values of the key
repeat with i = 1 to key.count
  put key[i]
end repeat

Below is the text shown by key.interface() method:
-- Supported methods:
Open( Parent, strSubKey, symAccessType = #KEY_ALL_ACCESS, bCreateIfMissing = true )
-- Opens the registry key:
-- Use as Parent 'HKEY_CLASSES_ROOT', 'HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE', 'HKEY_USERS', 'HKEY_CURRENT_CONFIG', 'HKEY_PERFORMANCE_DATA'
-- or another RegistryKey wrapper object
-- symAccessType could be: #KEY_ALL_ACCESS, #KEY_READ, #KEY_WRITE
-- or integer bitwise mask (details in MSDN)
--
OpenSubKey( strSubKey, symAccessType = #KEY_ALL_ACCESS, bCreateIfMissing )
CreateSubKey( strSubKeyName )
DeleteSubKey( strSubKeyName )
DeleteValue( strValueName )
--
-- Supported properties:
Count -- returns the number of values for the key
Value -- reads or writes the default value of the key
Value.Count -- returns the number of values for the key
Value[strName] -- reads or writes the named value of the key
Value[nIndex] -- reads or writes the value of the key by index
ValueType[strName] -- returns the data type of named value of the key
ValueType[nIndex] -- returns the data type of the value of the key by index
GetAt( index ) -- same as reading Value[index]
SetAt( index, newValue ) -- same as setting Value[index] to newValue
ValueNames -- returns the list with value names
SubKeyNames -- returns the list with subkey names

-- Other common error handling properties:
Failed -- read only, returns true when the last access to binary data has failed
Succeeded -- read only, returns true when the last access to binary data has succeeded
LastError -- read only, returns the description of the last error if any
LastErrorCode -- read only, returns the code of the last error if any
DebugMode -- read/write value which indicates whether error descriptions will be output right into Messages window

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com