<?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>Wizard Software - All things Delphi (and some PHP) &#187; shutdown source</title>
	<atom:link href="http://wizard-soft.com/blog/tag/shutdown-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://wizard-soft.com/blog</link>
	<description>Delphi, Pascal, PHP, programming and (Wizard) Software</description>
	<lastBuildDate>Tue, 01 Dec 2009 06:36:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Windows Shutdown with Delphi</title>
		<link>http://wizard-soft.com/blog/2009/01/09/windows-shutdown-with-delphi/</link>
		<comments>http://wizard-soft.com/blog/2009/01/09/windows-shutdown-with-delphi/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 13:40:44 +0000</pubDate>
		<dc:creator>Softy</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[shutdown source]]></category>

		<guid isPermaLink="false">http://wizard-soft.com/blog/?p=84</guid>
		<description><![CDATA[Recently I&#8217;ve been doing a lot of torrent downloading and wanted to shutdown my torrent computer after a specified period of time, so, I wrote the following short function, connect it to a TTimer and you&#8217;ve got an automatic (and well-behaved) means of shutting-down Windows XP, Vista and Windows 7.  The RebootParam is: EWX_POWEROFF or [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been doing a lot of torrent downloading and wanted to shutdown my torrent computer after a specified period of time, so, I wrote the following short function, connect it to a TTimer and you&#8217;ve got an automatic (and well-behaved) means of shutting-down Windows XP, Vista and Windows 7.  The RebootParam is: EWX_POWEROFF or EWX_FORCE.</p>
<pre>function MyExitWindows(RebootParam: Longword): Boolean;
var
  TTokenHd: THandle;
  TTokenPvg: TTokenPrivileges;
  cbtpPrevious: DWORD;
  rTTokenPvg: TTokenPrivileges;
  pcbtpPreviousRequired: DWORD;
  tpResult: Boolean;
const
  SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
  if Win32Platform = VER_PLATFORM_WIN32_NT then
  begin
    tpResult := OpenProcessToken(GetCurrentProcess(),
      TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
      TTokenHd);
    if tpResult then
    begin
      tpResult := LookupPrivilegeValue(nil,
                                       SE_SHUTDOWN_NAME,
                                       TTokenPvg.Privileges[0].Luid);
      TTokenPvg.PrivilegeCount := 1;
      TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
      cbtpPrevious := SizeOf(rTTokenPvg);
      pcbtpPreviousRequired := 0;
      if tpResult then
        Windows.AdjustTokenPrivileges(TTokenHd,
                                      False,
                                      TTokenPvg,
                                      cbtpPrevious,
                                      rTTokenPvg,
                                      pcbtpPreviousRequired);
    end;
  end;
  Result := ExitWindowsEx(RebootParam, 0);
end;</pre>
]]></content:encoded>
			<wfw:commentRss>http://wizard-soft.com/blog/2009/01/09/windows-shutdown-with-delphi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

