<?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>Sharp World &#187; Win32</title>
	<atom:link href="http://sharpmix.net/blog/tag/win32/feed/" rel="self" type="application/rss+xml" />
	<link>http://sharpmix.net/blog</link>
	<description>It&#039;s about C# and video games !</description>
	<lastBuildDate>Fri, 18 Sep 2009 15:43:53 +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>TaskDialog hidden icons.</title>
		<link>http://sharpmix.net/blog/2009/06/28/taskdialog-hidden-icons/</link>
		<comments>http://sharpmix.net/blog/2009/06/28/taskdialog-hidden-icons/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 21:45:19 +0000</pubDate>
		<dc:creator>Abdallah Fdal</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COMCTL32.DLL]]></category>
		<category><![CDATA[TaskDialog]]></category>
		<category><![CDATA[TaskDialogIcon]]></category>
		<category><![CDATA[TaskDialogIndirect]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows API Code Pack]]></category>

		<guid isPermaLink="false">http://managedworld.wordpress.com/?p=108</guid>
		<description><![CDATA[Before starting, you need to know there&#8217;s a small issue on using the API in your project, you can get an Unable to find an entry point name &#8216;TaskDialogIndirect&#8217; in DLL &#8216;comctl32.dll&#8217; error.
To get the whole story, see my post Unable to find an entry point name &#8216;TaskDialogIndirect&#8217; in DLL &#8216;comctl32.dll&#8217;

Thanks to Bart Desmet, you [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Before starting, you need to know there&#8217;s a small issue on using the API in your project, you can get an </strong><em>Unable to find an entry point name &#8216;TaskDialogIndirect&#8217; in DLL &#8216;comctl32.dll&#8217;</em><strong> error.</strong></p>
<p><strong>To get the whole story, see my post </strong><em><a href="http://sharpmix.net/blog/2009/06/23/unable-to-find-an-entry-point-name-taskdialogindirect-in-dll-comctl32-dll/"><strong>Unable to find an entry point name &#8216;TaskDialogIndirect&#8217; in DLL &#8216;comctl32.dll&#8217;</strong></a></em></p>
<hr />
<p style="text-align:left;">Thanks to <a href="http://bartdesmet.net/blogs/bart/archive/2006/09/26/4470.aspx">Bart Desmet</a>, you can access all flavors of icons; these are not present in the <em>TaskDialog</em> documentation, I think they have been removed.</p>
<p style="text-align:left;"><em>Another CancelShutdown ? </em></p>
<p style="text-align: left;"><img title="TaskDialog" src="http://managedworld.files.wordpress.com/2009/06/taskdialog.png" alt="TaskDialog" width="376" height="119" /></p>
<p style="text-align: left;"><img title="TaskDialog (2)" src="http://managedworld.files.wordpress.com/2009/06/taskdialog-2.png" alt="TaskDialog (2)" width="376" height="119" /></p>
<p style="text-align: left;"><img title="TaskDialog (3)" src="http://managedworld.files.wordpress.com/2009/06/taskdialog-3.png" alt="TaskDialog (3)" width="376" height="119" /></p>
<p style="text-align: left;"><img title="TaskDialog (4)" src="http://managedworld.files.wordpress.com/2009/06/taskdialog-4.png" alt="TaskDialog (4)" width="376" height="119" /></p>
<p style="text-align: left;"><img title="TaskDialog (5)" src="http://managedworld.files.wordpress.com/2009/06/taskdialog-5.png" alt="TaskDialog (5)" width="376" height="119" /></p>
<p style="text-align:left;">Replace the <em>TaskDialogStandardIcon</em> definition with the one below.</p>
<pre class="brush: csharp;">
    /// &lt;summary&gt;
    /// Specifies the icon displayed in a task dialog.
    /// &lt;/summary&gt;
    public enum TaskDialogStandardIcon
    {
        /// &lt;summary&gt;
        /// Displays no icons (default).
        /// &lt;/summary&gt;
        None = 0,

        /// &lt;summary&gt;
        /// Displays the warning icon.
        /// &lt;/summary&gt;
        Warning = 65535,

        /// &lt;summary&gt;
        /// Displays the error icon.
        /// &lt;/summary&gt;
        Error = 65534,

        /// &lt;summary&gt;
        /// Displays the Information icon.
        /// &lt;/summary&gt;
        Information = 65533,

        /// &lt;summary&gt;
        /// Displays the User Account Control shield.
        /// &lt;/summary&gt;
        Shield = 65532,

        SecurityShieldBlue = 65531,

        SecurityWarning = 65530,

        SecurityError = 65529,

        SecuritySuccess = 65528,

        SecurityShieldGray = 65527,
    }
</pre>
<p><em><a href="http://sharpmix.net/blog/2009/06/23/unable-to-find-an-entry-point-name-taskdialogindirect-in-dll-comctl32-dll/"><strong> </strong></a></em></p>
<p>If you are lazy like I am, get the code : <a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/TaskDialogHiddenIcons.zip">TaskDialogHiddenIcons</a><a href="../wp-content/uploads/2009/06/TaskDialogHiddenIcons.zip"></a></p>
<p>Too easy,</p>
<ul>
<li> You still have to get the <a href="http://code.msdn.microsoft.com/WindowsAPICodePack">Windows API Code Pack</a>,</li>
<li>Point the <em>Core </em>project location to where you extracted it,</li>
<li>Update the <em>TaskDialogStandardIcon</em> definition with the one provided above,</li>
<li>Enjoy !</li>
</ul>
<p>If you&#8217;re even lazier than I am <em>(I didn&#8217;t know this was possible, I have to meet you right now :-)</em>, go to <em>bin\Debug</em> and run the application&#8217;s .EXE :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://sharpmix.net/blog/2009/06/28/taskdialog-hidden-icons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unable to find an entry point name &#039;TaskDialogIndirect&#039; in DLL &#039;comctl32.dll&#039;</title>
		<link>http://sharpmix.net/blog/2009/06/23/unable-to-find-an-entry-point-name-taskdialogindirect-in-dll-comctl32-dll/</link>
		<comments>http://sharpmix.net/blog/2009/06/23/unable-to-find-an-entry-point-name-taskdialogindirect-in-dll-comctl32-dll/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 18:53:54 +0000</pubDate>
		<dc:creator>Abdallah Fdal</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[COMCTL32.DLL]]></category>
		<category><![CDATA[TaskDialog]]></category>
		<category><![CDATA[TaskDialogIcon]]></category>
		<category><![CDATA[TaskDialogIndirect]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows API Code Pack]]></category>

		<guid isPermaLink="false">http://managedworld.wordpress.com/?p=71</guid>
		<description><![CDATA[For those of you who tried Windows API Code Pack, particularly the TaskDialog managed wrapper, you&#8217;ve probably encountered the following error when trying to run your program.


 
Too bad,
I was happy when I heard they finally released a managed API for those (not yet managed) APIs &#8230;
I have been struggling a lot last year to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align:left;">For those of you who tried <a href="http://code.msdn.microsoft.com/WindowsAPICodePack">Windows API Code Pack</a>, particularly the TaskDialog managed wrapper, you&#8217;ve probably encountered the following error when trying to run your program.</p>
<p style="text-align:left;"><em><br />
</em></p>
<p style="text-align:left;"><em> </em></p>
<p style="text-align:left;">Too bad,</p>
<p style="text-align:left;">I was happy when I heard they finally released a managed API for those (not yet managed) APIs &#8230;</p>
<p style="text-align:left;">I have been struggling a lot last year to try get it working with C#, thanks to Chris Dunford&#8217;s <a href="http://adventuresinwpf.blogspot.com/2008/09/vistabridge-considered-harmful.html">VistaBridge Considered Harmful; An Alternative</a> which would have otherwise, never happened.</p>
<p style="text-align:left;">(Credits goes to Kenny Kerr too, for <a href="http://weblogs.asp.net/kennykerr/archive/2006/07/18/Windows-Vista-for-Developers-_1320_-Part-2-_1320_-Task-Dialogs-in-Depth.aspx">his article</a> and Bart Desmet&#8217;s <a href="http://bartdesmet.net/blogs/bart/archive/2006/09/26/4470.aspx">Using Windows Vista&#8217;s TaskDialog API in managed code</a>)</p>
<p style="text-align:left;"><strong>The main problem <span style="text-decoration: line-through;">is</span> was the <a href="http://msdn.microsoft.com/en-us/library/aa374153(VS.85).aspx">activation context</a>,</strong></p>
<p style="text-align:left;">Solution is here :</p>
<p style="text-align:left;"><a href="http://blogs.codes-sources.com/tom/archive/2009/05/20/seven-vista-la-classe-taskdialog-et-l-erreur-unable-to-find-an-entry-point-named-taskdialogindirect-in-dll-comctl32-dll.aspx">[Seven / Vista] La classe TaskDialog et l’erreur “Unable to find an entry point named &#8216;TaskDialogIndirect&#8217; in DLL &#8216;comctl32.dll&#8217;”</a></p>
<p style="text-align:left;">Here is the translation in english :</p>
<ol>
<li>Open your project properties in the <em>Solution Explorer</em>,</li>
<li>On the Security tab, check <em>Enable ClickOnce Security Settings</em>,</li>
<li>Now you can see appearing the <em>app.manifest</em> file in the <em>Properties </em>folder of your solution, open it,</li>
<li>Beneath the <em>&lt;/trustInfo&gt;</em> tag, insert the following code :
<pre class="brush: csharp;">
  &lt;dependency&gt;
    &lt;dependentAssembly&gt;
      &lt;assemblyIdentity type=&quot;win32&quot; name=&quot;Microsoft.Windows.Common-Controls&quot; version=&quot;6.0.0.0&quot; processorArchitecture=&quot;*&quot; publicKeyToken=&quot;6595b64144ccf1df&quot; language=&quot;*&quot; /&gt;
    &lt;/dependentAssembly&gt;
  &lt;/dependency&gt;
</pre>
</li>
<li>If you try to build there&#8217;ll be an error, to fix it, uncheck the <em>Enable ClickOnce Security Settings</em>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://sharpmix.net/blog/2009/06/23/unable-to-find-an-entry-point-name-taskdialogindirect-in-dll-comctl32-dll/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Detect the type of your monitor</title>
		<link>http://sharpmix.net/blog/2009/06/12/detect-monitor-type-getmonitortechnologytype/</link>
		<comments>http://sharpmix.net/blog/2009/06/12/detect-monitor-type-getmonitortechnologytype/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 16:54:23 +0000</pubDate>
		<dc:creator>Abdallah Fdal</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Video games]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CRT]]></category>
		<category><![CDATA[DDC/CI]]></category>
		<category><![CDATA[detect monitor type]]></category>
		<category><![CDATA[EDID]]></category>
		<category><![CDATA[GetMonitorTechnologyType]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[MAME]]></category>
		<category><![CDATA[PowerStrip]]></category>
		<category><![CDATA[scanlines]]></category>
		<category><![CDATA[softMCCS]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[WinI2C/DDC]]></category>

		<guid isPermaLink="false">http://managedworld.wordpress.com/?p=38</guid>
		<description><![CDATA[UPDATE : Here is the monitor management application !
MonitorConfigurationAPI
Requirements : Vista and a display monitor with Vista drivers.
Usage : Click &#8216;Probe&#8217; button then wait a few seconds !
Issues

Color temperature doesn&#8217;t produce expected results
During detection, some monitors may change their settings

If you don&#8217;t have a Vista-specific driver, you shouldn&#8217;t install an old XP driver otherwise it [...]]]></description>
			<content:encoded><![CDATA[<h3>UPDATE : Here is the monitor management application !</h3>
<p><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/MonitorConfigurationAPI.zip">MonitorConfigurationAPI</a></p>
<p>Requirements : Vista and a display monitor with Vista drivers.</p>
<p>Usage : Click &#8216;Probe&#8217; button then wait a few seconds !</p>
<p>Issues</p>
<ul>
<li>Color temperature doesn&#8217;t produce expected results</li>
<li>During detection, some monitors may change their settings</li>
</ul>
<p><strong>If you don&#8217;t have a Vista-specific driver, you shouldn&#8217;t install an old XP driver otherwise it will break a couple of things on your system like monitor management for instance. You may think that you can roll-back to the previous driver, but it&#8217;ll be broken anyway ! I have seen some results with monitor that don&#8217;t have  Vista drivers with the <em>Generic PnP Monitor</em> that is installed by default, though.</strong></p>
<hr />For my <a href="http://en.wikipedia.org/wiki/MAME">MAME </a>GUI project,</p>
<p>I needed to detect what is the type of the monitor plugged onto the PC. This then, would allow me to provide custom <a href="http://en.wikipedia.org/wiki/Scanline">scanlines</a> PNGs, dependent of the technology used.</p>
<p style="text-align:center;">
<p style="text-align:center;"><a href="http://en.wikipedia.org/wiki/Cathode_ray_tube">CRT</a> ?</p>
<p style="text-align:center;"><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/crt.png"><img class="aligncenter size-full wp-image-39" title="CRT" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/crt.png" alt="CRT" width="320" height="239" /></a></p>
<p style="text-align:center;">or <a href="http://en.wikipedia.org/wiki/Lcd">LCD</a> ?</p>
<p style="text-align:center;"><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/lcd.png"><img class="aligncenter size-full wp-image-40" title="LCD" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/lcd.png" alt="LCD" width="320" height="239" /></a></p>
<p style="text-align:center;">
<p style="text-align:left;">
<p style="text-align:left;">Knowing that LCD does blurry stretching when not set at its native resolution, it is critical to know what display we are going to play on, in order to provide The (best possible) visual experience.</p>
<p>Proper arcade games emulation is somewhat sensitive to your display settings, hence, it&#8217;s always best to try provide nearest if not exact, display settings (resolution &amp; refresh rate).</p>
<p>This all came out when I decided to try MAME, seriously (this time) on my LCD screen.<br />
I got the following conclusion : it is possible to have a very good display experience even on LCDs, compared to using <a href="http://entechtaiwan.com/util/ps.shtm">PowerStrip</a> with my CRT.</p>
<p>While I have a great <a href="http://support.dell.com/support/edocs/monitors/p1130/en/g_ug/specs.htm">P1130</a> which is nothing more than a repainted <a href="http://www.erenumerique.fr/comparatif_de_8_ecrans_crt_21_et_22_pouces-art-156-2.html">G520</a> from Sony and is very good, if not one of the best CRTs to play your arcade games on, I like to play MAME quickly on my desktop PC (which in fact is a laptop) who is connected to the LCD screen. This is because since I got a new PC, the old Precision 360 workstation has been converted to a gaming-only PC. Too lazy to stand up and play just like in a real arcade game &#8230;</p>
<p>I thought : <em>&#8220;This should be simple to get, I only need to know what is the type of screen, nothing more. (So it&#8217;s gonna be easy, yeah ?)&#8221;</em></p>
<p>But life was different,</p>
<p>In fact this post is kind of, the tip of the iceberg I&#8217;ve been sitting on and didn&#8217;t even know there was an iceberg under my feets until recently &#8230; So I decided to write this post, because now I got it working and other people can benefit from it.</p>
<p>I knew that display monitors have a protocol so the PC can speak with them, <a href="http://en.wikipedia.org/wiki/Display_Data_Channel">DDC/CI</a>.</p>
<p>But here the problems comes,</p>
<ul>
<li>The protocol is using nothing more than <a href="http://en.wikipedia.org/wiki/I2c">I²C</a></li>
<li>This is something low-level, not addressable with C# directly</li>
</ul>
<p>And the list grows with time, why such simple request be so complicated to code ?</p>
<p>Now here are the possible solutions,</p>
<ul>
<li>Get <a href="http://en.wikipedia.org/wiki/EDID">EDID</a> string from Windows registry<br />
(Nice try but the string is in its raw form, decode it ? the specifications are not free &#8230;)</li>
<li>Use a software like <a href="http://www.entechtaiwan.com/lib/softmccs.shtm">softMCCS,</a> or better, an SDK like <a href="http://www.nicomsoft.com/wini2cddc/">WinI2C/DDC</a>,<br />
(Nice try again but these analysis softwares are stand-alone application, and while WinI2C is exactly what is needed, it&#8217;s pricey and not to consider because of the target project : Another <strong>free </strong>MAME GUI (already claiming it&#8217;s the best).</li>
</ul>
<p>While I&#8217;ve spent some time on WinI2C, the time-bombed samples always crashed for me, though the compiled demo ran &#8230; so I haven&#8217;t even been able to use it !</p>
<p>Now I don&#8217;t really need it because i have the same thing I coded myself but this wouldn&#8217;t happen without help right from Microsoft :-) considering you have Vista or better.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/ms775230(VS.85).aspx">Monitor Configuration</a><br />
<em><br />
You can use the monitor configuration functions to get information from a monitor and to change a monitor&#8217;s settings. You can use these functions to :</em></p>
<p><em>* Change a monitor&#8217;s geometry settings, such as the width and height of the display.<br />
* Change image settings, such as brightness and contrast.<br />
* Reset a monitor&#8217;s settings to their factory defaults.<br />
* Degauss the monitor.</em></p>
<p><em>Internally, the monitor configuration functions use the Display Data Channel Command Interface (DDC/CI) to send commands to the monitor.<br />
Now while this kicks ass, again, it&#8217;s for C++ &#8230;</em></p>
<p>Okay it does 99% of the job, all you have to do is call the functions you need, in fact it is even handier for my project as I am even able to change the colors of the monitor (if supported), great for monochrome emulation !</p>
<p>Now the only thing we need is a C# wrapper. (But some of it ran into trouble)</p>
<p>&#8230;</p>
<p>It got stuck when trying to get the physical monitors from the monitor, the pointer pointing to 0 was indeed correct (a pointer of pointer ?). While I hate pointers I find them working great when they are tamed.</p>
<p>But you still have to do a lot of things even with this API to get your Graal.</p>
<p><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/api.png"><img class="aligncenter size-full wp-image-41" title="Monitor Detect API" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/api.png" alt="Monitor Detect API" width="496" height="300" /></a></p>
<p>In the next part I will unveil a complete monitor configuration wrapper for C# :-)</p>
<p><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/cd.png"><img class="aligncenter size-full wp-image-42" title="Monitor Detect Class Diagram" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/cd.png" alt="Monitor Detect Class Diagram" width="650" height="505" /></a><br />
This is longer than expected as I decided to fully document it, and it&#8217;s tedious !<br />
(I am already considering another project that creates P/Invoke declarations fully documented from MSDN site but here comes dirty HTML and Regular Expressions &#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://sharpmix.net/blog/2009/06/12/detect-monitor-type-getmonitortechnologytype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Block system shutdown</title>
		<link>http://sharpmix.net/blog/2009/06/12/block-shutdown-in-vista-shutdownblockreasoncreate/</link>
		<comments>http://sharpmix.net/blog/2009/06/12/block-shutdown-in-vista-shutdownblockreasoncreate/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 13:32:45 +0000</pubDate>
		<dc:creator>Abdallah Fdal</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[shutdown]]></category>
		<category><![CDATA[ShutdownBlockReasonCreate]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Win32]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[XP]]></category>

		<guid isPermaLink="false">http://managedworld.wordpress.com/?p=8</guid>
		<description><![CDATA[UPDATE : Here is a sample code for Vista only.
ShutdownBlockReasonCreate
Running the program then initiating a shutdown will display the Windows feature.
As things seems to have changed a little in Windows 7, it doesn&#8217;t work with it. I will post an updated version of it, when the documentation is available.
Sometimes you need to handle a shutdown [...]]]></description>
			<content:encoded><![CDATA[<h3>UPDATE : Here is a sample code for Vista only.<a href="http://sharpmix.net/blog/wp-content/uploads/2009/09/ShutdownBlockReasonCreate.zip"></a></h3>
<h3><a href="http://sharpmix.net/blog/wp-content/uploads/2009/09/ShutdownBlockReasonCreate.zip">ShutdownBlockReasonCreate</a></h3>
<h3>Running the program then initiating a shutdown will display the Windows feature.</h3>
<h3>As things seems to have changed a little in Windows 7, it doesn&#8217;t work with it. I will post an updated version of it, when the documentation is available.</h3>
<p>Sometimes you need to handle a shutdown that has been accidentally initiated &#8230;</p>
<p>(Yes it can happen, at least for me).</p>
<p>For example in XP, when you have an application running and initiate a shutdown, a small window appears, saying that the application is not responding :</p>
<p><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/xpend4.png"><img class="aligncenter size-full wp-image-34" title="XP shutdown" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/xpend4.png" alt="XP shutdown" width="354" height="250" /></a></p>
<p>By simply pressing <em>Cancel </em>you were able to abort the shutdown process.</p>
<p>Now on Vista, <a href="http://msdn.microsoft.com/en-us/library/ms700677%28VS.85%29.aspx">things have a changed a little</a>, there is a new more user-friendly interface that appears when you try to shutdown while other applications are running :</p>
<p><a href="http://sharpmix.net/blog/wp-content/uploads/2009/06/ui1.jpg"><img class="aligncenter size-full wp-image-33" title="Vista's new shutdown UI" src="http://sharpmix.net/blog/wp-content/uploads/2009/06/ui1.jpg" alt="Vista's new shutdown UI" width="496" height="414" /></a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa376882%28VS.85%29.aspx">There&#8217;s an API</a> in Windows that you have to use, though.</p>
<p>In fact that API is more subtile than it looks, because of lack of examples and that you have to place these functions in a precise place in your code.</p>
<p><em>(Note that while the two provided links are unknown to each other, there are complementary informations on them !)</em></p>
<p><strong>You have to request that you need to block the shutdown process, probably because the application is doing whatever you think, is a critical operation.</strong></p>
<p>However, according to Microsoft, <span style="text-decoration: underline;">it is not recommended practice</span>.</p>
<p>Your application shall never block a shutdown process, especially if it&#8217;s a critical shutdown (one initiated by the user, from the shutdown button present on the Start menu).</p>
<p>A better practice, would be to save your application&#8217;s data and shut it down.</p>
<p>I needed this, so I started using the API but ran onto some issues &#8230;</p>
<p>Numerous examples on the web didn&#8217;t work for me, when not C++ at best I could see the new UI for 5 seconds only.</p>
<p>Now what I wanted is, just like in Outlook, when you shut down while it is running, the system waits for it to finish Send/Receive then it continues the shutdown process.</p>
<p>On the <a href="http://msdn.microsoft.com/en-us/library/ms700677%28VS.85%29.aspx">documentation</a> it seems that the content has not been verified, there are duplicate paragraphs and actually, we can make Vista wait more than 30 + 5 seconds (just as Outlook does or seems to), even in a critical shutdown !</p>
<p>There is also an obscure function, so obscure that Microsoft removed its documentation, <em>CancelShutdown</em>. It does what it says even under Vista and 7, it is able to (need to confirm that) cancel shutdown on these platforms.</p>
<p><span style="text-decoration: line-through;">We&#8217;ll look at all the coding needed for that, on part 2 &#8230;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://sharpmix.net/blog/2009/06/12/block-shutdown-in-vista-shutdownblockreasoncreate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
