<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx</link><description>It used to mean something on 16-bit Windows.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>The Old New Thing : How do I test that return value of ShellExecute against 32?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#1035972</link><pubDate>Wed, 08 Nov 2006 18:00:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1035972</guid><dc:creator>The Old New Thing : How do I test that return value of ShellExecute against 32?</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/oldnewthing/archive/2006/11/08/1035971.aspx"&gt;http://blogs.msdn.com/oldnewthing/archive/2006/11/08/1035971.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1035972" width="1" height="1"&gt;</description></item><item><title>DDE ..? How does it matter..?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#595185</link><pubDate>Thu, 11 May 2006 10:21:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:595185</guid><dc:creator>Pranav ... Blogging</dc:creator><description>When you are talking about office programs what happens when you open a new document seems to depend...&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=595185" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#592875</link><pubDate>Tue, 09 May 2006 03:58:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:592875</guid><dc:creator>Norman Diamond</dc:creator><description>&amp;gt; Cast it to int, cast it to INT_PTR, it won't&lt;br&gt;&amp;gt; make any difference.&lt;br&gt;&lt;br&gt;That is obvious only to someone who either knows or has reverse engineered the code. &amp;nbsp;MSDN isn't quite sure about that, your colleagues seem sure about the opposite, and even you didn't quite seem so sure a few replies back.&lt;br&gt;&lt;br&gt;&amp;gt; What error codes are born as long longs?&lt;br&gt;&lt;br&gt;I don't know, but the responses of both you (prior to this one) and your colleagues made it obvious that there are some.&lt;br&gt;&lt;br&gt;In a 64-bit program, HINSTANCE is 64 bits. &amp;nbsp;Now consider a case where ShellExecute has set that field to the value 2**33 + 1. &amp;nbsp;If the program casts this to type INT_PTR then the result of the cast will be greater than 32 and the program will think that it represents success. &amp;nbsp;If the program obeys MSDN and your colleagues, casts this to type int, and sees the result of 1, then the program will observe that it represents failure. &amp;nbsp;Since your company is so firm about the incorrecness of casting this to INT_PTR, it must be because some failure returns will be misinterpreted as successes unless they get cast down to int.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=592875" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#592140</link><pubDate>Mon, 08 May 2006 07:54:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:592140</guid><dc:creator>Raymond Chen - MSFT</dc:creator><description>Cast it to int, cast it to INT_PTR, it won't make any difference. (I'm not sure what you're referring to in that last sentence. What error codes are born as long longs?)&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=592140" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#592081</link><pubDate>Mon, 08 May 2006 04:43:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:592081</guid><dc:creator>Norman Diamond</dc:creator><description>&amp;gt; When I wrote, &amp;quot;You can check if it is greater&lt;br&gt;&amp;gt; than 32,&amp;quot; I mean &amp;quot;You can check if it is&lt;br&gt;&amp;gt; greater than 32 after casting it to an int&amp;quot;&lt;br&gt;&amp;gt; [...] Do I have to spell out very last&lt;br&gt;&amp;gt; excruciating detail?&lt;br&gt;&lt;br&gt;In this case there was a reason. &amp;nbsp;In the base note you also wrote this:&lt;br&gt;&lt;br&gt;&amp;gt; GWLP_HINSTANCE (or GWL_HINSTANCE if you're&lt;br&gt;&amp;gt; still living in the unenlightened non-64-bit-&lt;br&gt;&amp;gt; compatible world).&lt;br&gt;&lt;br&gt;As stated, I thought it might be appropriate to be 64-bit aware and cast the HINSTANCE to an INT_PTR instead of to an int. &amp;nbsp;Your employer said no, and here you agree with your colleague, but it's still not completely obvious. &amp;nbsp;It is good that MSDN is literally correct here. &amp;nbsp;In fact if MSDN were literally correct in enough other places then I wouldn't have wondered whether to doubt this one. &amp;nbsp;But your base note didn't say int, and any 64-bit-aware person who reads your base note might not be aware that they should only test the low-order 32 bits.&lt;br&gt;&lt;br&gt;Saturday, May 06, 2006 6:45 AM by KJK::Hyperion&lt;br&gt;&amp;gt; Rigorousness OK, but it doesn't take a lot of&lt;br&gt;&amp;gt; psychic skills to understand what goes on&lt;br&gt;&amp;gt; behind the curtain. The return value is&lt;br&gt;&amp;gt; obviously born as a positive int and casted&lt;br&gt;&amp;gt; into an HINSTANCE with IntToPtr().&lt;br&gt;&lt;br&gt;Um, since the HINSTANCE used to be an address sometimes, it's not obvious to me that it's always born as an int. &amp;nbsp;I only would have guessed that error returns were born as ints ... sometimes. &amp;nbsp;Considering that 64-bit-aware programs must cast it down to 32 bits, obviously even some error returns are born as long longs but have the error value shown in the low-order 32 bits.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=592081" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#591818</link><pubDate>Sun, 07 May 2006 12:18:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:591818</guid><dc:creator>Steven Edwards</dc:creator><description>To go even more off topic.&lt;br&gt;&lt;br&gt;bviksoe: Some programs that try to be compatible on the oldest Windows version possible such as Win9x still use DDE. I tracked down a bug in firefox recently that was causing a hang during DDE communication.&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=591818" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#591645</link><pubDate>Sat, 06 May 2006 23:23:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:591645</guid><dc:creator>bviksoe</dc:creator><description>Oh no, you said: DDE. &lt;br&gt;And here I thought you weren't allowed to swear or use obscene words on this blog! Well, good thing the topic was filed under Historic. So many bad memories... &lt;br&gt;&lt;br&gt;Could it be that Windows Explorer is the only application on the face of this earth to use this technology still?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=591645" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#591532</link><pubDate>Sat, 06 May 2006 18:52:18 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:591532</guid><dc:creator>Raymond Chen - MSFT</dc:creator><description>It's okay to cast to an int because, as both the linked article and the documentation for ShellExecute note, the error code is an integer, cast to HINSTANCE for compatibility. The return value will never be 2**33+1 since that doesn't fit in an int.&lt;br&gt;&lt;br&gt;When I wrote, &amp;quot;You can check if it is greater than 32,&amp;quot; I mean &amp;quot;You can check if it is greater than 32 after casting it to an int&amp;quot; - but I assumed that was obvious since I'm assuming people reading the entry are already familiar with ShellExecute. Do I have to spell out very last excruciating detail? Do you spell out every last excruciating detail when you talk with your friends?&lt;br&gt;&lt;br&gt;&amp;quot;When you get to the gas station, turn left.&amp;quot;&lt;br&gt;&lt;br&gt;&amp;quot;Even if the traffic light is red?&amp;quot;&lt;br&gt;&lt;br&gt;&amp;quot;Sigh. Turn left *when safe and legal*.&amp;quot;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=591532" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#591426</link><pubDate>Sat, 06 May 2006 13:45:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:591426</guid><dc:creator>KJK::Hyperion</dc:creator><description>and, Norman, the result cannot &amp;quot;happen&amp;quot; to be larger than that. Rigorousness OK, but it doesn't take a lot of psychic skills to understand what goes on behind the curtain. The return value is obviously born as a positive int and casted into an HINSTANCE with IntToPtr(). And int is always 32 bit, even on Win64, so there's no kind of trickery that could make it overflow&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=591426" width="1" height="1"&gt;</description></item><item><title>re: What can I do with the HINSTANCE returned by the ShellExecute function?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2006/05/05/590749.aspx#591425</link><pubDate>Sat, 06 May 2006 13:40:16 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:591425</guid><dc:creator>KJK::Hyperion</dc:creator><description>Norman: just ditch ShellExecute and use ShellExecuteEx, then. Has nicer error handling and generally nicer everything. As for INT_PTR, I'll just say beware, beware sign extension&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=591425" width="1" height="1"&gt;</description></item></channel></rss>