Creating a New On-Demand Publishing Point
The first step in publishing your content is to create a new publishing point that can be used to distribute it. The following Visual Basic, C#, and C++ examples show you how to create a new on-demand publishing point named "NewPubPoint" and use it to publish content from a directory, in this case, "c:\wmpub\wmroot". By modifying the values to fit your content, you can create your own personal on-demand publishing point.
Visual Basic .NET Example
Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices
' Declare variables.
Dim Server As WMSServer
Dim ODPubPoint As IWMSOnDemandPublishingPoint
Try
' Create the WMSServer object.
Server = New WMSServer()
' Add a new on-demand publishing point.
ODPubPoint = Server.PublishingPoints.Add("NewPubPointII", _
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_ON_DEMAND, _
"c:\wmpub\wmroot\")
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;
// Declare variables.
WMSServer Server;
IWMSOnDemandPublishingPoint ODPubPoint;
try
{
// Create the WMSServer object.
Server = new WMSServerClass();
// Add a new on-demand publishing point.
ODPubPoint = (IWMSOnDemandPublishingPoint)Server.PublishingPoints.Add(
"NewPubPointII",
WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_ON_DEMAND,
"c:\\wmpub\\wmroot\\");
}
catch (COMException comExc)
{
// TODO: Handle COM exceptions.
}
catch (Exception exc)
{
MessageBox.Show(exc.ToString(), "Example 20");
// TODO: Exception handler goes here.
}
finally
{
// TODO: Clean-up code goes here.
}
C++ Example
#include <windows.h>
#include <atlbase.h> // Includes CComBSTR.
#include "wmsserver.h"
// Declare variables and interfaces.
IWMSServer *pServer;
IWMSPublishingPoints *pPubPoints;
IWMSPublishingPoint *pPubPoint;
IWMSOnDemandPublishingPoint *pODPubPoint;
HRESULT hr;
CComBSTR bstrFile;
CComBSTR bstrName;
// 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 add a new on-demand publishing point.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;
bstrName = "NewPubPoint";
bstrFile = "c:\\wmpub\\wmroot\\";
hr = pPubPoints->Add(bstrName, WMS_PUBLISHING_POINT_ON_DEMAND,
bstrFile, &pPubPoint);
if (FAILED(hr)) goto EXIT;
// Query the IWMSOnDemandPublishingPoint interface from
// the newly created publishing point.
hr = pPubPoint->QueryInterface(IID_IWMSOnDemandPublishingPoint,
(void **)&pODPubPoint);
if (FAILED(hr)) goto EXIT;
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
See Also
Reference
IWMSOnDemandPublishingPoint Interface
IWMSOnDemandPublishingPoint Object (C#)
IWMSOnDemandPublishingPoint Object (Visual Basic .NET)