<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=908323</guid>
        <pubDate>Mon, 07 Nov 2005 10:27:42 +0000</pubDate>
        <title>как программно выключить комп?</title>
        <link>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=908323</link>
        <description><![CDATA[tIce: заклинило меня ;)  :D  :D  :D  поправил.]]></description>
        <author>tIce</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=908313</guid>
        <pubDate>Mon, 07 Nov 2005 10:15:34 +0000</pubDate>
        <title>как программно выключить комп?</title>
        <link>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=908313</link>
        <description><![CDATA[LiquidStorm: <div class='tag-quote'><a class='tag-quote-link' href='https://forum.sources.ru/index.php?showtopic=120878&view=findpost&p=907997'><span class='tag-quote-prefix'>Цитата</span></a> <span class='tag-quote__quote-info'>tIce &#064; <time class="tag-quote__quoted-time" datetime="2005-11-07T06:22:37+00:00">07.11.05, 06:22</time></span><div class='quote '><br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">&nbsp;&nbsp; &nbsp;if not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Exit Error&#39;, &#39;OpenProcessToken() Failed&#39;, MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Exit;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Exit Error&#39;, &#39;OpenProcessToken() Failed&#39;, MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Exit;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)</div></ol></div></div></div></div><script>preloadCodeButtons('1');</script></div></div><br>
А зачем два раза дублируется вызов OpenProcessToken()?]]></description>
        <author>LiquidStorm</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=907997</guid>
        <pubDate>Mon, 07 Nov 2005 06:22:37 +0000</pubDate>
        <title>как программно выключить комп?</title>
        <link>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=907997</link>
        <description><![CDATA[tIce: выключает с любой версией windows.<br>
<div class='tag-code'><span class='pre_code'></span><div class='code  code_collapsed ' title='Подсветка синтаксиса доступна зарегистрированным участникам Форума.' style=''><div><div><ol type="1"><div class="code_line">function GetWinVersion: string;</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;VersionInfo: TOSVersionInfo;</div><div class="code_line">&nbsp;&nbsp;OSName: string;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;// устанавливаем размер записи</div><div class="code_line">&nbsp;&nbsp;VersionInfo.dwOSVersionInfoSize := SizeOf( TOSVersionInfo );</div><div class="code_line">&nbsp;&nbsp;if Windows.GetVersionEx( VersionInfo ) then</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;with VersionInfo do</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;case dwPlatformId of</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32s: OSName := &#39;Win32s&#39;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_WINDOWS: OSName := &#39;Windows 95&#39;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;VER_PLATFORM_WIN32_NT: OSName := &#39;Windows NT&#39;;</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;end; // case dwPlatformId</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Result := OSName + &#39; Version &#39; + IntToStr( dwMajorVersion ) + &#39;.&#39; + IntToStr( dwMinorVersion ) +</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;#13#10&#39; (Build &#39; + IntToStr( dwBuildNumber ) + &#39;: &#39; + szCSDVersion + &#39;)&#39;;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; // with VersionInfo</div><div class="code_line">&nbsp;&nbsp;end // if GetVersionEx</div><div class="code_line">&nbsp;&nbsp;else</div><div class="code_line">&nbsp;&nbsp;Result := &#39;&#39;;</div><div class="code_line">end;</div><div class="code_line">&nbsp;</div><div class="code_line">procedure ShutDown;</div><div class="code_line">const</div><div class="code_line">&nbsp;&nbsp;SE_SHUTDOWN_NAME = &#39;SeShutdownPrivilege&#39;; // Borland forgot this declaration</div><div class="code_line">var</div><div class="code_line">&nbsp;&nbsp;hToken: THandle;</div><div class="code_line">&nbsp;&nbsp;tkp: TTokenPrivileges;</div><div class="code_line">&nbsp;&nbsp;tkpo: TTokenPrivileges;</div><div class="code_line">&nbsp;&nbsp;zero: DWORD;</div><div class="code_line">begin</div><div class="code_line">&nbsp;&nbsp;if Pos(&#39;Windows NT&#39;, GetWinVersion) = 1 then // we&#39;ve got to do a whole buch of things</div><div class="code_line">&nbsp;&nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp;zero := 0;</div><div class="code_line">&nbsp;&nbsp; &nbsp;if not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Exit Error&#39;, &#39;OpenProcessToken() Failed&#39;, MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Exit;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; // if not OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken)</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;// SE_SHUTDOWN_NAME</div><div class="code_line">&nbsp;&nbsp; &nbsp;if not LookupPrivilegeValue( nil, &#39;SeShutdownPrivilege&#39; , tkp.Privileges[0].Luid ) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Exit Error&#39;, &#39;LookupPrivilegeValue() Failed&#39;, MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Exit;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end; // if not LookupPrivilegeValue( nil, &#39;SeShutdownPrivilege&#39; , tkp.Privileges[0].Luid )</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;tkp.PrivilegeCount := 1;</div><div class="code_line">&nbsp;&nbsp; &nbsp;tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp; &nbsp;AdjustTokenPrivileges(hToken, False, tkp, SizeOf( TTokenPrivileges ), tkpo, zero);</div><div class="code_line">&nbsp;&nbsp; &nbsp;if Boolean(GetLastError()) then</div><div class="code_line">&nbsp;&nbsp; &nbsp;begin</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;MessageBox(0, &#39;Exit Error&#39;, &#39;AdjustTokenPrivileges() Failed&#39;, MB_OK);</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;Exit;</div><div class="code_line">&nbsp;&nbsp; &nbsp;end // if Boolean( GetLastError() )</div><div class="code_line">&nbsp;&nbsp; &nbsp;else</div><div class="code_line">&nbsp;&nbsp; &nbsp; &nbsp;ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, 0 );</div><div class="code_line">&nbsp;</div><div class="code_line">&nbsp;&nbsp;end // if OSVersion = &#39;Windows NT&#39;</div><div class="code_line">&nbsp;&nbsp;else</div><div class="code_line">&nbsp;&nbsp;begin // just shut the machine down</div><div class="code_line">&nbsp;&nbsp; &nbsp;ExitWindowsEx( EWX_FORCE or EWX_SHUTDOWN, 0 );</div><div class="code_line">&nbsp;&nbsp;end; // else</div><div class="code_line">end;</div></ol></div></div></div></div>]]></description>
        <author>tIce</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=907782</guid>
        <pubDate>Sun, 06 Nov 2005 18:32:13 +0000</pubDate>
        <title>как программно выключить комп?</title>
        <link>https://forum.sources.ru/index.php?showtopic=120878&amp;view=findpost&amp;p=907782</link>
        <description><![CDATA[Darkmaster: как можно при помощи Делфи выключить компьютер?]]></description>
        <author>Darkmaster</author>
        <category>Delphi: Система, Windows API</category>
      </item>
	
      </channel>
      </rss>
	