-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add Windows Application Recovery and Restart API #1293
Comments
Hi @ebourg. JNA is a user-supported project, so it's unlikely this will be done unless you do it, or wait for another user who needs these mappings. These are straightforward mappings you could easily add. See the example in the FAQ here. Feel free to ask for help on the jna-users mailing list. |
@ebourg I had a look at this and the first functions can be found here: #1294 While the unittest demonstrates, that the functions are correctly run, I failed to use it really - this was not restartet: public class Main {
public static void main(String[] args) {
HRESULT hres = Kernel32.INSTANCE.RegisterApplicationRestart(Native.toCharArray("-jar c:\\temp\\restarttest.jar restart"), 0);
COMUtils.checkRC(hres);
System.out.println(Kernel32Util.QueryFullProcessImageName(Kernel32.INSTANCE.GetCurrentProcess(), 0));
Native.setProtected(false);
SwingUtilities.invokeLater(() -> {
JFrame frame = new JFrame("Dummy Window");
frame.setSize(800, 600);
JLabel label = new JLabel(Arrays.toString(args));
JButton button = new JButton("Kill");
button.addActionListener((ae) -> {
new Pointer(0).getByteArray(0, 1024);
});
frame.add(label);
frame.add(button);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
});
}
} So it would be nice to get a pointer into the right direction. |
Thank you, I've started implementing the 3 restart functions too, and I'm trying to validate this, either by crashing the JVM (not that easy!) or by updating the system. |
Indeed the JVM prevents windows crash handling to kick in. Here is a sample that worked for me: https://github.com/matthiasblaesing/JNA-Demos/tree/master/ApplicationRestart |
For anyone looking into this - the first bindings were merged |
Would it be possible to add the Windows Application Recovery and Restart API functions to WinBase.java please? Especially the
RegisterApplicationRestart
function which can be used to ensure an application is automatically restarted when the system restarts after an update.The text was updated successfully, but these errors were encountered: