|
22 | 22 |
|
23 | 23 | package processing.app.windows;
|
24 | 24 |
|
| 25 | +import com.sun.jna.platform.win32.Advapi32Util; |
| 26 | +import com.sun.jna.platform.win32.WinReg; |
25 | 27 | import org.apache.commons.exec.CommandLine;
|
26 | 28 | import org.apache.commons.exec.DefaultExecutor;
|
27 | 29 | import org.apache.commons.exec.Executor;
|
@@ -52,25 +54,15 @@ public void init() throws IOException {
|
52 | 54 | }
|
53 | 55 |
|
54 | 56 | private void recoverSettingsFolderPath() throws IOException {
|
55 |
| - String path = getFolderPathFromRegistry("AppData"); |
| 57 | + String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData"); |
56 | 58 | this.settingsFolder = new File(path, "Arduino15");
|
57 | 59 | }
|
58 | 60 |
|
59 | 61 | private void recoverDefaultSketchbookFolder() throws IOException {
|
60 |
| - String path = getFolderPathFromRegistry("Personal"); |
| 62 | + String path = Advapi32Util.registryGetStringValue(WinReg.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Personal"); |
61 | 63 | this.defaultSketchbookFolder = new File(path, "Arduino");
|
62 | 64 | }
|
63 | 65 |
|
64 |
| - private String getFolderPathFromRegistry(String folderType) throws IOException { |
65 |
| - ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
66 |
| - Executor executor = new DefaultExecutor(); |
67 |
| - executor.setStreamHandler(new PumpStreamHandler(baos, null)); |
68 |
| - |
69 |
| - CommandLine toDevicePath = CommandLine.parse("reg query \"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v \"" + folderType + "\""); |
70 |
| - executor.execute(toDevicePath); |
71 |
| - return new RegQueryParser(new String(baos.toByteArray())).getValueOfKey(); |
72 |
| - } |
73 |
| - |
74 | 66 | /**
|
75 | 67 | * Remove extra quotes, slashes, and garbage from the Windows PATH.
|
76 | 68 | */
|
|
0 commit comments