DOWNLOAD THE CODE:
Download the Code 47540.zip

The toVBArray method first empties the g_dict object, then populates it with key/value pairs. The keys contain the numeric array subscript numbers. (The keys in a Dictionary object must be unique.) The values contain the elements from the JScript array. The toVBArray method uses the Items method to return the g_dict object's items as a VBArray object.

dictToJSArray. The dictToJSArray method provides a JScript script the ability to convert a Dictionary object into a JScript array. The dictToJSArray method is useful when you're using the component's EnumKey, EnumValues, or EnumValuesAndData method in a JScript script because these methods all return a reference to a Dictionary object.

The dictToJSArray method uses the syntax

dictToJSArray(Dictionary)

where Dictionary is a Dictionary object.

The dictToJSArray method works by calling the g_dict object's Keys method, which returns a VBArray object. Using the toArray method, dictToJSArray converts this object into a JScript array and creates a new Array object to contain that array. Using JScript's for...in statement, the dictToJSArray method iterates through the JScript array, populating it with the key/value pairs. Finally, dictToJSArray returns the resulting JScript array.

Accessing the Registry Made Simple
The Penton.RegObject object addresses the shortcomings inherent in the WMI registry methods and makes it both simple and elegant to read and make changes to the registry, no matter whether you prefer to use VBScript or JScript. Next month, I'll provide some sample VBScript and JScript code so you can get a better feel for how the object works and how to implement it in your own scripts.

Table 1: The Penton.RegObject Object's Properties
Property Description
Result After calling the CheckAccess method, the property will contain True (-1) if the user has access or False (0) if the user doesn't have access.

After calling the ReadValue method, the property will contain the registry value's data.
ValueType After calling ReadValue method, the property will contain the value's data type as a string (e.g., REG_SZ).
EnumDict The property contains the Dictionary object that's populated by the EnumKey, EnumValues, or EnumValuesAndData method.
Table 2: The Penton.RegObject Object's Methods
Method Description
Connect Connects to the StdRegProv provider on a computer. You must call this method before you can use any of the other methods.
CheckAccess Determines whether the user has the permissions necessary to access a registry subkey.
CreateKey Creates a registry key.
DeleteKey Deletes a registry key. Unlike the StdRegProv object's DeleteKey method, this method supports deleting a key that contains subkeys.
DeleteValue Deletes a registry value.
EnumKey Populates a Dictionary object with the subkeys in a registry key.
EnumValues Populates a Dictionary object with a registry key's values and their corresponding data types (e.g., REG_SZ, REG_DWORD).
EnumValuesAndData Populates a Dictionary object with a registry key's values and their contents.
ExistKey Determines whether a registry key exists.
ExistValue Determines whether a registry value exists in a key.
ReadValue Reads a registry value and its data type.
WriteValue Writes a registry value.
toVBArray Converts a JScript array into a VBArray object.
dictToJS ArrayConverts a Dictionary object into a JScript array.
Table 3: Common Parameters for the Penton.RegObject Object's Methods
Parameter Name Description
DefKey Specifies a registry hive. Can be one of the following string values: HKEY_CLASSES_ROOT (or HKCR), HKEY_CURRENT_USER (or HKCU), HKEY_LOCAL_MACHINE (or HKLM), HKEY_USERS, or HKEY_CURRENT_CONFIG.
SubKey NameSpecifies a registry subkey (e.g., SYSTEM\CurrentControlSet\Services).
ValueName Specifies the name of the registry value you want to manipulate.

End of Article

Prev. page     1 2 [3]     next page -->



You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

The introduction of Windows Management Instrumentation (WMI) as a core OS component in Windows 2000 made many administrative scripting tasks far easier, but Microsoft has recognized that registry management still plays an important role in Windows management.

asdf10000

Article Rating 3 out of 5

http://www.scriptingprovip.com/registration/index.cfm

asdf516

Article Rating 3 out of 5

 
 

ADS BY GOOGLE