16

How can I get to a Steam game folder without hardcoding it?

Instead of hardcoding C:\Steam\steamapps\common\<game_folder>\GameData in my code can I use something involving the steamappid of a game to obtain this information automatically?

tezzo
  • 10,858
  • 1
  • 25
  • 48
Thomsen1707
  • 193
  • 1
  • 1
  • 13

1 Answers1

27

In order to obtain a Steam games folder you have to follow this steps:

  1. find Steam installation folder
  2. check Steam acf files and libraryfolders.vdf

You can find Steam InstallPath in windows registry:

  • 32-bit: HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam
  • 64-bit: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam

You can read a Value from a Registry Key using this code:

Dim strSteamInstallPath as String = My.Computer.Registry.GetValue(
    "HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing)

MsgBox("The install path is " & strSteamInstallPath)

Once you have Steam main folder (the one containing steam.exe) you can read games installation folder from appmanifest_<steamappid>.acf files contained in \steamapps subfolder.

For example, appmanifest_2280.acf contains informations about Ultimate Doom.

You can search for a particular steamappid or analyze every files and get game name from name key.

Also check libraryfolders.vdf in \steamapps subfolder for other game installation folders.

For example I have some games in D:\mygames so my libraryfolders.vdf is:

"LibraryFolders"
{
    "TimeNextStatsReport"   "xxxxxxxxxxx"
    "ContentStatsID"        "xxxxxxxxxxx"
    "1"                     "D:\\mygames"
}

Once you have this alternative folder, check for acm files contained in \steamapps subfolder.

tezzo
  • 10,858
  • 1
  • 25
  • 48
  • FORGET THAT! I just needed to add \Steam to the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\ , and now it pops up. THANK YOU MY GOOD SIR! Could you edit your answer to this? And ill mark it as the answer :) – Thomsen1707 Dec 04 '15 at 15:56
  • answer updated. sorry but I don't have steam installed so I can't test the registry key I find on steam faq. – tezzo Dec 04 '15 at 16:01
  • No worries, at all man. It is working beautifully. Thank you – Thomsen1707 Dec 04 '15 at 16:04
  • May I ask the exact applicability of this answer? The original question was about the game folder, does this refer to that folder or to the application folder? Can this folder be changed by the user? if so, is this registry entry being updated accordingly? That is: is this surely a reliable way to know the games folder for Steam under the most likely conditions? If this is a reliable enough answer, the whole question might not be completely off-topic (+ useful for someone else). – varocarbas Dec 04 '15 at 16:10
  • 1
    @varocarbas This is good enough for me to work further with. It shows where Steam is located. In my case: `C:\Program Files(x86)\Steam` and then i add `\steamapps\common\*game*\gamedata` to pinpoint the game folders location. Though now ive got another problem. Ive got another steam games folder on my ssd I:\ which, no, it does not update. But this definitely helped me to understand how to do it, and now ive got another goal, which i will be taking on. – Thomsen1707 Dec 04 '15 at 16:22
  • @Thomsen1707 Happy to read that all this helped you. But I wanted to clarify the exact applicability of this answer to the original question "how to locate the games folder?", mainly for future readers. I guess that your last comment is clear enough on this front. – varocarbas Dec 04 '15 at 16:29
  • @varocarbas Yea, it basicly gives out the place where Steam was originally installed. Mine was installed on the C:\ drive in the `Program Files(x86)` folder. So instead of hardcoding `C:\Program Files(x86)\Steam\steamapps\common\*game*\gamedata`. You would create a variable with the registry placement, and then use it to show the specific users path to the Steam folder. E.g. `Variable & "\steamapps\common\*game*\gamedata"` – Thomsen1707 Dec 04 '15 at 16:41
  • 1
    @Thomsen1707 Some people like me have multiple folders where games can be installed. I have a rather small SSD on my laptop as my main drive and a larger and slower drive. I put a few games I play often on my C: drive and have another library folder on my D: drive for games that are very larger or that I don't play often. In that case you would need to look deeper and parse `libraryfolders.vdf` – Jason Goemaat Dec 20 '21 at 08:04