Share via


IFPCVendorParametersSet::Value property

Applies to: desktop apps only

The Value property gets or sets the value associated with the parameter name supplied.

This property is read/write.

Syntax

HRESULT put_Value(
  BSTR bstrName,
  VARIANT vValue
);

HRESULT get_Value(
  BSTR bstrName,
  VARIANT *pvValue
);
' Data type: Variant

Property Value( _
  ByVal Name As String, _
  ByVal bstrName As BSTR, _
  ByVal pvValue As VARIANT, _
  ByVal vValue As VARIANT _
) As Variant

Property value

Value associated with the parameter name specified in the Name parameter. The value can be of any subtype defined in the Variant type and is not necessarily a string.

Error codes

These property methods return S_OK if the call is successful; otherwise, they return an error code.

Remarks

This property is read/write.

In C#, the Value property is not available, but parameters can still be added, displayed, and removed. The following code example demonstrates how to add, display, and remove parameters in a vendor parameters set for the policy rule specified by the user in C#.

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.Isa.Interop;
namespace VpsExample
{
    class VendorParameters
    {
        const string VpsGUID = "{20CD9353-223D-455D-9BA6-C88273978CDC}";
        const Int32 Error_AlreadyExists = -2147024713; // 0x800700B7
        private static FPC m_Root;
        private static FPCArray m_Array;
        private static FPCPolicyRule m_Rule;
        private static FPCVendorParametersSets m_VpSets;
        private static FPCVendorParametersSet m_VpSet;
        static void Main(string[] args)
        {
            string RuleName;
            if (args.Length != 1)
            {
                Console.WriteLine("You must type the name of a rule.");
                return;
            }
            RuleName = args[0];
            // Create the root object.
            m_Root = new FPC();
            // Get references to the array object, a
            // policy rule, and its vendor parameters sets collection.
            m_Array = m_Root.GetContainingArray();
            m_Rule = m_Array.ArrayPolicy.PolicyRules.Item(RuleName);
            m_VpSets = m_Rule.VendorParametersSets;
           
            try
            {
                m_VpSet = m_VpSets.Add(VpsGUID, false, false);                
            }
            catch (COMException comEx)
            {
                if (comEx.ErrorCode == Error_AlreadyExists)
                {
                    m_VpSet = m_VpSets.Item(VpsGUID);
                    Console.WriteLine("Using existing VPS");
                }
            }
            // Create parameters in the vendor parameters set.
            m_VpSet["x"] = 1;
            m_VpSet["y"] = 2;
            m_VpSet["z"] = 3;
            // Remove one of the parameters that was just added.
            m_VpSet.RemoveValue("y");
            m_VpSets.Save(false, true);
            // Display the GUIDs of all the vendor parameters sets 
            // associated with the rule followed by their parameters.
            if(m_VpSets.Count > 0)
            {
                Console.WriteLine("The vendor parameters sets for {0} are:", m_Rule.Name);
                foreach(FPCVendorParametersSet vpSet in m_VpSets)
                {
                    Console.WriteLine("VP Set GUID: {0}", vpSet.Name);
                    
                    object[] allNames = (object[])vpSet.AllNames;
                    int index = 1;
                    foreach(string name in allNames)
                    {
                        Console.WriteLine("   {0}. {1} = {2}", index, name, vpSet[name]);
                        index = index + 1;
                    }
                }
                m_VpSets.Remove(VpsGUID);
               // m_VpSets.Save(false, true);
            }
            else
            {
                Console.WriteLine("The collection of vendor parameters sets for the {0} rule is empty.", m_Rule.Name);
            }
            Console.WriteLine("\r\nDone!");
        }
    }
}

For more information about writing code in C# that uses the Forefront TMG administration COM objects, see Getting Started with Administration COM Objects.

Examples

The FPCVendorParametersSet object is used to store data that is defined as {name, value} pairs by using the Value property. The following example stores a parameter named x having a value of 1:

Dim vps As FPCVendorParametersSet
...
vps.Value("x") = 1

The expression "Value("x")" will return the value. The Value property is also the default property. The following examples are equivalent:

vps.Value("x") 
vps("x")

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008 R2, Windows Server 2008 with SP2 (64-bit only)

Version

Forefront Threat Management Gateway (TMG) 2010

IDL

Msfpccom.idl

DLL

Msfpccom.dll

See also

FPCVendorParametersSet

 

 

Build date: 7/12/2010