Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Multistring-valued registry entries are relatively rare in the registry. The Registry Provider does, however, provide the SetMultiStringValue method to enable you to create these entries as needed. Because a multistring can store a list of strings, the SetMultiStringValue method accepts an array of strings as the parameter that determines the values of the entry.
Note that if you use the SetMultiStringValue method to append to an existing multistring-valued entry rather than create a new one, you have to first use the GetMultiStringValue method to retrieve the existing list of strings. This is because SetMultiStringValue overwrites any existing value. For example, suppose you have a multistring value consisting of the following strings:
A B C D
If you use the SetMultiStringValue method, you cannot pass the string "E" as the sole parameter; if you do, the A, B, C, and D strings will be replaced, and the entry will contain this value:
E
To append "E" as an additional string within the value, you must pass an array containing the initial string values as well as the new value:
arrStringValues = Array(
"A
",
"B
",
"C
",
"D
",
"E
") objReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, _ strEntryName,arrStringValues
Listing 16.10 contains a script that creates a multistring-valued entry in the registry subkey created by the script in Listing 16.8. To carry out this task, the script must perform the following steps:
Listing 16.10 Creating Registry Multistring-valued Entries
|
|
Figure 16.6 shows the newly created multistring-valued entry in a registry editor.
Figure 16.6 Newly Created Multistring-valued Entry
Newly Created Multistring-valued Entry
Send us your feedback | « Previous | Next » |