You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在.NET 8 WPF应用中识别Zoom远程控制以禁用拖放?

识别Zoom远程控制并禁用WPF拖放功能

以下是几种可行的实现方案,针对Zoom远程控制场景做适配:

方案1:检测Zoom进程与控制窗口

Zoom开启远程控制时,会生成特定的进程和窗口,可通过枚举系统进程与窗口来判断状态:

  • 先检查系统中是否运行Zoom.exe主进程
  • 进一步枚举窗口,查找包含"Zoom 远程控制"关键词的窗口(不同语言版本可能有差异,需对应调整)

示例C#代码:

using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;

public static bool IsZoomRemoteControlling()
{
    // 检查Zoom主进程是否存在
    if (Process.GetProcessesByName("Zoom").Length == 0)
        return false;

    bool hasControlWindow = false;
    EnumWindows((hwnd, lParam) =>
    {
        var windowTitle = new StringBuilder(256);
        GetWindowText(hwnd, windowTitle, windowTitle.Capacity);
        if (windowTitle.ToString().Contains("Zoom 远程控制"))
        {
            hasControlWindow = true;
            return false; // 找到目标窗口后停止枚举
        }
        return true;
    }, IntPtr.Zero);

    return hasControlWindow;
}

// 导入Windows API用于窗口枚举
[DllImport("user32.dll")]
private static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam);
private delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern int GetWindowText(IntPtr hwnd, StringBuilder lpString, int nMaxCount);

在WPF拖放事件中禁用功能:

private void Window_PreviewDragEnter(object sender, DragEventArgs e)
{
    if (IsZoomRemoteControlling())
    {
        e.Effects = DragDropEffects.None;
        e.Handled = true;
    }
}

方案2:检测输入设备来源

Zoom远程控制的输入属于虚拟输入设备,可通过Windows API获取输入事件的额外信息判断:

[DllImport("user32.dll")]
private static extern IntPtr GetMessageExtraInfo();

public static bool IsRemoteInput()
{
    var extraInfo = GetMessageExtraInfo().ToInt64();
    // 远程输入通常会携带特定标志位,需实际测试Zoom控制时的返回值调整
    return (extraInfo & 0x00000001) != 0;
}

注意:不同版本Zoom的虚拟输入标志位可能有差异,需自行测试确认具体值。

方案3:监听Zoom注册表状态

Zoom开启远程控制时可能会修改注册表项,可定期检查以下路径的相关键值:

  • HKEY_CURRENT_USER\Software\Zoom\Zoom Meetings
  • 查找与远程控制状态相关的键(如IsRemoteControlling类的字段,需自行验证)

实现建议

  1. 优先采用方案1,进程+窗口检测的兼容性和稳定性较好
  2. 结合方案2的输入检测作为补充,减少误判
  3. 在应用启动、拖放事件触发时都执行状态检测,确保实时生效

内容的提问来源于stack exchange,提问作者Markus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 19:06:11