检测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();
        }
    }
}
相关推荐
复杂的小土豆1 天前
Managers/WebServer.cs
powerpoint
SpaceAIGlobal1 天前
即触 AI PPT“保留原文”核心能力深度评测
人工智能·powerpoint
LL3436382 天前
撰写周报、整理会议纪要、制作PPT适配的各类办公效率工具分析
powerpoint
沉默的云朵3 天前
NET平台下不借助Office实现Word、Powerpoint等文件的解析(一)
word·powerpoint
神奇的代码在哪里3 天前
AI编程时代,PPT已成为过去,单个HTML文件创造无限可能
javascript·html·powerpoint·ai编程·ppt
开开心心_Every5 天前
带OCR识别的电子发票打印工具
运维·自动化·ocr·电脑·powerpoint·音视频·lua
绎奇PPT5 天前
青拔申报全套服务丨文案逻辑梳理+高端PPT设计
信息可视化·powerpoint·ppt
Ar-Sr-Na6 天前
工作路演PPT处理,交给Workbuddy
人工智能·powerpoint·workbuddy开发者分享季
RZhLyRaHv6 天前
LangChain教程-4、构建简易智能 PPT 生成器
人工智能·langchain·powerpoint
SpaceAIGlobal23 天前
AI 生成 PPT 工具深度评测与选型指南
人工智能·powerpoint