Page 1 of 2
Reboot after close
Posted: Tue Dec 18, 2012 8:53 am
by KevinA.
How can I reboot my application after I do a close of the application, without having to download or to power it off?
Re: Reboot after close
Posted: Tue Dec 18, 2012 8:57 am
by mark.monroe
This topic has been already covered in this
forum post. You just need to add the code to the event that you want. In the example script, it is associated with a button.
Re: Reboot after close
Posted: Tue Dec 18, 2012 12:59 pm
by KevinA.
I downloaded your zip file and tried it but each time I try it simulation as soon as I click one of the buttons an error closes the program. Here is the error;
Also when I copy the reboot part of the HMI in my application, I have all these errors.
Re: Reboot after close
Posted: Tue Dec 18, 2012 2:22 pm
by mark.monroe
That file is used to reboot a HMI that runs Windows CE. Running the application in simulation mode on a PC will not work because there are different functions used to reboot a Windows 7 machine as opposed to a Windows CE machine.
What is the OS and/or name of the HMI panel that you are trying to reboot?
Re: Reboot after close
Posted: Tue Dec 18, 2012 3:28 pm
by KevinA.
I am using a T10A and T7A HMI panel. Will it work with those?
Re: Reboot after close
Posted: Wed Dec 19, 2012 8:50 am
by mark.monroe
Yes, those run Windows CE. Try downloading your application to one of those terminals and see it the button works.
Re: Reboot after close
Posted: Thu Dec 20, 2012 8:20 am
by KevinA.
I've put this code in my application
Code: Select all
void Button36_Click(System.Object sender, System.EventArgs e)
{
string systemStateName = "reboot";
uint nError = CESetSystemPowerState(systemStateName.ToCharArray(), 0, 0x0);
}
but I can't download to my HMI cause he gives me this error while trying :S
Re: Reboot after close
Posted: Thu Dec 20, 2012 9:37 am
by mark.monroe
You need to add the code that defines the CESetSystemPowerState function.
Re: Reboot after close
Posted: Thu Dec 20, 2012 10:50 am
by KevinA.
which code is it? If it is this one
Code: Select all
[DllImport("coredll.dll", EntryPoint = "GetSystemPowerState")]
private static extern uint CEGetSystemPowerState(StringBuilder Buffer, uint Length, out uint Flags);
[DllImport("coredll.dll", EntryPoint = "SetSystemPowerState")]
private static extern uint CESetSystemPowerState(char[] sState, uint StateFlags, uint Options);
When I put those lines it gives me those errors
Re: Reboot after close
Posted: Thu Dec 20, 2012 11:23 am
by mark.monroe
Copy all the "using" values as well.
Specifically:
using System.Text;
using System.Runtime.InteropServices;