大网数据广告活动
Windows 系统接口

Game Bar Presence Writer

· 52CE 我爱测

Game Bar Presence Writer is a component that is notified when a game's "presence" state (i.e. is a game running in the foreground) changes. This functionality is available in Windows 10 and later operating systems. By default, the existing Game Bar Presence Writer will set a user's Xbox Live presence state for a running game if the Xbox App is installed,…

Purpose

Game Bar Presence Writer is a component that is notified when a game's "presence" state (i.e. is a game running in the foreground) changes. This functionality is available in Windows 10 and later operating systems. By default, the existing Game Bar Presence Writer will set a user's Xbox Live presence state for a running game if the Xbox App is installed, the user is signed into their Xbox account, and the user has enabled Xbox Live presence to be set when they run a game on their PC. It is possible for Windows Application developers to override this default behavior with their own implementation.

Important: By providing a custom implementation of the Game Bar Presence Writer, the default behavior of a user's Xbox Live presence state being set when they run a game will no longer be available.

Implement an out of proc COM server that implements Game Bar Presence Writer functionality

In order to provide a Game Bar Presence Writer implementation, you must implement an out of proc COM server that implemented the following COM interfaces:

import "oaidl.idl";
import "Inspectable.idl";

#include <sdkddkver.h>

namespace Windows.Gaming.GameBar.PresenceServer.Internal
{
    // typedefs
    typedef enum GameNotificationEvent GameNotificationEvent;
    typedef enum AppIdType AppIdType;

    typedef UINT64 WindowId;

    interface IPresenceWriter;
    runtimeclass PresenceWriter;

    // enums
    enum GameNotificationEvent
    {
        None = 0,
        GotFocus,
        LostFocus,
        AppClose
    };

    // enums
    enum AppIdType
    {
        Aumid = 0,  // Application User Model Id
        TitleId     // Xbox Live Title Id
    };

    [uuid(782674D9-5CBB-4FCA-AD72-D9AC5F7AE963)]
    [exclusiveto(PresenceWriter)]
    interface IPresenceWriter : IInspectable
    {
        HRESULT UpdatePresence([in] WindowId hWnd, [in] GameNotificationEvent @event, [in] HSTRING appId, [in] AppIdType appIdType);
    }

    [marshaling_behavior(agile)] 
    runtimeclass PresenceWriter 
    {
        [default] interface IPresenceWriter; 
    }
}

When a game is ran on the user's machine, UpdatePresence will be called with the following parameters:

hWnd [in]

A handle to the window of the running game.

event [in]

Event that correpsonds to whether the game got focus (GotFocus), lost focus (LostFocus), or the game as was closed (AppClose).

appId [in]

Application Identifier of the game. If appIdType is Aumid then appId is the Application User Model Id. If appId is TitleId then appId is the Xbox Live Title Id.

appIdType [in]

Specifies if appId corresponds to the Application User Model Id (Aumid) of the game of the Xbox Live Title Id (TitleId) of the game.

Register COM server implementation for Presence Writer

In order for your implementation of Game Bar Presence Writer to run, it must ensure the following registry value is set:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsRuntime\Server\Windows.Gaming.GameBar.Internal.PresenceWriterServer\ExePath

Data type Range Default value
REG_SZ Path to the executable

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 02/22/2024
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。