日期:2014-05-17  浏览次数:21202 次

c#调用暴风影音2组件
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices; 
namespace 多媒体播放2
{
    public partial class Form1 : Form
    {
        private System.Windows.Forms.OpenFileDialog openMediaFileDialog = new OpenFileDialog();
        private AxMPSLib.AxStormPlayer player;
        public Form1()
        {
            InitializeComponent();
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            openMediaFileDialog.ShowDialog();
            player.URL = openMediaFileDialog.FileName;
           

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }      
    }
}
怎么调试的时候总是在这个地方(player.URL = openMediaFileDialog.FileName)提示:未处理 System.Runtime.InteropServices.COMException
  Message="对 COM 组件的调用返回了错误 HRESULT E_FAIL。"
  Source="Interop.MPSLib"
  ErrorCode=-2147467259

  StackTrace:
       在 MPSLib.IKureePlayer.set_URL(String newVal)
       在 AxMPSLib.AxStormPlayer.set_URL(String value)
       在 多媒体播放2.Form1.openToolStripMenuItem_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects\多媒体播放2\多媒体播放2\Form1.cs:行号 24
       在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
       在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventAr