This code snippet demonstrates how you can enumerate all available event handlers for Windows Media Services.

Example output :

7 event handlers available

WMS Client Logging
CLSID : {09EE74B0-961A-11D2-AEDE-0060089BBAF4}
Enabled : True
Status : 14
Properties
WMSSystemPlugin : 1
ASPMoniker : LoggingAdmin.asp
UnsupportedLoadTypes : 2
MMCMoniker : CLSID:{9C046A5B-3EC3-11D3-B38A-00C04F610D6B},CLSID:{26C1EDA6-4C44-46DE-84BE-901064C754EB},CLSID:{9E531984-0384-4b25-9DFB-E804165D1D75}
SubCategory : Logging
Name : WMS Client Logging
Description : Enables you to log activity data for players that are connected over a unicast stream. The server and publishing point logging plug-ins work in conjunction with one another.
Author : Microsoft Corporation
Copyright : Copyright © Microsoft Corporation. All rights reserved.
[…]

// ------------------------
// This requires the following using statement
//
// Note that this is not present by default in Visual Studio, you require either an installed WMS Server on the
// local machine or copy and reference the Microsoft.WindowsMediaServices.dll file from either the Windows SDK or a WMS Server
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
// ------------------------

try
{
  // Connect to the interface
  WMSServer LocalWMSServer = new WMSServer();
  Console.WriteLine(LocalWMSServer.EventHandlers.Count + " event handlers available");
  Console.WriteLine("");

  // enumerate all event handlers
  foreach (IWMSPlugin handler in LocalWMSServer.EventHandlers)
  {
    Console.WriteLine(handler.Name);
    Console.WriteLine("CLSID : " + handler.CLSID);
    Console.WriteLine("Enabled : " + handler.Enabled);
    Console.WriteLine("Status : " + handler.Status);
    Console.WriteLine("Properties");

    // Write out each property belonging to the property collection
    foreach (IWMSNamedValue nv in handler.Properties)
    {
      Console.WriteLine("\t" + nv.Name + " : " + nv.Value);
    }
    Console.WriteLine("");
  }
}
catch (COMException e)
{
  Console.WriteLine("Something went wrong with accessing the COM object.");
  Console.WriteLine(e.ToString());
}
catch (Exception e)
{
  Console.WriteLine("Something went wrong");
  Console.WriteLine(e.ToString());
}
Tagged with: