C# Windows CE 5.0 error: Can't find entry point ExitWindowsEx in PInvoke DLL coredll
I need to programatically shutdown a Windows CE 5.0 tablet using Microsoft.NET SDK CompactFramework v2.0. I tried using the solution here but got the error message
Can't find entry point ExitWindowsEx in PInvoke DLL coredll
Is there a way to add ExitWindowsEx to my build? Do I need a different coredll?
[Flags]
public enum ExitFlags
{
Reboot = 0x02,
PowerOff = 0开发者_运维技巧x08
}
[DllImport("coredll")]
public static extern int ExitWindowsEx(ExitFlags flags, int reserved);
private static void buttonShutdown_Click(object sender, EventArgs e)
{
ExitWindowsEx(ExitFlags.PowerOff, 0);
}
private static void buttonRestart_Click(object sender, EventArgs e)
{
ExitWindowsEx(ExitFlags.Reboot, 0);
}
You can't just swap out coredll.dll, it's part of the OS. To change coredll, you need an entirely new OS.
That said, it's not clear that you need one. ExitWindowsEx
is likely not the call you want to be making (it's not supported in CE), but instead you probably should be calling KernelIoControl
with IOCTL_HAL_REBOOT for a soft reset.
There really is no standard "power off" so if you truly need to shut down power, check with your OEM. There is, however, a device Suspend mode (assuming it's in your specific OS). Suspend can be gotten at programmatically by P/Invoking GwesPowerOffSystem
or post a VK_OFF key to the keyboard stream.
精彩评论