检测PowerPoint是否进入了PPT全屏放映模式

豆包给了一段代码,可以检测PowerPoint是否进入了PPT全屏放映模式,VS2022,winform4.8

cs 复制代码
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 Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;

namespace PowerPointTool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
      
        }

        /// <summary>
        /// 检测 PowerPoint 是否处于全屏放映模式
        /// </summary>
        public static bool IsPowerPointFullScreen()
        {
            Microsoft.Office.Interop.PowerPoint.Application pptApp = null;
            try
            {
                // 获取正在运行的 PowerPoint 实例
                pptApp = (Microsoft.Office.Interop.PowerPoint.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application");

                if (pptApp.SlideShowWindows.Count > 0)
                {
                    foreach (SlideShowWindow window in pptApp.SlideShowWindows)
                    {
                        // 判断是否全屏
                        if (window.IsFullScreen == MsoTriState.msoTrue)
                            return true;
                    }
                }
                return false;
            }
            catch
            {
                // 没有运行 PowerPoint
                return false;
            }
            finally
            {
                // 释放 COM 对象,避免进程残留
                if (pptApp != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pptApp);
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = IsPowerPointFullScreen().ToString();
        }
    }
}
相关推荐
小淮AI12 小时前
AI生成PPT工具的功能观察:百度文库、Gamma、WPS AI
人工智能·powerpoint·wps
小羊没烦恼!18 小时前
【译】利用Asp.net MVC处理文件的上传下载
开发语言·缓存·c#·word·powerpoint·.net
小羊没烦恼!7 天前
微服务化的基石——持续集成
java·大数据·word·powerpoint·.net
百事牛科技8 天前
PPT只读怎么取消?四种情况分别处理
windows·powerpoint
AcaDesign13 天前
上海市科技奖申报答辩ppt制作案例_科技进步奖ppt模板_技术发明奖ppt设计_自然科学奖ppt美化
大数据·科技·powerpoint
古少侠13 天前
deepseek转word工具怎么选?DS随心转与4种方案对比实测
人工智能·word·powerpoint
SunnyDays101114 天前
使用 Python 将 PowerPoint 转换为视频(无需安装 Microsoft PowerPoint)
python·powerpoint·ppt 转 动画·ppt 转 mp4·ppt 转 wmv·幻灯片转动画·幻灯片转 mp4
小羊没烦恼!15 天前
Memory 记忆设计讨论:Agent Memory 的安全边界:权限、删除、版本与回执
java·大数据·word·powerpoint·.net
h788139417 天前
录音容易纪要难?录音转文字 + AI 纪要实测,提升会议效率
人工智能·powerpoint
AI分享猿18 天前
百智云智能PPT 实测:一句话生成整套材料,还能上传自己的模板
人工智能·powerpoint