I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit e93a2ddd authored by hypercubus's avatar hypercubus Committed by zzz
Browse files

now directly reading the default browser from the registry on Windows

parent 57b9c406
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,16 @@
package net.i2p.apps.systray;
import net.i2p.util.ShellCommand;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import net.i2p.util.ShellCommand;
/**
* A quick and simple multi-platform URL launcher. It attempts to launch the
* default browser for the host platform first, then popular third-party
......@@ -60,10 +65,29 @@ public class UrlLauncher {
} else if (osName.startsWith("Windows")) {
if (_shellCommand.executeSilentAndWaitTimed("rundll32 url.dll,FileProtocolHandler " + url, 5))
return true;
String browserString = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"";
BufferedReader bufferedReader = null;
_shellCommand.executeSilentAndWaitTimed("regedit /E default_browser.reg \"HKEY_CLASSES_ROOT\\http\\shell\\open\\command\"", 5);
try {
bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream("default_browser.reg")));
for (String line; (line = bufferedReader.readLine()) != null; ) {
if (line.startsWith("@=\"")) {
browserString = line.substring(3, line.toLowerCase().indexOf(".exe") + 3);
}
}
} catch (Exception e) {
// Defaults to IE.
}
try {
bufferedReader.close();
} catch (IOException e) {
// No worries.
}
new File("default_browser.reg").delete();
if (_shellCommand.executeSilentAndWaitTimed("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" " + url, 5))
if (_shellCommand.executeSilentAndWaitTimed(browserString + " " + url, 5))
return true;
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment