You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

如何标记非游戏程序以避免GeForce Experience自动注入Overlay?

解决GeForce Experience自动注入Overlay的开发者方案

针对非游戏GPU加速程序(如用Rust winit创建的窗口、LibreOffice等),开发者可以通过以下通用或平台特定手段,让GeForce Experience默认不注入Overlay:

通用Windows平台方案

1. 注册表标记程序为非游戏

Nvidia会读取注册表中的标记判断程序是否为游戏,开发者可在程序启动时自动写入对应项:

  • 写入当前用户注册表(无需管理员权限,仅对当前用户生效):路径为HKEY_CURRENT_USER\SOFTWARE\NVIDIA Corporation\Global\GfExperience\State\Applications\[你的程序文件名],添加IsGame DWORD值为0。
  • 写入本地机器注册表(需管理员权限,对所有用户生效):路径为HKEY_LOCAL_MACHINE\SOFTWARE\NVIDIA Corporation\Global\GfExperience\State\Applications\[你的程序文件名],添加IsGame DWORD值为0。

2. 调用NVAPI禁用Overlay

使用Nvidia官方提供的NVAPI,在程序初始化图形上下文(如D3D、Vulkan)后,主动禁用Overlay。该方法需要链接NVAPI库,仅在Windows平台生效。

3. 打包为MSIX/UWP应用

如果程序可以迁移为Windows沙箱应用(如MSIX打包、UWP),GeForce Experience通常不会向沙箱内的程序注入Overlay,因为沙箱限制了外部注入行为。

Rust winit场景的具体实现

注册表标记示例(基于winreg crate)

使用winreg crate在程序启动时写入当前用户注册表:

#[cfg(windows)]
use winreg::enums::*;
#[cfg(windows)]
use winreg::RegKey;

#[cfg(windows)]
fn mark_as_non_game() -> Result<(), Box<dyn std::error::Error>> {
    let exe_path = std::env::current_exe()?;
    let exe_name = exe_path.file_name().unwrap().to_str().ok_or("Invalid executable name")?;

    let hkcu = RegKey::predef(HKEY_CURRENT_USER);
    let app_key = hkcu.create_subkey(format!(
        r"SOFTWARE\NVIDIA Corporation\Global\GfExperience\State\Applications\{}",
        exe_name
    ))?;
    app_key.set_value("IsGame", &0u32)?;
    Ok(())
}

fn main() {
    // 仅在Windows平台执行标记逻辑
    #[cfg(windows)]
    if let Err(e) = mark_as_non_game() {
        eprintln!("Failed to mark as non-game: {}", e);
    }

    // 初始化winit窗口
    let event_loop = winit::event_loop::EventLoop::new();
    let _window = winit::window::WindowBuilder::new().build(&event_loop).unwrap();

    // 后续窗口逻辑...
    event_loop.run(|_event, _, control_flow| {
        control_flow.set_wait();
    });
}

NVAPI禁用示例(基于nvapi-sys crate)

如果程序使用DirectX 11,可通过nvapi-sys crate调用NVAPI禁用Overlay:

#[cfg(windows)]
use nvapi_sys::*;
#[cfg(windows)]
use winapi::um::d3d11::ID3D11Device;

#[cfg(windows)]
unsafe fn disable_nvidia_overlay(device: *mut ID3D11Device) -> Result<(), String> {
    if NvAPI_Initialize() != NVAPI_OK {
        return Err("Failed to initialize NVAPI".into());
    }

    let mut overlay_state = NVAPI_OVERLAY_STATE {
        bEnabled: 0,
        ..std::mem::zeroed()
    };

    let result = NvAPI_D3D11_SetOverlayState(device, &mut overlay_state);
    NvAPI_Unload();

    if result != NVAPI_OK {
        Err(format!("NVAPI error code: {}", result))
    } else {
        Ok(())
    }
}

// 在创建D3D11设备后调用上述函数

注意事项

  • 注册表标记可能被GeForce Experience的更新覆盖,建议程序每次启动时检查并重新写入。
  • NVAPI方法依赖图形上下文,需确保在创建D3D/Vulkan设备后调用。
  • 跨平台程序只需在Windows分支中处理,GeForce Experience仅在Windows环境运行。

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

火山引擎 最新活动