怎么在TC中重新启动机器?

walkline 2003-09-29 03:42:46
谢谢!
...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
walkline 2003-09-29
  • 打赏
  • 举报
回复
unsinged char code[]={0xea,0x0,0xff,0xff};
(*(void(far*)()code)();
载http://www.china-askpro.com/cpp.shtml
walkline 2003-09-29
  • 打赏
  • 举报
回复
我可以给大家一个方法!
这是我刚找到的!
你们可以测试一下,看行不行!
simclock 2003-09-29
  • 打赏
  • 举报
回复
纯DOS下可以引入汇编解决吧
fireseed 2003-09-29
  • 打赏
  • 举报
回复
这是和操作系统紧密相关的操作,TC做为一个开发环境、编译器和标准库是不可能提供这样的功能的。

在Win32下利用API的方法如下:


Platform SDK: Windows System Information
Shutting Down
You can use the ExitWindowsEx function to shut down the system. Shutting down flushes file buffers to disk and brings the system to a condition in which it is safe to turn off the computer.

Windows NT/2000/XP: The following example enables the SE_SHUTDOWN_NAME privilege and then shuts down the system.

HANDLE hToken;
TOKEN_PRIVILEGES tkp;

// Get a token for this process.

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
error("OpenProcessToken");

// Get the LUID for the shutdown privilege.

LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

// Get the shutdown privilege for this process.

AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);

// Cannot test the return value of AdjustTokenPrivileges.

if (GetLastError() != ERROR_SUCCESS)
error("AdjustTokenPrivileges");

// Shut down the system and force all applications to close.

if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
error("ExitWindowsEx");
For more information about setting security privileges, see Privileges.

Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)


fireseed 2003-09-29
  • 打赏
  • 举报
回复
这是和操作系统紧密相关的操作,TC做为一个开发环境、编译器和标准库是不可能提供这样的功能的。

在Win32下利用API的方法如下:


Platform SDK: Windows System Information
Shutting Down
You can use the ExitWindowsEx function to shut down the system. Shutting down flushes file buffers to disk and brings the system to a condition in which it is safe to turn off the computer.

Windows NT/2000/XP: The following example enables the SE_SHUTDOWN_NAME privilege and then shuts down the system.

HANDLE hToken;
TOKEN_PRIVILEGES tkp;

// Get a token for this process.

if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
error("OpenProcessToken");

// Get the LUID for the shutdown privilege.

LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);

tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

// Get the shutdown privilege for this process.

AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);

// Cannot test the return value of AdjustTokenPrivileges.

if (GetLastError() != ERROR_SUCCESS)
error("AdjustTokenPrivileges");

// Shut down the system and force all applications to close.

if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
error("ExitWindowsEx");
For more information about setting security privileges, see Privileges.

Platform SDK Release: August 2001 What did you think of this topic?
Let us know. Order a Platform SDK CD Online
(U.S/Canada) (International)


玄豹 2003-09-29
  • 打赏
  • 举报
回复
不太明白意思!

69,364

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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