当前位置:编程学习 > C#/ASP.NET >>

请问c#中如何用反射来实现com的后绑定!

诚心请教  c#中如何用反射来实现com的后绑定,为了调用idispatch中的invoke事件 --------------------编程问答-------------------- 顶!!!!!!!!!! --------------------编程问答--------------------
private void button1_Click(object sender, EventArgs e)
{
    string filename = @"c:\temp\sounds of silence.mp3";
    Type t = Type.GetTypeFromProgID( "MediaPlayer.MediaPlayer");
    object o = Activator.CreateInstance(t);
    t.InvokeMember("FileName", BindingFlags.SetProperty, null, o, new object[] { filename });
    t.InvokeMember("Play", BindingFlags.InvokeMethod, null, o, null);

    MessageBox.Show("Close me to stop the music");
    t.InvokeMember("Stop", BindingFlags.InvokeMethod, null, o, null);
}


这是一段用媒体播放器播放音乐的调用。t.InvokeMember后期邦定Play和Stop函数。
原文:http://topic.csdn.net/u/20080608/15/871eb6ff-0273-4ea2-81cd-03232dc493f0.html
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,