mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-18 20:39:10 +00:00
Issue #464 Javaw and ffdec open and closes: fixed
This commit is contained in:
@@ -173,10 +173,10 @@ public class CommandLineArgumentParser {
|
||||
}
|
||||
}
|
||||
if (nextParam.equals("-removefromcontextmenu")) {
|
||||
ContextMenuTools.addToContextMenu(false);
|
||||
ContextMenuTools.addToContextMenu(false, true);
|
||||
System.exit(0);
|
||||
} else if (nextParam.equals("-addtocontextmenu")) {
|
||||
ContextMenuTools.addToContextMenu(true);
|
||||
ContextMenuTools.addToContextMenu(true, true);
|
||||
System.exit(0);
|
||||
} else if (nextParam.equals("-proxy")) {
|
||||
parseProxy(args);
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import com.sun.jna.platform.win32.WinUser;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -63,7 +65,7 @@ public class ContextMenuTools {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean addToContextMenu(boolean add) {
|
||||
public static boolean addToContextMenu(boolean add, boolean fromCommandLine) {
|
||||
if (add == isAddedToContextMenu()) {
|
||||
return true;
|
||||
}
|
||||
@@ -73,15 +75,15 @@ public class ContextMenuTools {
|
||||
|
||||
if (add) {
|
||||
String exeName = Platform.is64Bit() ? exeName64 : exeName32;
|
||||
return addToContextMenu(add, exeName);
|
||||
return addToContextMenu(add, fromCommandLine, exeName);
|
||||
} else {
|
||||
// remove both 32 and 64 bit references
|
||||
addToContextMenu(add, exeName32);
|
||||
return addToContextMenu(add, exeName64);
|
||||
return addToContextMenu(add, fromCommandLine, exeName32) &&
|
||||
addToContextMenu(add, fromCommandLine, exeName64);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean addToContextMenu(boolean add, String exeName) {
|
||||
private static boolean addToContextMenu(boolean add, boolean fromCommandLine, String exeName) {
|
||||
final String extensions[] = new String[]{"swf", "gfx"};
|
||||
|
||||
final WinReg.HKEY REG_CLASSES_HKEY = WinReg.HKEY_LOCAL_MACHINE;
|
||||
@@ -198,16 +200,20 @@ public class ContextMenuTools {
|
||||
}
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
//Updating registry failed, try elevating rights
|
||||
SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO();
|
||||
sei.fMask = 0x00000040;
|
||||
sei.lpVerb = new WString("runas");
|
||||
sei.lpFile = new WString(appDir + exeName);
|
||||
sei.lpParameters = new WString(add ? "-addtocontextmenu" : "-removefromcontextmenu");
|
||||
sei.nShow = WinUser.SW_NORMAL;
|
||||
Shell32.INSTANCE.ShellExecuteEx(sei);
|
||||
//Wait till exit
|
||||
Kernel32.INSTANCE.WaitForSingleObject(sei.hProcess, 1000 * 60 * 60 * 24 /*1 day max*/);
|
||||
if (!fromCommandLine) {
|
||||
//Updating registry failed, try elevating rights
|
||||
SHELLEXECUTEINFO sei = new SHELLEXECUTEINFO();
|
||||
sei.fMask = 0x00000040;
|
||||
sei.lpVerb = new WString("runas");
|
||||
sei.lpFile = new WString(appDir + exeName);
|
||||
sei.lpParameters = new WString(add ? "-addtocontextmenu" : "-removefromcontextmenu");
|
||||
sei.nShow = WinUser.SW_NORMAL;
|
||||
Shell32.INSTANCE.ShellExecuteEx(sei);
|
||||
//Wait till exit
|
||||
Kernel32.INSTANCE.WaitForSingleObject(sei.hProcess, 1000 * 60 * 60 * 24 /*1 day max*/);
|
||||
} else {
|
||||
Logger.getLogger(ContextMenuTools.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ public class Main {
|
||||
if (!offered) {
|
||||
if (Platform.isWindows()) {
|
||||
if ((!ContextMenuTools.isAddedToContextMenu()) && View.showConfirmDialog(null, "Do you want to add FFDec to context menu of SWF files?\n(Can be changed later from main menu)", "Context menu", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
ContextMenuTools.addToContextMenu(true);
|
||||
ContextMenuTools.addToContextMenu(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ public class MainFrameClassicMenu implements MainFrameMenu, ActionListener {
|
||||
if (miAssociate.isSelected() == ContextMenuTools.isAddedToContextMenu()) {
|
||||
return;
|
||||
}
|
||||
ContextMenuTools.addToContextMenu(miAssociate.isSelected());
|
||||
ContextMenuTools.addToContextMenu(miAssociate.isSelected(), false);
|
||||
|
||||
//Update checkbox menuitem accordingly (User can cancel rights elevation)
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@@ -541,7 +541,7 @@ public class MainFrameRibbonMenu implements MainFrameMenu, ActionListener {
|
||||
if (miAssociate.isSelected() == ContextMenuTools.isAddedToContextMenu()) {
|
||||
return;
|
||||
}
|
||||
ContextMenuTools.addToContextMenu(miAssociate.isSelected());
|
||||
ContextMenuTools.addToContextMenu(miAssociate.isSelected(), false);
|
||||
|
||||
//Update checkbox menuitem accordingly (User can cancel rights elevation)
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
Reference in New Issue
Block a user