编程创建/删除Windows Media Services的发布点 [英] Programmatically Create / Delete Windows Media Services Publishing Point
问题描述
我在寻找一个.NET包装通过WMI编程方式创建和删除Windows Media Services的发布点。
I'm looking for a .NET wrapper to programmatically Create and Delete Windows Media Services publishing points through WMI.
我不能成为唯一一个曾经想通过.NET要做到这一点,所以我才重新发明轮子,任何人看到任何code样品都来做到这一点?
I can't be the only one to ever want to do this through .NET, so before I re-invent the wheel, anyone seen any code samples out there to do this?
推荐答案
我使用的是媒体服务9 SDK被记录的此处。该SDK是捆绑在一起的运行时组件,所以你需要复制 Microsoft.WindowsMediaServices.Interop.dll
和 WMSServerTypeLib.dll
从Windows Server机器安装运行。我发现他们在 C:\ WINDOWS \ SYSTEM32 \的Windows Media \服务器
。然后,注册类型库并添加引用Interop程序集。
I'm using the Media Services 9 SDK which is documented here. The SDK is bundled with the runtime components, so you'll need to copy Microsoft.WindowsMediaServices.Interop.dll
and WMSServerTypeLib.dll
from your Windows Server machine with the runtime installed. I found them at C:\Windows\System32\windows media\server
. Then, register the type library and add a reference to the Interop assembly.
然后,使用SDK:
using System.Runtime.InteropServices;
using Microsoft.WindowsMediaServices.Interop;
// instantiating the server for a remote host
Type serverType = Type.GetTypeFromProgID("WMSServer.Server", "MediaServer");
// may need to wrap this in an impersonation context depending the server's ACL
WMSServer server = (WMSServer)Activator.CreateInstance(serverType);
// removing all of the publish points
for(int i = server.PublishingPoints.Count - 1; i >= 0; i--)
{
server.PublishingPoints.Remove(i);
}
// adding a push broadcast point
IWMSBroadcastPublishingPoint newPoint =
(IWMSBroadcastPublishingPoint) server.PublishingPoints.Add(
"NewPoint", WMS_PUBLISHING_POINT_CATEGORY.WMS_PUBLISHING_POINT_BROADCAST,
"Push:*");
// cloning
IWMSPublishingPoint cloned = server.PublishingPoints.Clone("Cloned", newPoint);
我包括克隆,因为我遇到了一个错误(存根收到坏数据
)尝试添加一个新的发布点的远程计算机上时。我看到了另一个线程如果有人有同样的问题,所以我想,而不是战斗吧,我只想创建一个模板发布点和创建所有的新点作为该克隆。
I included cloning because I encountered an error (The stub received bad data
) when trying to add a new publishing point on a remote machine. I saw another thread where someone had the same issue, so I figured instead of fighting it, I would just create a template publishing point and create all of the new points as clones of that.
这篇关于编程创建/删除Windows Media Services的发布点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!