In Microsoft System Center Configuration Manager 2007, you read an embedded RegMultiString list from a site control file component or configuration resource by getting the RegMultiStringList SMS_Client_Reg_MultiString_List object from the resources RegMultiStringLists property array.

To read a RegMultiString list

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Using the connection object from step one, get a site control file resource. For more information, see About the Configuration Manager Site Control File.

  3. Get the SMS_Client_Reg_MultiString_List for the required RegMultiString list.

  4. View the RegMultiString list values in the SMS_Client_Reg_MultiString_List ValueStrings array property.

Example

The following example method populates the supplied valueStrings parameter with the value strings of the embedded RegMultiString list identified by the valueName parameter. true is returned if the RegMultiString list is found; otherwise, false is returned.

You can update the embedded RegMultiString list returned from this method by using the method How to Write a Configuration Manager Site Control File Embedded RegMultiString List.

To view code that calls these methods, see How to Read and Write to the Configuration Manager Site Control File by Using Managed Code or see How to Read and Write to the Configuration Manager Site Control File by Using WMI.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Function GetScfRegMultiStringList(resource,  _
		valueName, 					 _
		ByRef valueString) 
	
	dim regMultiStringList	 
			
	If IsNull(resource.RegMultiStringLists) = True Then
			GetScfRegMultiStringList = false
			Exit Function
	End If


	For Each regMultiStringList in resource.RegMultiStringLists
		if UCase(regMultiStringList.ValueName) = UCase(valueName) Then
			' Found the property, so populate values and exit.
			valueName = regMultiStringList.ValueName 
			valueString = regMultiStringList.ValueStrings
			GetScfRegMultiStringList = True
			Exit Function
		End If
	Next

	' Did not find the string list.
	GetScfRegMultiStringList = False
End Function
C#  Copy Code
public bool GetScfRegMultiStringList(
IResultObject resource,
string valueName,
out ArrayList valueStrings)
{
	valueStrings = new ArrayList();

	try
	{
		if (resource.RegMultiStringLists.ContainsKey(valueName))
		{
			valueStrings.AddRange(resource.RegMultiStringLists[valueName]["ValueStrings"].StringArrayValue);
			return true;
	}
}
	catch (SmsException e)
	{
		Console.WriteLine("Couldn't get multi-string list: " + e.Message);
}
	return false;

}

The sample method has the following parameters:

Parameter

Type

Description

Resource

  • Managed: IResultObject

  • VBScript: SWbemObject

The site control file resource that contains the RegMultiString list.

ValueName

  • Managed: Integer

  • VBScript: Integer

The RegMultiString list name. It is obtained from the SMS_Client_Reg_MultiString_List class ValueName property.

ValueStrings

  • Managed: String

  • VBScript: String

The RegMultiString list. It is obtained from the SMS_Client_Reg_MultiString_List class ValueStrings property.

Compiling the Code

The C# example has the following compilation requirements:

Namespaces

System

System.Collections.Generic

System.Collections

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.

See Also


Send comments about this topic to Microsoft.