Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
90 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package system.os; | ||
|
||
import ui.Main; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author LM. Garret (admin@gameroom.me) | ||
* @date 07/06/2017. | ||
*/ | ||
public class WinReg { | ||
public final static String HKLM = "HKLM"; | ||
|
||
public static String readString(String hkey, String key, String valueName) { | ||
Terminal terminal = new Terminal(false); | ||
try { | ||
String[] result = terminal.execute("reg query", hkey + "\\" + key, "/v", valueName); | ||
String lineStart = valueName + " " + "REG_SZ "; | ||
for (String line : result) { | ||
if (line.trim().startsWith(lineStart)) { | ||
return line.trim().substring(lineStart.length()); | ||
} | ||
} | ||
} catch (IOException e) { | ||
Main.LOGGER.error("WinReg: could not find reg key"); | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
public static String readDataPath() { | ||
String dataPath32 = readString(HKLM, "Software\\GameRoom", "DataPath"); | ||
if (dataPath32 != null) { | ||
return dataPath32; | ||
} | ||
String dataPath64 = readString(HKLM, "Software\\WOW6432NODE\\GameRoom", "DataPath"); | ||
if (dataPath64 != null) { | ||
return dataPath64; | ||
} | ||
String appdataFolder = System.getenv("APPDATA"); | ||
return appdataFolder + File.separator + "GameRoom"; | ||
} | ||
} |