Find steam games folder [closed]

独自空忆成欢 提交于 2019-12-18 12:34:41

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/34090258/find-steam-games-folder

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!