Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
A multistring value stores a list of strings. A typical use of a multistring value is demonstrated by the Autorecover MOFs entry in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\CIMOM subkey. This entry holds a list of .mof files that are used to autorecover the CIM repository. The list could have been held in a series of string-valued entries, all stored under a single Autorecover MOFs subkey. However, using a multistring value is more compact and makes programmatic retrieval of the values more convenient. With a multistring entry, there is only one registry entry to read, which makes it more likely that you will retrieve every value. By contrast, storing each value in a separate registry entry requires you to individually read each of those entries. In turn, that increases the likelihood of you missing a value.
Figure 16.3 shows how a registry editor displays a multistring value. You can see that it is simply a list of strings contained under the single Autorecover MOFs entry.
Figure 16.3 Multistring Value as Displayed by a Registry Editor
Multistring Value as Displayed by a Registry Editor
You use the GetMultiStringValue method to retrieve a multistring value. The method takes as one of its parameters a variable that holds the set of strings retrieved. The strings are returned in an array, so you must use a For Each loop in your script to enumerate each of the individual strings in the array.
Listing 16.4 contains a script that retrieves a multistring value from the registry. To carry out this task, the script must perform the following steps:
Listing 16.4 Reading a Multistring-valued Entry
|
|
Send us your feedback | « Previous | Next » |