Share via


Duplicating a Publishing Point

Duplicating a publishing point is the easiest way to set up multiple publishing points that all use the same basic configuration. The newly cloned publishing point can simply be directed to new content without the need to reconfigure the various plug-ins. The cloning is done through the IWMSPublishingPoints object, which manages all of the publishing points on the server.

The following examples illustrate how to clone a publishing point.

Visual Basic .NET Example

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

' Declare variables.
Dim Server As WMSServer
Dim PubPoint As IWMSPublishingPoint
Dim PubPointClone As IWMSPublishingPoint

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

    ' Retrieve the publishing point to be cloned.
    PubPoint = Server.PublishingPoints.Item("Publishing Point Name")

    ' Clone the publishing point.
    PubPointClone = Server.PublishingPoints.Clone( _
        "Publishing Point Clone", PubPoint)

Catch errCom As COMException
    ' TODO: Handle COM exceptions.
Catch err As Exception
    ' TODO: Exception handler goes here.

Finally
    ' TODO: Clean-up code goes here.
End Try

C# Example

using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

WMSServer Server;
IWMSPublishingPoint PubPoint;
IWMSPublishingPoint PubPointClone;
int i;

try
{
    // Create the WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the publishing point to be cloned.
    for (i=0; i< Server.PublishingPoints.Count; i++)
        {
            if ("Publishing Point Name" == Server.PublishingPoints[i].Name)
            {
                PubPoint = Server.PublishingPoints[i];

                // Clone the publishing point.
                PubPointClone = Server.PublishingPoints.Clone( 
               "Publishing Point Clone", PubPoint);
               break;
           }
        }
}
catch (COMException comExc)
{
    // TODO: Handle COM exceptions.
}
catch (Exception exc)
{
    MessageBox.Show(exc.ToString(), "Example 11");
    // TODO: Exception handler goes here.
}
finally
{
    // TODO: Clean-up code goes here.
}

C++ Example

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer              *pServer;
IWMSPublishingPoints    *pPubPoints;
IWMSPublishingPoint     *pPubPoint;
IWMSPublishingPoint     *pPubPointClone;

HRESULT         hr;
CComVariant     varIndex;
CComBSTR        bstrName;
long            lCount;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPublishingPoints
// interface and retrieve the number of publishing
// points.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
hr = pPubPoints->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the publishing
// point to be cloned.
varIndex = "Publishing Point Name";
hr = pPubPoints->get_Item(varIndex, &pPubPoint);
if (FAILED(hr)) goto EXIT;

// Set the new name for the clone.
bstrName = "Publishing Point Clone";

// Clone the publishing point.
hr = pPubPoints->Clone(bstrName, pPubPoint, &pPubPointClone);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also (General)

See Also (Visual Basic .NET)

See Also (C#)

See Also (C++)