大家帮下我,这段程序是否有问题。为啥执行得不到结果!那位能帮我看一下。这段程序应该是捕获PowerPoint的事件然后显示在Listbox里。分不够继续加!using System.Runtime.InteropServices;private UCOMIConnectionPoint m_oConnectionPoint;
private int m_Cookie;
private PowerPoint.ApplicationClass oPPT;
private void button1_Click(object sender, System.EventArgs e)
{
// QI for IConnectionPointContainer.
UCOMIConnectionPointContainer oConnPointContainer = (UCOMIConnectionPointContainer) oPPT;
// Get the GUID of the EApplication interface.
Guid guid=typeof(PowerPoint.EApplication).GUID; // Find the connection point.
oConnPointContainer.FindConnectionPoint(ref guid,out m_oConnectionPoint);
// Call Advise to sink up the connection.
m_oConnectionPoint.Advise(this,out m_Cookie);
}[DispId(2001)]
public void WindowSelectionChange(PowerPoint.Selection Sel)
{
this.listBox1.Items.Add("WindowSelectionChange");
}[DispId(2002)]
public void WindowBeforeRightClick(PowerPoint.Selection Sel,bool Cancel) 
{
this.listBox1.Items.Add("WindowBeforeRightClick");
}[DispId(2003)]
public void WindowBeforeDoubleClick(PowerPoint.Selection Sel,bool Cancel) 
{
this.listBox1.Items.Add("WindowBeforeDoubleClick");
}[DispId(2004)]
public void PresentationClose(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("PresentationClose");
}[DispId(2005)]
public void PresentationSave(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("PresentationSave");
}[DispId(2006)]
public void PresentationOpen(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("PresentationOpen");
}[DispId(2007)]
public void NewPresentation(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("NewPresentation");
}[DispId(2008)]
public void PresentationNewSlide(PowerPoint.Slide Sld) 
{
this.listBox1.Items.Add("PresentationNewSlide");
}[DispId(2009)]
public void WindowActivate(PowerPoint.Presentation Pres,PowerPoint.DocumentWindow Wn) 
{
this.listBox1.Items.Add("WindowActivate");
}[DispId(2010)]
public void WindowDeactivate(PowerPoint.Presentation Pres,PowerPoint.DocumentWindow Wn) 
{
this.listBox1.Items.Add("WindowDeactivate");
}[DispId(2011)]
public void SlideShowBegin(PowerPoint.SlideShowWindow Wn) 
{
this.listBox1.Items.Add("SlideShowBegin");
}[DispId(2012)]
public void SlideShowNextBuild(PowerPoint.SlideShowWindow Wn) 
{
this.listBox1.Items.Add("SlideShowNextBuild");
}[DispId(2013)]
public void SlideShowNextSlide(PowerPoint.SlideShowWindow Wn) 
{
this.listBox1.Items.Add("SlideShowNextSlide");
}[DispId(2014)]
public void SlideShowEnd(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("SlideShowEnd");
}[DispId(2015)]
public void PresentationPrint(PowerPoint.Presentation Pres) 
{
this.listBox1.Items.Add("PresentationPrint");
}[DispId(2016)]
public void SlideSelectionChanged(PowerPoint.SlideRange SldRange) 
{
this.listBox1.Items.Add("SlideSelectionChanged");
}[DispId(2017)]
public void ColorSchemeChanged(PowerPoint.SlideRange SldRange) 
{
this.listBox1.Items.Add("ColorSchemeChanged");
}[DispId(2018)]
public void PresentationBeforeSave(PowerPoint.Presentation Pres,bool Cancel) 
{
this.listBox1.Items.Add("PresentationBeforeSave");
} [DispId(2019)]
public void SlideShowNextClick(PowerPoint.SlideShowWindow Wn,PowerPoint.Effect nEffect)
{
this.listBox1.Items.Add("SlideShowNextClick");
}private void button2_Click(object sender, System.EventArgs e)
{
m_oConnectionPoint.Unadvise(m_Cookie);
System.Runtime.InteropServices.Marshal.ReleaseComObject(oPPT);
GC.Collect();
}private void Form1_Load(object sender, System.EventArgs e)
{
//Create an instance of PowerPoint.
oPPT = new PowerPoint.ApplicationClass(); // Show PowerPoint to the user.
oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;