using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using PowerPoint = Microsoft.Office.Interop.PowerPoint; namespace PPTEventTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private PowerPoint.Application oPPT; private void button1_Click(object sender, EventArgs e) { oPPT = new PowerPoint.Application(); oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; oPPT.Activate(); oPPT.SlideShowBegin += new PowerPoint.EApplication_SlideShowBeginEventHandler(SlideShowBegin); oPPT.SlideShowEnd += new PowerPoint.EApplication_SlideShowEndEventHandler(SlideShowEnd); } private void SlideShowEnd(PowerPoint.Presentation Pres) { this.listBox1.Items.Add("结束放映"); } private void SlideShowBegin(PowerPoint.SlideShowWindow Wn) { this.listBox1.Items.Add("开始放映"); } private void Form1_Load(object sender, EventArgs e) { System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false; } private void button2_Click(object sender, EventArgs e) { oPPT.SlideShowBegin -= SlideShowBegin; oPPT.SlideShowEnd -= SlideShowEnd; oPPT.ActivePresentation.Saved = Microsoft.Office.Core.MsoTriState.msoTrue; oPPT.ActivePresentation.Close(); oPPT.Quit(); oPPT = null; //GC.Collect(); } } }
111,128
社区成员
642,535
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧