首先声明我是个菜鸟,这方面开第一次接触我执行下面的插件为什么没有阻止播放啊
pCallback.OnAuthenticateComplete(WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED, null, Context);
这一句应该能阻止流媒体的播放啊
下面的代码是我自己DLL,全部代码都在这里了
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Globalization;
namespace DBBasePlugin
{
[Guid("D3217092-3EC0-4d0a-9856-91E73E19BD07")] class CDBYanzhengPlugin : IWMSAuthenticationContext, IWMSAuthenticationPlugin, IWMSBasicPlugin
{
#region IWMSAuthenticationContext 成员 void IWMSAuthenticationContext.Authenticate(object ResponseBlob, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandContext, IWMSAuthenticationCallback pCallback, object Context)
{
throw new Exception("The method or operation is not implemented."); //WMS_AUTHENTICATION_RESULT result = WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED;
//byte[] challenge = Encoding.Unicode.GetBytes(""); //pCallback.OnAuthenticateComplete(result, challenge, Context); MessageBox.Show("我到这了");
pCallback.OnAuthenticateComplete(WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED, null, Context);
//WMS_AUTHENTICATION_SUCCESS
}
public IWMSAuthenticationContext CreateAuthenticationContext()
{
return (IWMSAuthenticationContext)this;
} public int GetFlags()
{
return Convert.ToInt32( WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_TEXT_CHALLENGE | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CLIENT_SHOWS_UI | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CHALLENGE_FIRST);
} public string GetPackageName()
{
return "TiVi.WMSAuthentication";
} public string GetProtocolName()
{
return "Custom";
} IWMSAuthenticationPlugin IWMSAuthenticationContext.GetAuthenticationPlugin()
{
throw new Exception("The method or operation is not implemented.");
return (IWMSAuthenticationPlugin)this;
} string IWMSAuthenticationContext.GetImpersonationAccountName()
{
throw new Exception("The method or operation is not implemented.");
return "";
} int IWMSAuthenticationContext.GetImpersonationToken()
{
throw new Exception("The method or operation is not implemented.");
return 0;
} string IWMSAuthenticationContext.GetLogicalUserID()
{
throw new Exception("The method or operation is not implemented.");
return "";
} #endregion
#region IWMSAuthenticationPlugin 成员 IWMSAuthenticationContext IWMSAuthenticationPlugin.CreateAuthenticationContext()
{
throw new Exception("The method or operation is not implemented."); return (IWMSAuthenticationContext)this;
} int IWMSAuthenticationPlugin.GetFlags()
{
throw new Exception("The method or operation is not implemented.");
return Convert.ToInt32(WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_TEXT_CHALLENGE | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CLIENT_SHOWS_UI | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CHALLENGE_FIRST, CultureInfo.InvariantCulture);
} string IWMSAuthenticationPlugin.GetPackageName()
{
throw new Exception("The method or operation is not implemented.");
return "Custom WMS Authentication";
} string IWMSAuthenticationPlugin.GetProtocolName()
{
throw new Exception("The method or operation is not implemented.");
return "Basic";
} #endregion
#region IWMSBasicPlugin 成员 void IWMSBasicPlugin.DisablePlugin()
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.EnablePlugin(ref int plFlags, ref int plHeartbeatPeriod)
{
throw new Exception("The method or operation is not implemented.");
} object IWMSBasicPlugin.GetCustomAdminInterface()
{
throw new Exception("The method or operation is not implemented."); return null;
} void IWMSBasicPlugin.InitializePlugin(IWMSContext pServerContext, WMSNamedValues pNamedValues, IWMSClassObject pClassFactory)
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.OnHeartbeat()
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.ShutdownPlugin()
{
throw new Exception("The method or operation is not implemented.");
} #endregion
}
}
高手们快来救救我吧实在抱歉我的分已经用完了,请你们先将就将就吧
pCallback.OnAuthenticateComplete(WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED, null, Context);
这一句应该能阻止流媒体的播放啊
下面的代码是我自己DLL,全部代码都在这里了
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Globalization;
namespace DBBasePlugin
{
[Guid("D3217092-3EC0-4d0a-9856-91E73E19BD07")] class CDBYanzhengPlugin : IWMSAuthenticationContext, IWMSAuthenticationPlugin, IWMSBasicPlugin
{
#region IWMSAuthenticationContext 成员 void IWMSAuthenticationContext.Authenticate(object ResponseBlob, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandContext, IWMSAuthenticationCallback pCallback, object Context)
{
throw new Exception("The method or operation is not implemented."); //WMS_AUTHENTICATION_RESULT result = WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED;
//byte[] challenge = Encoding.Unicode.GetBytes(""); //pCallback.OnAuthenticateComplete(result, challenge, Context); MessageBox.Show("我到这了");
pCallback.OnAuthenticateComplete(WMS_AUTHENTICATION_RESULT.WMS_AUTHENTICATION_DENIED, null, Context);
//WMS_AUTHENTICATION_SUCCESS
}
public IWMSAuthenticationContext CreateAuthenticationContext()
{
return (IWMSAuthenticationContext)this;
} public int GetFlags()
{
return Convert.ToInt32( WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_TEXT_CHALLENGE | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CLIENT_SHOWS_UI | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CHALLENGE_FIRST);
} public string GetPackageName()
{
return "TiVi.WMSAuthentication";
} public string GetProtocolName()
{
return "Custom";
} IWMSAuthenticationPlugin IWMSAuthenticationContext.GetAuthenticationPlugin()
{
throw new Exception("The method or operation is not implemented.");
return (IWMSAuthenticationPlugin)this;
} string IWMSAuthenticationContext.GetImpersonationAccountName()
{
throw new Exception("The method or operation is not implemented.");
return "";
} int IWMSAuthenticationContext.GetImpersonationToken()
{
throw new Exception("The method or operation is not implemented.");
return 0;
} string IWMSAuthenticationContext.GetLogicalUserID()
{
throw new Exception("The method or operation is not implemented.");
return "";
} #endregion
#region IWMSAuthenticationPlugin 成员 IWMSAuthenticationContext IWMSAuthenticationPlugin.CreateAuthenticationContext()
{
throw new Exception("The method or operation is not implemented."); return (IWMSAuthenticationContext)this;
} int IWMSAuthenticationPlugin.GetFlags()
{
throw new Exception("The method or operation is not implemented.");
return Convert.ToInt32(WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_TEXT_CHALLENGE | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CLIENT_SHOWS_UI | WMS_AUTHENTICATION_FLAGS.WMS_AUTHENTICATION_CHALLENGE_FIRST, CultureInfo.InvariantCulture);
} string IWMSAuthenticationPlugin.GetPackageName()
{
throw new Exception("The method or operation is not implemented.");
return "Custom WMS Authentication";
} string IWMSAuthenticationPlugin.GetProtocolName()
{
throw new Exception("The method or operation is not implemented.");
return "Basic";
} #endregion
#region IWMSBasicPlugin 成员 void IWMSBasicPlugin.DisablePlugin()
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.EnablePlugin(ref int plFlags, ref int plHeartbeatPeriod)
{
throw new Exception("The method or operation is not implemented.");
} object IWMSBasicPlugin.GetCustomAdminInterface()
{
throw new Exception("The method or operation is not implemented."); return null;
} void IWMSBasicPlugin.InitializePlugin(IWMSContext pServerContext, WMSNamedValues pNamedValues, IWMSClassObject pClassFactory)
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.OnHeartbeat()
{
throw new Exception("The method or operation is not implemented.");
} void IWMSBasicPlugin.ShutdownPlugin()
{
throw new Exception("The method or operation is not implemented.");
} #endregion
}
}
高手们快来救救我吧实在抱歉我的分已经用完了,请你们先将就将就吧
解决方案 »
- 如何用C#实现计算机不受外部的监控。
- .Net高手进////////简单问题...
- c#ASP.NET 如何实现对SQLServer数据库的备份
- 比如一个按钮控件,名称为 button1,我先写出了单击事件代码,可是之后我再给按钮改名为cmdexit。发现单击事件还是 button1_click,为什么
- 复制粘贴,从winform到word
- enum能不能请类型,就是在声明时就定义其类型
- 求教C#打包读取pak文件的算法或思路
- C# 编译后splitcontainer 的拆分条在哪?
- C# ,在Datagrid中删除记录出错
- 回车键处理
- WebForm中2个按钮的问题!
- 100分!在线等!在线结贴!web service 部署到 88端口,不返回数据
class CDBYanzhengPlugin : IWMSAuthenticationContext, IWMSAuthenticationPlugin, IWMSBasicPlugin
{
//增加注册方法
[ComRegisterFunction]
public static void RegisterFunction(Type t)
{
}
[ComUnregisterFunction] //注销方法
public static void UnRegisterFunction(Type t)
{
}
}
错误提示是: 错误代码:0X80004005, 未指定的错误
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.IO;using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace WM_Plugin
{
[GuidAttribute("02a5d426-e0df-40b5-99f4-95cad3a67ed4")] public class MediaEventLogger : IWMSBasicPlugin, IWMSEventNotificationPlugin
{ #region IWMSBasicPlugin 成员 void IWMSBasicPlugin.DisablePlugin()
{
} void IWMSBasicPlugin.EnablePlugin(ref int plFlags, ref int plHeartbeatPeriod)
{
} object IWMSBasicPlugin.GetCustomAdminInterface()
{
return 0;
} void IWMSBasicPlugin.InitializePlugin(IWMSContext pServerContext, WMSNamedValues pNamedValues, IWMSClassObject pClassFactory)
{ } void IWMSBasicPlugin.OnHeartbeat()
{
} void IWMSBasicPlugin.ShutdownPlugin()
{
} #endregion #region IWMSEventNotificationPlugin 成员 object IWMSEventNotificationPlugin.GetHandledEvents()
{
int[] iHandledEvents = new int[3];
iHandledEvents[0] = (int)WMS_EVENT_TYPE.WMS_EVENT_CONNECT;
iHandledEvents[1] = (int)WMS_EVENT_TYPE.WMS_EVENT_DISCONNECT;
iHandledEvents[2] = (int)WMS_EVENT_TYPE.WMS_EVENT_PLAY;
return (iHandledEvents);
} void IWMSEventNotificationPlugin.OnEvent(ref WMS_EVENT pEvent, IWMSContext pUserCtx, IWMSContext pPresentationCtx, IWMSCommandContext pCommandCtx)
{
try
{
MessageBox.Show("pEvent", "Event Plug-in", MessageBoxButtons.OK); string bFilePath = @"c:\test.txt";
File.Delete(bFilePath);
FileStream fsMyfile = new FileStream(bFilePath, FileMode.Append, FileAccess.Write);
StreamWriter swMyfile = new StreamWriter(fsMyfile);
switch (pEvent.Type)
{
case WMS_EVENT_TYPE.WMS_EVENT_CONNECT:
MessageBox.Show("Client connected",
"Event Plug-in",
MessageBoxButtons.OK);
swMyfile.WriteLine("Client connected");
break; case WMS_EVENT_TYPE.WMS_EVENT_DISCONNECT:
MessageBox.Show("Client disconnected",
"Event Plug-in",
MessageBoxButtons.OK);
swMyfile.WriteLine("Client disconnected");
break;
case WMS_EVENT_TYPE.WMS_EVENT_PLAY:
MessageBox.Show("hhh");
swMyfile.WriteLine("xiecuole");
break;
}
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message,
"Event Plug-in Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
} #endregion [ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
try
{
RegistryKey regHKLM = Registry.LocalMachine;
regHKLM = regHKLM.CreateSubKey("SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Event Notification and Authorization\\{02a5d426-e0df-40b5-99f4-95cad3a67ed4}");
regHKLM.SetValue(null, "WMS_QYWS_Plug"); RegistryKey regHKCR = Registry.ClassesRoot;
regHKCR = regHKCR.CreateSubKey("CLSID\\{02a5d426-e0df-40b5-99f4-95cad3a67ed4}\\Properties");
regHKCR.SetValue("Name", "WMS_QYWS_Plug");
regHKCR.SetValue("Author", "QYWS Corporation");
regHKCR.SetValue("CopyRight", "Copyright 2002 . All rights reserved");
regHKCR.SetValue("Description", "Enables you to trap the connect and disconnect events"); regHKCR.SetValue("SubCategory", "Logging");
regHKCR.SetValue("UnsupportedLoadTypes ", "2");
}
catch (Exception error)
{
MessageBox.Show(error.Message,
"Inside RegisterFunction(). Cannot Register",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
[ComUnregisterFunctionAttribute]
public static void UnRegisterFunction(Type t)
{
try
{
RegistryKey regHKLM = Registry.LocalMachine;
regHKLM.DeleteSubKey("SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Event Notification and Authorization\\{02a5d426-e0df-40b5-99f4-95cad3a67ed4}"); RegistryKey regHKCR = Registry.ClassesRoot;
regHKCR.DeleteSubKeyTree("CLSID\\{02a5d426-e0df-40b5-99f4-95cad3a67ed4}\\Properties");
regHKCR.DeleteSubKeyTree("MediaEventLogger.MediaEventLogger");
}
catch (Exception error)
{
MessageBox.Show(error.Message,
"Cannot delete a subkey.",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}
现在我这么写,可以注册,可以启用,但是好像没有起作用啊,在c盘下没有记录根本没有生成test.txt啊,怎么回事
怎么回事啊 完全按照SDK来做的