Share via


IWMSNamedValues.Item (Visual Basic .NET)

banner art

Previous Next

IWMSNamedValues.Item (Visual Basic .NET)

The Item property specifies and retrieves a name-value pair from the IWMSNamedValues collection.

Syntax

  IWMSNamedValues
  (
  varIndex As Variant).Value = Variant

IWMSNamedValue = IWMSNamedValues.Item(
  varIndex As Variant
)

Parameters

varIndex

[in] Variant containing either the name portion of the name-value pair or an index into the collection. The maximum size of a name is 250 characters.

Property Value

This property returns an IWMSNamedValue object. You can use this object to retrieve the name-value pair.

If this property fails, it returns an error number.

Return code Number Description
DISP_E_BADINDEX 0x8002000B varIndex is an invalid index location.

Remarks

If you supply a name and no matching name is found in the collection, the Item method creates a new IWMSNamedValue object containing the name and value you specify. If the name-value pair already exists, the value portion is updated.

If you enter an integer index and no matching index is found in the collection, the Item method returns an error.

Example Code

Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices

Private Sub GetProperty()

    ' Declare variables.
    Dim Server As WMSServer
    Dim NamedValues As IWMSNamedValues
    Dim NamedValue As IWMSNamedValue
    Dim strName As String
    Dim varIndex As Object
    Dim varValue As Object

Try
    ' Create the WMSServer object.
    Server = New WMSServer()

    ' Retrieve the IWMSNamedValues object
    ' containing descriptive information about the server.
    NamedValues = Server.Properties

    ' Retrieve information about each name-value pair.
    For i = 0 To NamedValues.Count – 1

        NamedValue = NamedValues.Item(i)

        ' Retrieve the name associated with this pair.
        strName = NamedValue.Name

        ' Add a new property to the collection of name-value pairs.
        strName = "System Administrator"
        varValue = "Bob Jenkins"
        NamedValue = NamedValues.Add(strName, varValue)

        ' Modify the existing name-value pair of the same name.
        varIndex = "System Administrator"
        varValue = "Justin Crouch"
        NamedValues(varIndex).Value = varValue

    Next i

Catch excCom As COMException
    ' TODO: Handle COM exceptions.
Catch exc As Exception
    ' TODO: Handle errors.
Finally
    ' TODO: Clean-up code goes here.
End Try

End Sub

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next