1
\$\begingroup\$

Note: This was the best fitting stack I could find for this. Apparently this site doesn't specify in the scope whether this is allowed. I originally asked in Meta, and they told me to create the question so the community could decide using a concrete question.

Like other people with large gaming libraries, I've often been faced with uncertainty about what game to play. There are websites that can check your Steam library and suggest you a game based on things like Metascore, user ratings, genre preferences,... but there are 3 major issues with these:

  1. They require an internet connection;
  2. They check all your games, which also means games you've yet to download or which you got through a bundle deal with no intention of ever playing;
  3. They only check Steam games, not games from other clients or even just classic disc-based games.

During my spare time, I had been working on a small C# program trying to fix this. It worked using a very brute-force way: you entered a folder name, it would get ALL files from that folder, then filter out everything that wasn't a .exe file and the stuff that didn't look like it was a game executable. It kinda worked, but it had 3 main issues:

  1. SLOOOOOOW! it took 15 minutes to get all the files, if it didn't crash due to memory issues.
  2. it included things that weren't games, like uninstallers, C redists and utilities;
  3. I wrote it as an UWP program, which meant it wasn't portable to Windows 7 and 8 and was lacking proper libraries for things like mocking.

I'm taking another stab at it soon, but this time, I don't want to do it brute-force. I'm hoping to leverage the power of the platform and use readily available methods to find what I need.

My question is:

  • Does Windows have something that can give me a list of installed games?
  • If Windows can't do it, do the major digital distribution clients (meaning Steam, Origin and UPlay) have a way to provide a list of installed games? I don't mind if it means parsing files and then looking things up.
\$\endgroup\$
1
  • \$\begingroup\$ If you must find portable apps searching the disk for all exes sounds like the easiest way to me. Use a DB so you don't need to rescan on restart. If you need new/removed games immediately then you can subscribe to file change notifications, otherwise you can schedule a service to run (eg- at 4am) to scan the disk for changes. If you don't have a good way of determining if an exe is game, you can allow the user to validate whether exes are actually games. \$\endgroup\$
    – milk
    Commented Jun 17, 2016 at 23:15

4 Answers 4

4
\$\begingroup\$

There's no API from Windows to specifically get installed games. However you can programmatically grab the currently installed programs:

string registry_key = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using(Microsoft.Win32.RegistryKey key = Registry.LocalMachine.OpenSubKey(registry_key))
{
    foreach(string subkey_name in key.GetSubKeyNames())
    {
        using(RegistryKey subkey = key.OpenSubKey(subkey_name))
        {
            Console.WriteLine(subkey.GetValue("DisplayName"));
        }
    }
}

Source

You will also want to do this for the key:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Then, from there, you will need to grab a list from any potential game store front.

For Steam, you want to check for a SteamPath key in: HKEY_CURRENT_USER\Software\Valve\Steam

This will give you the path to the Steam install directory. From here, you are looking for Config\config.vdf. This file can contain several keys in the format BaseInstallFolder_#, which are the individual Steam Library paths. These paths will be where all of Steam's games are stored, although it won't help with 3rd-party games added into Steam manually. Please consult this helpful wiki article for parsing the .vdf file.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ For the other game store fronts...I'm not sure if this should be broken down into multiple Q/A's for each one, a community post to include all of them, or...? \$\endgroup\$
    – user39686
    Commented Jun 17, 2016 at 21:13
1
\$\begingroup\$

Check the registry paths HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall and HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall. They have a sub-key for every piece of software which was installed through a common installation wizard. It doesn't separate games from other software, but when you are building a game recommendation engine then identifying the games should be within your area of expertise.

This also includes most (but not all) steam games. However, it won't list any games which are not installed through a conventional installer. This is uncommon, but not unheard of.

By the way, you might notice that while browsing to these paths you will stumble upon a list of almost all programs which were ever installed on the system, including those which were uninstalled long ago. That might or might not be interesting information for your application.

\$\endgroup\$
1
  • \$\begingroup\$ Okay, this is a solution for Steam games and some other games, but it doesn't work for EA Origin, Ubisoft Uplay and Blizzard Battle.net games. \$\endgroup\$
    – Nzall
    Commented Jun 17, 2016 at 21:09
1
\$\begingroup\$

Does Windows have something that can give me a list of installed games?

Nope. The closest you can get are various ways to get all executables on the machine... these include techniques like searching for *.exe in the whole filesystem (your 15 minute timeframe, by the way, suggests to me you did something very inefficient) or trawling the registry as suggested by others.

There was a Games shell folder in Windows 7, but it seems to have vanished in modern Windows, and would not pick up all games accurately anyhow.

If Windows can't do it, do the major digital distribution clients (meaning Steam, Origin and UPlay) have a way to provide a list of installed games? I don't mind if it means parsing files and then looking things up.

Steam has an API you could use for this. Origin does not, as far as I can tell (and at least as of 2013 didn't). Neither does UPlay.

\$\endgroup\$
1
  • \$\begingroup\$ about the inefficiency: I basically let them select a folder, then I did a GetFilesAsync depth search and let it run. Once it completed, it would run a rudimentary filter that filtered out the worst of the bunch. github.com/nzall/GameRoulette/blob/master/GameRoulette/… is the relevant Github repo file. I haven't worked on it for months though. \$\endgroup\$
    – Nzall
    Commented Jun 17, 2016 at 21:32
1
\$\begingroup\$

Probably a completely dead topic but one I referred to when I was trying to accomplish the same.

I ended up searching registry as mentioned above, and it wasn't too bad, until I came across battle.net launcher... no consistent identifying factor, so I hardcoded those games.

I've put below how I found them all

(Note, I'm not a professional developer, it's a learning project, but if you want to give it a test feel free) https://github.com/pekempy/Breeze/blob/master/Models/ExeSearch.cs

\$\endgroup\$
1
  • 1
    \$\begingroup\$ But this will still only find an part of all installed games \$\endgroup\$
    – Lee
    Commented Mar 21, 2019 at 11:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .