一个小问题~!~!~!~!~!~!~!

qweiop 2005-05-05 06:16:29
在使用user32.dll里面的Api函数 ExitWindowsEx 时 出现了一点小问题。
代码如下:
[ DllImport("user32") ]
public static extern long ExitWindowsEx(long uFlags, long dwReserved ) ;

public static void ShoutDownWindows() //关机
{
ExitWindowsEx(1,dwReserved);
}
public static void ReBootWindows() //重启
{
ExitWindowsEx(2,dwReserved);
}
public static void LogOffWindows() //注消
{
ExitWindowsEx(0,dwReserved);
}

其中”注消“可以 但是关机,和重启,就没有什么反应。这是为什么?
操作系统:Windows2000 Server
以Administrator用启运行!

那位大哥请指点一下!
...全文
54 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
qweiop 2005-05-06
  • 打赏
  • 举报
回复
问题已解决~!
多谢~1
ILearnCSharp 2005-05-05
  • 打赏
  • 举报
回复
望尘莫及
laZZe 2005-05-05
  • 打赏
  • 举报
回复
BOOL ExitWindowsEx(

UINT uFlags, // shutdown operation
DWORD dwReserved // reserved
);


Parameters

uFlags

Specifies the type of shutdown. This parameter must be some combination of the following values:

Value Meaning
EWX_FORCE Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.
EWX_REBOOT Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.
EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Remarks section. Windows 95: Security privileges are not supported or required.

这个是delphi中的~~~
laZZe 2005-05-05
  • 打赏
  • 举报
回复
查一下:ExitWindowsEx~~
hackate 2005-05-05
  • 打赏
  • 举报
回复
我是不太记得了哦。我记得以前用VB写惯技代码的时候,好象有个操作系统还是什么情况下还要多加什么才能做到关机的,具体忘掉了,看看有人知道不。。
singlepine 2005-05-05
  • 打赏
  • 举报
回复
把“关机,和重启”下面的代码换成“注销”下面的代码,试试会是什么效果,然后把注销下面的代码换成“关机,和重启”,再试试,又是什么效果。

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧