mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Use win32 ShellExecute API to open URL with default browser
This commit is contained in:
parent
229c32ccad
commit
bb41ad791f
@ -37,6 +37,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import com.sun.jna.Native;
|
import com.sun.jna.Native;
|
||||||
import com.sun.jna.Pointer;
|
import com.sun.jna.Pointer;
|
||||||
|
import com.sun.jna.platform.win32.Shell32;
|
||||||
import com.sun.jna.win32.StdCallLibrary;
|
import com.sun.jna.win32.StdCallLibrary;
|
||||||
import com.sun.jna.win32.W32APIOptions;
|
import com.sun.jna.win32.W32APIOptions;
|
||||||
|
|
||||||
@ -129,11 +130,15 @@ public class Platform extends processing.app.Platform {
|
|||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
// in this case convert the path to a "file:" url
|
// in this case convert the path to a "file:" url
|
||||||
url = file.toURI().toString();
|
url = file.toURI().toString();
|
||||||
|
|
||||||
// this allows to open the file on Windows 10 that
|
|
||||||
// has a more strict permission policy for cmd.exe
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (url.startsWith("http") || url.startsWith("file:")) {
|
||||||
|
// this allows to open the file on Windows 10 that
|
||||||
|
// has a more strict permission policy for cmd.exe
|
||||||
|
final int SW_SHOW = 5;
|
||||||
|
Shell32.INSTANCE.ShellExecute(null, null, url, null, null, SW_SHOW);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// this is not guaranteed to work, because who knows if the
|
// this is not guaranteed to work, because who knows if the
|
||||||
// path will always be c:\progra~1 et al. also if the user has
|
// path will always be c:\progra~1 et al. also if the user has
|
||||||
@ -150,18 +155,12 @@ public class Platform extends processing.app.Platform {
|
|||||||
// "Access is denied" in both cygwin and the "dos" prompt.
|
// "Access is denied" in both cygwin and the "dos" prompt.
|
||||||
//Runtime.getRuntime().exec("cmd /c " + currentDir + "\\reference\\" +
|
//Runtime.getRuntime().exec("cmd /c " + currentDir + "\\reference\\" +
|
||||||
// referenceFile + ".html");
|
// referenceFile + ".html");
|
||||||
if (url.startsWith("http") || url.startsWith("file:")) {
|
|
||||||
// open dos prompt, give it 'start' command, which will
|
// just launching the .html file via the shell works
|
||||||
// open the url properly. start by itself won't work since
|
// but make sure to chmod +x the .html files first
|
||||||
// it appears to need cmd
|
// also place quotes around it in case there's a space
|
||||||
Runtime.getRuntime().exec("cmd /c start \"\" \"" + url + "\"");
|
// in the user.dir part of the url
|
||||||
} else {
|
Runtime.getRuntime().exec("cmd /c \"" + url + "\"");
|
||||||
// just launching the .html file via the shell works
|
|
||||||
// but make sure to chmod +x the .html files first
|
|
||||||
// also place quotes around it in case there's a space
|
|
||||||
// in the user.dir part of the url
|
|
||||||
Runtime.getRuntime().exec("cmd /c \"" + url + "\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user