C# Windows CE 5.0 错误:无法在 PInvoke DLL coredll 中找到入口点 ExitWindowsEx
我需要使用 Microsoft.NET SDK CompactFramework v2.0 以编程方式关闭 Windows CE 5.0 平板电脑。我尝试使用此处的解决方案,但收到错误信息
找不到入口点 ExitWindowsEx 在PInvoke DLL coredll中
有没有办法将 ExitWindowsEx 添加到我的构建中? 我需要不同的 coredll 吗?
[Flags]
public enum ExitFlags
{
Reboot = 0x02,
PowerOff = 0x08
}
[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);
}
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 = 0x08
}
[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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能只替换 coredll.dll,它是操作系统的一部分。要更改 coredll,您需要一个全新的操作系统。
也就是说,尚不清楚您是否需要一个。
ExitWindowsEx
可能不是您想要进行的调用(CE 中不支持它),但您可能应该调用KernelIoControl
与 IOCTL_HAL_REBOOT 进行软重置。实际上没有标准的“关闭电源”,因此如果您确实需要关闭电源,请咨询您的 OEM。但是,有一个设备挂起模式(假设它位于您的特定操作系统中)。可以通过 P/Invoking 以编程方式实现暂停
GwesPowerOffSystem
< /a> 或将 VK_OFF 键发布到键盘流。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 callingKernelIoControl
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.