﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Timothy&#039;s Space &#187; Shutdown</title>
	<atom:link href="http://www.xiaozhou.net/tag/shutdown/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaozhou.net</link>
	<description>君看一叶舟，出没风波里</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>调整当前进程权限并关机</title>
		<link>http://www.xiaozhou.net/vcdevelopment/to-adjust-the-current-process-permissions-and-shutdown-2004-10-21.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/to-adjust-the-current-process-permissions-and-shutdown-2004-10-21.htm#comments</comments>
		<pubDate>Thu, 21 Oct 2004 14:11:51 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[adjust]]></category>
		<category><![CDATA[permission]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[Shutdown]]></category>
		<category><![CDATA[关机]]></category>
		<category><![CDATA[权限]]></category>
		<category><![CDATA[调整]]></category>
		<category><![CDATA[进程]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=33</guid>
		<description><![CDATA[核心代码片断： if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES &#124; TOKEN_QUERY, &#038;hToken)) { MessageBox(&#8220;OpenProcessToken failed!&#8221;); } LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&#038;tkp.Privileges[0].Luid); //获得本地机唯一的标识 tkp.PrivilegeCount = 1; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, FALSE, &#038;tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0); //调整获得的权限 if (GetLastError() != ERROR_SUCCESS) { MessageBox(&#8220;切换系统级权限失败!&#8221;); } fResult =InitiateSystemShutdown( NULL, // 要关的计算机用户名 &#8220;关机时间已到，WINDOWS将在上面的时间内关机，请做好保存工作!&#8221;, // 显示的消息 10, // 关机所需的时间 TRUE, // ask user to close apps FALSE); //设为TRUE为重起，设为FALSE为关机 if(!fResult) { [...]]]></description>
			<content:encoded><![CDATA[<p>核心代码片断：</p>
<p>if (!OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &#038;hToken))<br />
		{<br />
		    MessageBox(&#8220;OpenProcessToken failed!&#8221;);<br />
		}</p>
<p>	    LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&#038;tkp.Privileges[0].Luid); //获得本地机唯一的标识<br />
	    tkp.PrivilegeCount = 1;<br />
	    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br />
        AdjustTokenPrivileges(hToken, FALSE, &#038;tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0); //调整获得的权限</p>
<p>	    if (GetLastError() != ERROR_SUCCESS)<br />
		{<br />
            MessageBox(&#8220;切换系统级权限失败!&#8221;);<br />
		}</p>
<p>	    fResult =InitiateSystemShutdown(<br />
             NULL,                                  // 要关的计算机用户名<br />
             &#8220;关机时间已到，WINDOWS将在上面的时间内关机，请做好保存工作!&#8221;,  // 显示的消息<br />
             10,                                    // 关机所需的时间<br />
             TRUE,                                 // ask user to close apps<br />
             FALSE);                               //设为TRUE为重起，设为FALSE为关机<br />
	    if(!fResult)<br />
		{<br />
             MessageBox(&#8220;初始化系统关机失败！&#8221;);<br />
		}</p>
<p>	    tkp.Privileges[0].Attributes = 0;<br />
        AdjustTokenPrivileges(hToken, FALSE, &#038;tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);</p>
<p>	    if (GetLastError() != ERROR_SUCCESS)<br />
		{<br />
             MessageBox(&#8220;AdjustTokenPrivileges disable failed.&#8221;);<br />
		}</p>
<p>	    ExitWindowsEx(EWX_SHUTDOWN,0);</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/to-adjust-the-current-process-permissions-and-shutdown-2004-10-21.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CMD界面下的关机程序</title>
		<link>http://www.xiaozhou.net/myworks/cmd-interface-shutdown-procedure-2004-09-07.htm</link>
		<comments>http://www.xiaozhou.net/myworks/cmd-interface-shutdown-procedure-2004-09-07.htm#comments</comments>
		<pubDate>Tue, 07 Sep 2004 07:28:29 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[我的拙作]]></category>
		<category><![CDATA[CMD]]></category>
		<category><![CDATA[Shutdown]]></category>
		<category><![CDATA[关机]]></category>
		<category><![CDATA[界面]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=18</guid>
		<description><![CDATA[此程序运行在CMD界面下，支持多参数选择 源代码下载： 点击下载此文件 声明: 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 本站文章均采用 知识共享署名-相同方式共享3.0 协议进行授权，除非注明，本站文章均为原创，转载请注明转自 Timothy&#039;s Space 并应以链接形式标明本文地址!]]></description>
			<content:encoded><![CDATA[<p>此程序运行在CMD界面下，支持多参数选择</p>
<p>源代码下载：</p>
<p><a href="/attachments/month_0409/3zs7_shutdown.rar" target="_blank">点击下载此文件</a></p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/myworks/cmd-interface-shutdown-procedure-2004-09-07.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自动关机程序</title>
		<link>http://www.xiaozhou.net/myworks/automatic-shutdown-process-2004-09-07.htm</link>
		<comments>http://www.xiaozhou.net/myworks/automatic-shutdown-process-2004-09-07.htm#comments</comments>
		<pubDate>Tue, 07 Sep 2004 07:26:25 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[我的拙作]]></category>
		<category><![CDATA[Auto]]></category>
		<category><![CDATA[Shutdown]]></category>
		<category><![CDATA[自动关机]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=17</guid>
		<description><![CDATA[主要实现了定时关机的功能 在NT系统下，和win98不同，需要调整本进程的权限。 主要代码如下： void EnableDebugPriv( void ) { HANDLE hToken; LUID sedebugnameValue; TOKEN_PRIVILEGES tkp; if ( ! OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES &#124; TOKEN_QUERY, &#38;hToken ) ) return; if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &#38;sedebugnameValue ) ) { CloseHandle( hToken ); return; } tkp.PrivilegeCount = 1; tkp.Privileges[0].Luid = sedebugnameValue; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if ( ! AdjustTokenPrivileges( hToken, [...]]]></description>
			<content:encoded><![CDATA[<p>主要实现了定时关机的功能<br />
在NT系统下，和win98不同，需要调整本进程的权限。<br />
主要代码如下：</p>
<p>void EnableDebugPriv( void )<br />
{<br />
HANDLE hToken;<br />
LUID sedebugnameValue;<br />
TOKEN_PRIVILEGES tkp;</p>
<p>if ( ! OpenProcessToken( GetCurrentProcess(),<br />
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &amp;hToken ) )<br />
return;<br />
if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &amp;sedebugnameValue ) )<br />
{<br />
CloseHandle( hToken );<br />
return;<br />
}<br />
tkp.PrivilegeCount = 1;<br />
tkp.Privileges[0].Luid = sedebugnameValue;<br />
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;<br />
if ( ! AdjustTokenPrivileges( hToken, FALSE, &amp;tkp, sizeof tkp, NULL, NULL ) )<br />
CloseHandle( hToken );<br />
}</p>
<p>本程序源代码下载：</p>
<p><a href="/attachments/month_0409/tqjx_autoshutdown.rar" target="_blank">点击下载此文件</a></p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/myworks/automatic-shutdown-process-2004-09-07.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

