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

Windows下基于SteamID编程检测Steam游戏运行状态的可行方案

Reliable Ways to Detect if a Steam Game is Running via SteamID on Windows

Let's break down practical, consistent solutions to your problem—since the registry Running value is hit-or-miss (looking at you, Rocket League) and tracking just steam.exe doesn't give you the actual game process:

1. Track Game Processes via Command Line Arguments (No SDK Required)

Steam launches nearly all games with a command line that includes the target AppID using the -applaunch flag. You can enumerate all running Windows processes and check their command lines for this flag paired with your target Steam AppID.

Here's a quick PowerShell example (easily adapted to C#/C++ via Windows APIs):

$targetAppID = "252950" # Rocket League's AppID
Get-WmiObject Win32_Process | Where-Object {
    $_.CommandLine -match "-applaunch $targetAppID" -and $_.Name -ne "steam.exe"
} | Select-Object Name, ProcessId, CommandLine

This works even if you launch the game via an external program that calls steam.exe—the actual game process will still carry the -applaunch <AppID> parameter in its command line.

2. Use the Steamworks Local API (Most Reliable)

If you can integrate the Steamworks SDK into your program, you can directly query the Steam client for running games linked to a SteamID. The key method here is ISteamApps::GetAppRunningInProcess, which checks if a specific AppID is active in any process owned by the current Steam user.

A simplified C++ snippet:

#include "steam/steam_api.h"

bool IsGameRunning(uint32_t appID) {
    if (!SteamAPI_Init()) return false;
    
    CSteamID steamID = SteamUser()->GetSteamID();
    uint32 processID;
    // Returns true if the app is running in a process tied to this SteamID
    return SteamApps()->GetAppRunningInProcess(appID, &processID);
}

This bypasses the registry entirely and talks directly to the Steam client, so it works consistently across all Steam games—even those that ignore the legacy Running registry key.

3. Enumerate Steam.exe Child Processes

When Steam launches a game, the game process is almost always a direct or indirect child of steam.exe. You can:

  • Locate all running steam.exe processes
  • For each, enumerate its child processes using Windows API tools like CreateToolhelp32Snapshot
  • Cross-reference those child processes with your target game's known executable name (e.g., RocketLeague.exe, Undertale.exe) or check their command lines for the AppID

This is a solid middle ground if you don't want to use the Steamworks SDK but still need to link game processes back to Steam, even when launched externally.

Why the Registry Running Value Fails

That registry entry is a legacy Steam tracking mechanism, and modern games (especially those using newer Steamworks features or custom launchers) don't always update it. Titles like Rocket League use more direct communication with the Steam client instead of writing to that key—so relying on it is never a robust solution.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:32:22