Windows 2000还是WIN32,还是用ExitWindowsEx。
解决方案 »
- 在Windows API中,如何实现鼠标放在工具栏某个按钮上显示此按钮的文字信息??
- 大家vc编程,用什么配合做界面呀,如何与vc配合的。听说有专门配合vc做界面的软件,是什么呀?
- 怎么取消掉IE控件的滚动条啊
- 编辑框OnChange事件的行为与multiline属性的关系, 大侠进来解释一下这个现象
- 用MFC开发ActiveX控件,然后用一个已经存在的代码做成模板,可是用此模板生成的多份控件只能是最后注册的才能显示在控件栏里,为什么?如
- 怎样才能列举出生成AVI文件的所有压缩选项,功能如:AVISaveOptions函数
- 朋友们,谁没有父母啊,指点一下吧
- 高分求个文字播放器程序!
- 如何建一個文件夾?問大蝦!!!!!!謝謝
- 请问各位是不是要实现上下文帮助必须使用.hlp文件?
- 菜问题:如何声明并使用CFileDialog对话框?
- 要命!
BOOL ExitWindowsEx(
UINT uFlags, // shutdown operation
DWORD dwReserved // reserved
);
uFlags
Specifies the type of shutdown. This parameter must include one of the following values: Value Meaning
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 Res section.
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 Res section.
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 Res section.
This parameter can optionally include the following values: Value Meaning
EWX_FORCE Forces processes to terminate. When this flag is set, the system does not send the WM_QUERYENDSESSION and WM_ENDSESSION messages. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
EWX_FORCEIFHUNG Windows NT 5.0 and later: Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message. This flag is ignored if EWX_FORCE is used.
查查以Access开头的API吧。
OSVERSIONINFO oi;
oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&oi);
if (oi.dwPlatformId == VER_PLATFORM_WIN32_NT)
//if ((ver & 0x0000ffff) == ver and and (ver & 0x0000ffff) == 5)
{
HANDLE handle;
TOKEN_PRIVILEGES tkp; OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES and TOKEN_QUERY, &handle);
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(handle, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
}
::ExitWindowsEx(flag, 0);注:其中的flag是我在前边定义的,根据选选择是重起机还是关机设定。这段程序可在NT和2000下运行。