<?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>Fooling Around &#187; microsoft</title>
	<atom:link href="http://alax.info/blog/tag/microsoft/feed" rel="self" type="application/rss+xml" />
	<link>http://alax.info/blog</link>
	<description>// Software Production Line</description>
	<lastBuildDate>Fri, 03 Feb 2012 22:49:15 +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>Microsoft DTV-DVD Video Decoder at High Resolutions</title>
		<link>http://alax.info/blog/1283</link>
		<comments>http://alax.info/blog/1283#comments</comments>
		<pubDate>Wed, 21 Sep 2011 20:51:23 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[H.264]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1283</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate. The component responsible for video decoding is Microsoft DTV-DVD Video &#8230;<p class="read-more"><a href="http://alax.info/blog/1283">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1283" title="Microsoft DTV-DVD Video Decoder at High Resolutions"></a><p>It is really great news that Windows 7 offers quite some goodies for MPEG-4 support right out of the box, but some things appear to be made not so accurate.</p>
<p>The component responsible for video decoding is <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd390679%28v=vs.85%29.aspx">Microsoft DTV-DVD Video Decoder</a> (also known as Microsoft MPEG-2 Video Decoder), available with DirectShow interface. It offers video decoding capabilities for video resolutions up to 1920&#215;1088 (Full HD), including DXVA version 2 mode. The decoder is a &#8220;preferred decoder&#8221; and is given a first chance to be taken when it comes for <a href="http://msdn.microsoft.com/en-us/library/dd390342%28v=VS.85%29.aspx">Intelligent Connect</a> to render a video stream.</p>
<p>Technology went ahead though, stepped behind 1920&#215;1088 in particular. Microsoft DTV-DVD Video Decoder DirectShow filter still remains the first take in H.264 video decoding, and what however is taking place &#8211; the decoder accepts the format (media type) which is clearly cannot decode, neither according to specification, nor in real life. As soon as pin connection succeeds, DirectShow is not trying to look for another decoder, which can truly decode the feed. Result: failure to decode video.</p>
<p><img class="alignnone size-full wp-image-1284" title="Incorrect Media Type on Microsoft DTV-DVD Decoder Output" src="http://alax.info/blog/wp-content/uploads/2011/09/Image001.png" alt="" width="1034" height="624" /></p>
<p>The problem takes place in a quite surprising way. Given 5 megapixel video (2560&#215;1592, H.264, Baseline profile, from <a href="http://en.wikipedia.org/wiki/RTSP">RTSP</a>-enabled IP camera), the decoder advertises 720&#215;480 NV12 output media type. While consuming input data, the decoder outputs nothing and keeps video window black.</p>
<p>It does not issue any filter graph events, no. The filter is persistent and works hard in assumption that a new piece of knowledge will come from Mars and provide new capabilities to start decoding video, or filter&#8217;s input will give up and provide a new <a href="http://en.wikipedia.org/wiki/Network_Abstraction_Layer#Parameter_Sets">SPS</a> to lower resolution down to something less complex.</p>
<p>Well then, so is this advanced technology yet to be discovered by science? It appears that no. CoreAVC Video Decoder, applied to the same H.264 video decodes it well and nice:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/09/Image002.png"><img class="alignnone size-large wp-image-1287" title="CoreAVC H.264 Video Decoder with 5 MP Video from StarDot SDH500BN IP Camera" src="http://alax.info/blog/wp-content/uploads/2011/09/Image002-505x600.png" alt="" width="505" height="600" /></a></p>
<p><span style="text-decoration: underline;">Update 2011-09-26</span>: According to Microsoft classification, this is <a href="http://connect.microsoft.com/VisualStudio/feedback/details/689926/dtv-dvd-video-decoder-directshow-filter-negotiates-decoding-at-high-resolutions-but-fails-to-actually-decode">a bug on a released product</a>. That is, if anyone is experiencing severe issues as a result of this behavior, one might need to contact Microsoft Support directly in search of a solution.</p>
<p>Actually, as resolutions over Full HD (1920&#215;1080) are not so much common at the moment, the issue side effects are not yet likely. Still moving on with time, I think the issues are likely to come up, without being severe though.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1283/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A tricky EVR bug was caught up: input pin may falsely report disconnected state</title>
		<link>http://alax.info/blog/1262</link>
		<comments>http://alax.info/blog/1262#comments</comments>
		<pubDate>Tue, 26 Jul 2011 17:13:38 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Video]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[evr]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[Source]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1262</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1262" title="A tricky EVR bug was caught up: input pin may falsely report disconnected state"></a>Crime An application which builds a DirectShow graph unexpectedly started failing with VFW_E_NOT_CONNECTED (0&#215;80040209) error code. Scene The problem takes place during DirectShow graph building, yet in stopped state. Specific call which appeared to be giving out the error in &#8230;<p class="read-more"><a href="http://alax.info/blog/1262">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1262" title="A tricky EVR bug was caught up: input pin may falsely report disconnected state"></a><h4>Crime</h4>
<p>An application which builds a DirectShow graph unexpectedly started failing with VFW_E_NOT_CONNECTED (0&#215;80040209) error code.</p>
<h4>Scene</h4>
<p>The problem takes place during DirectShow graph building, yet in stopped state. Specific call which appeared to be giving out the error in first place appears to be EVR input pin&#8217;s <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin">IPin::ConnectionMediaType</a>, and the problem is also specific to <a href="http://msdn.microsoft.com/en-us/library/ms694916%28VS.85%29.aspx">Enhanced video Renderer</a> (Windows 7, but not necessarily only this version).</p>
<h4>Investigation</h4>
<p>The problem does not appear to be persistent. On the contrary, it is taking place for just a few milliseconds after pin connection. After the problem is gone, it does not seem to ever come up again unless the filter graph is built again from the beginning.</p>
<p>EVR pin connection is always reporting success, so the following error code stating <a href="http://msdn.microsoft.com/en-us/library/ms919477.aspx">VFW_E_NOT_CONNECTED</a> &#8220;The operation cannot be performed because the pins are not connected.&#8221; goes against documented behavior, and is thus a bug.</p>
<p>Depending on time between pin connection and media type polling, the call can reach EVR:</p>
<ul>
<li>before it starts showing the problem &#8211; stage A</li>
<li>at the time the call fails &#8211; stage B</li>
<li>after the failure time interval, when the call is successful from then on &#8211; stage C</li>
</ul>
<p>Thus, the problem is limited to specific use cases:</p>
<ul>
<li>the application should care about media type on EVR input</li>
<li>unexpected failure takes place when the call reaches in stage B</li>
<li>also found: the clipping window for the EVR has to belong to a non-primary monitor</li>
</ul>
<p>If an application keep polling for media type in a loop, the result may be about the following:</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #603000;">UINT</span> nStageA <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nStageB <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #808030;">,</span> nStageC <span style="color: #808030;">=</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #696969;">// [...]</span>
<span style="color: #800000; font-weight: bold;">for</span><span style="color: #808030;">(</span><span style="color: #800080;">;</span> <span style="color: #800080;">;</span> <span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    AM_MEDIA_TYPE MediaType<span style="color: #800080;">;</span>
    <span style="color: #400000;">ZeroMemory</span><span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>MediaType<span style="color: #808030;">,</span> <span style="color: #800000; font-weight: bold;">sizeof</span> MediaType<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">const</span> HRESULT nConnectionMediaTypeResult <span style="color: #808030;">=</span> pInputPin<span style="color: #808030;">-</span><span style="color: #808030;">&gt;</span>ConnectionMediaType<span style="color: #808030;">(</span><span style="color: #808030;">&amp;</span>MediaType<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>nConnectionMediaTypeResult<span style="color: #808030;">)</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>nStageB<span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            nStageC<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
            <span style="color: #800000; font-weight: bold;">break</span><span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span> <span style="color: #800000; font-weight: bold;">else</span>
            nStageA<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span> <span style="color: #800000; font-weight: bold;">else</span>
    <span style="color: #800080;">{</span>
        ATLASSERT<span style="color: #808030;">(</span>nConnectionMediaTypeResult <span style="color: #808030;">=</span><span style="color: #808030;">=</span> VFW_E_NOT_CONNECTED<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        nStageB<span style="color: #808030;">+</span><span style="color: #808030;">+</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoTaskMemFree<span style="color: #808030;">(</span>MediaType<span style="color: #808030;">.</span>pbFormat<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>
<span style="color: #696969;">// [...]</span>
<span style="color: #603000;">CString</span> sMessage<span style="color: #800080;">;</span>
sMessage<span style="color: #808030;">.</span>Format<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Bingo!</span><span style="color: #0f69ff;">\r</span><span style="color: #0f69ff;">\n</span><span style="color: #0f69ff;">\r</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nStageA </span><span style="color: #0f69ff;">%d</span><span style="color: #0000e6;">, nStageB </span><span style="color: #0f69ff;">%d</span><span style="color: #0000e6;"> - 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0000e6;">, nStageC </span><span style="color: #0f69ff;">%d</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nStageA<span style="color: #808030;">,</span> nStageB<span style="color: #808030;">,</span> nResult<span style="color: #808030;">,</span> nStageC<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
AtlMessageBox<span style="color: #808030;">(</span>m_hWnd<span style="color: #808030;">,</span> <span style="color: #808030;">(</span><span style="color: #603000;">LPCTSTR</span><span style="color: #808030;">)</span> sMessage<span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Result</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> MB_ICONERROR<span style="color: #808030;">)</span><span style="color: #800080;">;</span></pre>
<p><img class="alignnone size-full wp-image-1263" title="EVR Input Pin IPin::ConnectedMediaType Stages" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0034.png" alt="" width="384" height="184" /></p>
<h5>Workaround</h5>
<p>An obvious straightforward workaround is to follow EVR connection with a wait for Stage B to pass, or timeout &#8211; whichever takes place first.</p>
<p>Also, <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin">vote for the bug on Microsoft Connect</a>.</p>
<h5>More Details</h5>
<p>Video renderer filter are notorious for re-agreeing media type and being fretful as for memory allocators and media types (for a good reason though!). So it makes sense to suggest that the problem takes place when the filter is doing something related, such as it starts background activity immediately after connection in order to discover upstream peer capabilities.</p>
<p>In order to possibly get details on this, it is possible to raise an exception as soon as Stage B is detected and take a look at thread states using a debugger. Indeed, on of the background threads is engaged in EVR reconnection activity:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/07/Image0023.png"><img class="alignnone size-large wp-image-1264" title="EVR Background Thread State" src="http://alax.info/blog/wp-content/uploads/2011/07/Image0023-800x429.png" alt="" width="620" height="332" /></a></p>
<p>Yes it does the reconnection, but nevertheless it is expected to do the things undercover and transparently, it still allows a failure on the outer API.</p>
<pre>Â Â Â   evr.dll!GetSourceRectFromMediaType() + 0x37 bytesÂ Â Â Â 
 Â Â Â Â evr.dll!CEVRInputPin::CheckMediaType() + 0x81 bytesÂ Â Â Â 
 Â Â Â Â evr.dll!CBasePin::ReceiveConnection() + 0x61 bytesÂ Â Â Â 
 Â Â Â Â evr.dll!CEVRInputPin::ReceiveConnection() + 0x1fc2d bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CBasePin::AttemptConnection() - 0x21 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CBasePin::TryMediaTypes() + 0x60 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CBasePin::AgreeMediaType() + 0x54 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CBasePin::Connect() + 0x46 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFilterGraph::ConnectDirectInternal() + 0x83 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFilterGraph::ConnectRecursively() + 0x2c bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFilterGraph::ConnectInternal() + 0xde bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFilterGraph::Connect() + 0x17 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFGControl::WorkerDisplayChanged() + 0xf1 bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!CFGControl::CGraphWindow::OnReceiveMessage() + 0x2e2a bytesÂ Â Â Â 
&gt;Â Â Â Â quartz.dll!WndProc() + 0x3e bytesÂ Â Â Â 
 Â Â Â Â user32.dll!_InternalCallWinProc@20() + 0x23 bytesÂ Â Â Â 
 Â Â Â Â user32.dll!_UserCallWinProcCheckWow@32() + 0xb7 bytesÂ Â Â Â 
 Â Â Â Â user32.dll!_DispatchMessageWorker@8() + 0xed bytesÂ Â Â Â 
 Â Â Â Â user32.dll!_DispatchMessageW@4() + 0xf bytesÂ Â Â Â 
 Â Â Â Â quartz.dll!ObjectThread() + 0x65 bytes</pre>
<p>A test Visual C++ .NET 2010 application <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/EvrInputPinConnectionBug">is available from SVN</a>. The code requires a media file, and refers to <em>352&#215;288 I420.avi</em>, which is included into ZIP file attached to <a href="http://connect.microsoft.com/VisualStudio/feedback/details/680766/enhanced-video-renderer-is-incorrectly-reporting-vfw-e-not-connected-0x80040209-for-a-connected-pin#details">MS Connect Feedback</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1262/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>If your application is looking for network adapters, it may be blind to see</title>
		<link>http://alax.info/blog/1195</link>
		<comments>http://alax.info/blog/1195#comments</comments>
		<pubDate>Thu, 28 Apr 2011 17:17:41 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Source]]></category>
		<category><![CDATA[adapter]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1195</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1195" title="If your application is looking for network adapters, it may be blind to see"></a>A really long and annoying troubleshooting of a problem finally ended with a bug found in GetAdaptersInfo/GetAdaptersAddresses API. It may unexpectedly fail under the following conditions: 32-bit application 64-bit operating system or /3GB feature enabled on 32-bit operating system hosting &#8230;<p class="read-more"><a href="http://alax.info/blog/1195">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1195" title="If your application is looking for network adapters, it may be blind to see"></a><p>A really long and annoying troubleshooting of a problem finally ended with a bug found in <a href="http://msdn.microsoft.com/en-us/library/aa365917%28VS.85%29.aspx">GetAdaptersInfo</a>/<a href="http://msdn.microsoft.com/en-us/library/aa365915%28VS.85%29.aspx">GetAdaptersAddresses</a> API.</p>
<p>It may unexpectedly fail under the following conditions:</p>
<ul>
<li>32-bit application</li>
<li>64-bit operating system or /3GB feature enabled on 32-bit operating system</li>
<li>hosting process is linked with /LARGEADDRESSAWARE flag or has otherwise set it in binary header</li>
<li>over 2GB of RAM (in terms of Private Bytes/Virtual Size performance counters) consumed by the hosting process</li>
</ul>
<p>The application might unexpectedly start getting ERROR_NO_DATA (232) or ERROR_NOACCESS (998) error codes instead of list of adapters. Supposedly, the responsible Microsoft component iplhlpapi.dll or one of the underlying components/APIs are incompatible with such environments (such as for example, treating 32-bit pointer with the most significant bit set as invalid or compares such pointers as signed values).</p>
<p><img class="alignnone size-full wp-image-1196" title="GetAdaptersInfo Failure" src="http://alax.info/blog/wp-content/uploads/2011/04/Image0011.png" alt="" width="301" height="214" /></p>
<p>A test Visual C++ .NET 2010 application <a href="http://trac2.assembla.com/roatl-utilities/browser/trunk/GetAdaptersAddressesTest">is  available from SVN</a>. More bug details on <a href="http://connect.microsoft.com/VisualStudio/feedback/details/665383/getadaptersaddresses-api-incorrectly-returns-no-adapters-for-a-process-with-high-memory-consumption">Microsoft Connect</a>.</p>
<p>NOTE 1: You need to run &#8220;GetAdaptersAddressesTest /regserver&#8221; once to register the app before running it for the test.</p>
<p>NOTE 2: The problem does not seem to take place with 32-bit operating systems with /3GB tuning enabled.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1195/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build Incrementer Add-In for Visual Studio: Latest Visual Studio Versions</title>
		<link>http://alax.info/blog/1170</link>
		<comments>http://alax.info/blog/1170#comments</comments>
		<pubDate>Sat, 05 Mar 2011 13:08:38 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Utilities]]></category>
		<category><![CDATA[add-in]]></category>
		<category><![CDATA[ATL]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[increment]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[utility]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1170</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1170" title="Build Incrementer Add-In for Visual Studio: Latest Visual Studio Versions"></a>If you share concept (as I do) that every build should have a unique file version stamp in it, for a simple purpose â€“ at least â€“ to distinguish between different version of the same binary, then a helpful tool &#8230;<p class="read-more"><a href="http://alax.info/blog/1170">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1170" title="Build Incrementer Add-In for Visual Studio: Latest Visual Studio Versions"></a><p>If you share concept (as I do) that every build should have a unique file version stamp in it, for a simple purpose â€“ at least â€“ to distinguish between different version of the same binary, then a helpful tool of automatic incrementing fourth number in FILEVERSION&#8217;s file version is something you cannot live without. After going through several fixes and updates, it is finally here available for download.</p>
<p>The last issue was in particular that projects that are in solution&#8217;s folder are not found by the add-in with <a href="http://www.microsoft.com/visualstudio/en-us/">Visual Studio</a> 2008. Why? <a href="http://msdn.microsoft.com/en-us/library/aa301986.aspx">OnBuildProjConfigBegin</a> event provides you with a unique project name string in Project argument, but it appears that it is only good enough as a quick lookup argument with Visual Studio 2010.</p>
<pre style="color: #000000; background: #ffffff;"><span style="color: #696969;">// EnvDTE::_dispBuildEvents</span>
    STDMETHOD<span style="color: #808030;">(</span>OnBuildBegin<span style="color: #808030;">)</span><span style="color: #808030;">(</span>_EnvDTE_vsBuildScope Scope<span style="color: #808030;">,</span> _EnvDTE_vsBuildAction Action<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    STDMETHOD<span style="color: #808030;">(</span>OnBuildDone<span style="color: #808030;">)</span><span style="color: #808030;">(</span>_EnvDTE_vsBuildScope Scope<span style="color: #808030;">,</span> _EnvDTE_vsBuildAction Action<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    STDMETHOD<span style="color: #808030;">(</span>OnBuildProjConfigBegin<span style="color: #808030;">)</span><span style="color: #808030;">(</span>BSTR <strong><span style="text-decoration: underline;">Project</span></strong><span style="color: #808030;">,</span> BSTR ProjectConfig<span style="color: #808030;">,</span> BSTR Platform<span style="color: #808030;">,</span> BSTR SolutionConfig<span style="color: #808030;">)</span> <span style="color: #800000; font-weight: bold;">throw</span><span style="color: #808030;">(</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        _Z4<span style="color: #808030;">(</span>atlTraceCOM<span style="color: #808030;">,</span> <span style="color: #008c00;">4</span><span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Project </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">, ProjectConfig </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">, Platform </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">, SolutionConfig </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>Project<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>ProjectConfig<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>Platform<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>SolutionConfig<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _ATLTRY
        <span style="color: #800080;">{</span>
            <span style="color: #696969;">// NOTE: const CString&amp; cast forces compiler to process statement as variable definition rather than function forward declaration</span>
            CProjectConfiguration ProjectConfiguration<span style="color: #808030;">(</span><span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">const</span> <span style="color: #603000;">CString</span><span style="color: #808030;">&amp;</span><span style="color: #808030;">)</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>Project<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>ProjectConfig<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>Platform<span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>SolutionConfig<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            CRoCriticalSectionLock DataLock<span style="color: #808030;">(</span>m_DataCriticalSection<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #696969;">// NOTE: Check the project on the first run only (to skip multiple increments in batch build mode)</span>
            <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span><span style="color: #808030;">!</span>Project <span style="color: #808030;">|</span><span style="color: #808030;">|</span> m_VersionMap<span style="color: #808030;">.</span>Lookup<span style="color: #808030;">(</span>ProjectConfiguration<span style="color: #808030;">)</span><span style="color: #808030;">)</span>
                <span style="color: #800000; font-weight: bold;">return</span> S_FALSE<span style="color: #800080;">;</span>
            _Z3<span style="color: #808030;">(</span>atlTraceGeneral<span style="color: #808030;">,</span> <span style="color: #008c00;">3</span><span style="color: #808030;">,</span> _T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">Checking project </span><span style="color: #0f69ff;">\"</span><span style="color: #0f69ff;">%s</span><span style="color: #0f69ff;">\"</span><span style="color: #0000e6;">...</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> <span style="color: #603000;">CString</span><span style="color: #808030;">(</span>Project<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #696969;">// Checking the project is of C++ kind</span>
            CComPtr<span style="color: #800080;">&lt;</span>EnvDTE<span style="color: #800080;">::</span>Project<span style="color: #800080;">&gt;</span> pProject <span style="color: #808030;">=</span> GetProject<span style="color: #808030;">(</span>CComVariant<span style="color: #808030;">(</span><strong><span style="text-decoration: underline;">Project</span></strong><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            _A<span style="color: #808030;">(</span>pProject<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #808030;">.</span><span style="color: #808030;">.</span><span style="color: #808030;">.</span></pre>
<p>When the project is in a folder, <a href="http://msdn.microsoft.com/en-us/library/aa301425.aspx">Projects::Item</a> can just fail if you are looking up for the element interface. In which case, you have to walk the collection taking into account <a href="http://msdn.microsoft.com/en-us/library/aa301157.aspx">SubProjects</a> and additionally look there yourself. Visual Studio 2010 is one step smarter and gives the thing to you right from the start.</p>
<p>Eventually, the add-in is here. It&#8217;s job is to go to .RC file and increment file version each time you build the binary. It reports the action into build output window:</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2011/03/Image001.png"><img class="size-large wp-image-1172 alignnone" title="Build Incrementer Report in Visual Studio Build Output" src="http://alax.info/blog/wp-content/uploads/2011/03/Image001-800x213.png" alt="" width="640" height="170" /></a></p>
<p>To install the add-in:</p>
<ul>
<li>download and register (regsvr32, administrator) the <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/VisualStudioBuildIncrementerAddIn/_Bin/Release/VisualStudioBuildIncrementerAddIn.dll?format=raw">VisualStudioBuildIncrementerAddIn.dll</a></li>
<li>apply one or more Visual Studio integration registry files:
<ul>
<li><a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/VisualStudioBuildIncrementerAddIn/Visual Studio 2008 Registration.reg?format=raw">Visual Studio 2008 Registration.reg</a></li>
<li><a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/VisualStudioBuildIncrementerAddIn/Visual Studio 2010 Registration.reg?format=raw">Visual Studio 2010 Registration.reg</a></li>
</ul>
</li>
</ul>
<p>Or, alternatively, use installation file <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/VisualStudioBuildIncrementerAddIn/_Bin/Release/VisualStudioBuildIncrementerAddInSetup.msi?format=raw">VisualStudioBuildIncrementerAddInSetup.msi (version 1.0.4, 379K)</a> to have it done for you in a user-friendly way. Partial <a href="http://www.assembla.com/code/roatl-utilities/subversion/nodes/trunk/VisualStudioBuildIncrementerAddIn">source code</a>, a Visual Studio 2010 projectis also there in repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1170/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ATL ActiveX control hosting memory leak, _freea assertion failure and more</title>
		<link>http://alax.info/blog/1166</link>
		<comments>http://alax.info/blog/1166#comments</comments>
		<pubDate>Fri, 04 Mar 2011 20:13:28 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[ATL]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[microsoft]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1166</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1166" title="ATL ActiveX control hosting memory leak, _freea assertion failure and more"></a>If you were adding and removing ActiveX controls programmatically with ATL, you might have noticed a nasty memory leak after final release of the control. Control added, removed and a leaky block is left om heap. Tracking simple memory leaks &#8230;<p class="read-more"><a href="http://alax.info/blog/1166">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1166" title="ATL ActiveX control hosting memory leak, _freea assertion failure and more"></a><p>If you were adding and removing ActiveX controls programmatically with ATL, you might have noticed a nasty memory leak after final release of the control. Control added, removed and a leaky block is left om heap.</p>
<p>Tracking simple memory leaks is not a rocket science with Microsoft C++ runtime, by adding _CRTDBG_MAP_ALLOC define, as described in <a href="http://msdn.microsoft.com/en-us/library/e5ewb1h3.aspx">Memory Leak Detection Enabling on MSDN</a>:</p>
<pre><span style="color: blue;">#if</span> defined(_DEBUG)
<span style="color: blue;">#define</span> _CRTDBG_MAP_ALLOC
#<span style="color: blue;">include</span> &lt;stdlib.h&gt;
#<span style="color: blue;">include</span> &lt;crtdbg.h&gt;
<span style="color: blue;">#endif</span> <span style="color: green;">// defined(_DEBUG)</span></pre>
<p>Having that done, the problem was isolated to an extra instance of CAxHostWindow, which was excessively instantiated and never freed. Luckily, having this done you already have sufficient amount of keywords on hands to locate relevant articles on Microsoft knowledge base:</p>
<ul>
<li><a href="http://support.microsoft.com/KB/229904">PRB: CAxWindow Members Can Cause a Memory Leak</a></li>
<li><a href="How to add ActiveX controls to an ATL composite control programmatically in Visual C++">How to add ActiveX controls to an ATL composite control programmatically in Visual C++</a></li>
</ul>
<p>Basically, what is taking place is the behavior by design. That is, AtlAxCreateControlEx API is leaky by design, one gotta just be aware.</p>
<pre>CComPtr&lt;IUnknown&gt; pContainerUnkonwn, pControlUnknown;
<span style="color: blue;">static</span> LPCTSTR g_pszControlClass = _T(<span style="color: maroon;">"{8856F961-340A-11D0-A96B-00C04FD705A2}"</span>);
<span style="color: green;">// NOTE: This results in two instances of CAxWindowHost being created, one of which appears to be leaked (see below), </span>
<span style="color: green;">//       see http://support.microsoft.com/kb/218442</span>
<span style="color: green;">// </span>
<span style="color: green;">// Detected memory leaks!</span>
<span style="color: green;">// Dumping objects -&gt;</span>
<span style="color: green;">// {81} normal block at 0x00128928, 244 bytes long.</span>
<span style="color: green;">// Data: &lt;x .       .     &gt; 78 09 2E 01 01 00 00 00 0C 10 2E 01 00 00 00 00 </span>
<span style="color: green;">// Object dump complete.</span>
ATLENSURE_SUCCEEDED(AtlAxCreateControlEx(CT2COLE(g_pszControlClass), m_hWnd, <span style="color: blue;">NULL</span>, &amp;pContainerUnkonwn, &amp;pControlUnknown));</pre>
<p><span id="more-1166"></span>A workaround here is suggested by Q218442 and is a replacement of AtlAx* API call with a CAxWindow class:</p>
<pre>CComPtr&lt;IUnknown&gt; pContainerUnkonwn, pControlUnknown;
<span style="color: blue;">static</span> LPCTSTR g_pszControlClass = _T(<span style="color: maroon;">"{8856F961-340A-11D0-A96B-00C04FD705A2}"</span>);
CAxWindow AxWindow;
AxWindow.Attach(m_hWnd);
ATLENSURE_SUCCEEDED(AxWindow.CreateControlEx(CT2COLE(g_pszControlClass), <span style="color: blue;">NULL</span>, &amp;pContainerUnkonwn, &amp;pControlUnknown));</pre>
<p>The happiness of leak resolution here might be somewhat diluted by a weird assertion failure coming out from the deepness of ATL. The problem comes from ~CAutoStackPtr destructor (undocumented) trying to <a href="http://msdn.microsoft.com/en-us/library/k8984a8h.aspx">_freea</a> a memory block allocated by caller&#8217;s <a href="http://msdn.microsoft.com/en-us/library/5471dc8s.aspx">_malloca</a>. While caller&#8217;s _malloca is converted to plain heap allocation (_malloc_dbg) for debugging purposes, _freea is still looking for security cookie which never existed. Hence, assertion failure:</p>
<pre>_ASSERTE((<span style="color: maroon;">"Corrupted pointer passed to _freea"</span>, <span style="color: maroon;">0</span>));</pre>
<p>Unfortunately, it appears that _CRTDBG_MAP_ALLOC macro is not compatible with _malloca/_freea, the problem exists in versions of Visual C++ 2008 (at least) through 2010 SP1.</p>
<p>Vote for the problem on MS Connect: <a href="https://connect.microsoft.com/VisualStudio/feedback/details/649364/malloca-freea-mismatch-with-malloc-debug-builds-crtdbg-map-alloc">_malloca/_freea mismatch with malloc debug builds (_CRTDBG_MAP_ALLOC)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1166/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)</title>
		<link>http://alax.info/blog/1086</link>
		<comments>http://alax.info/blog/1086#comments</comments>
		<pubDate>Fri, 30 Oct 2009 08:56:38 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[ole]]></category>
		<category><![CDATA[oledb]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[win7]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=1086</guid>
		<description><![CDATA[<a href="http://alax.info/blog/1086" title="Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)"></a>It was a sort of ridiculous problem: an attempt to instantiate a Microsoft.Jet.OLEDB.4.0 object failed with error. Still some applications are still running without problems connecting to Jet databases, how comes? There has been a number of posts on Internet, &#8230;<p class="read-more"><a href="http://alax.info/blog/1086">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/1086" title="Microsoft.Jet.OLEDB.4.0 ProgID is not available (Windows 7 but probably not only)"></a><p>It was a sort of ridiculous problem: an attempt to instantiate a Microsoft.Jet.OLEDB.4.0 object failed with error. Still some applications are still running without problems connecting to Jet databases, how comes?</p>
<p>There has been <a href="http://www.google.com/search?q=Microsoft.Jet.OLEDB.4.0">a number of posts on Internet</a>, but none of the top ones appeared to be relevant.</p>
<p>The problem is reproduced extremely simple:</p>
<pre style="background: #ffffff none repeat scroll 0% 0%; color: #000000; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous;"><span style="color: #800000; font-weight: bold;">int</span> _tmain<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">int</span> argc<span style="color: #808030;">,</span> _TCHAR<span style="color: #808030;">*</span> argv<span style="color: #808030;">[</span><span style="color: #808030;">]</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>CoInitialize<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">{</span>
        <span style="color: #696969;">//CoLoadLibrary(L"C:\\Program Files (x86)\\Common Files\\System\\Ole DB\\oledb32.dll", TRUE);</span>
        CComPtr<span style="color: #800080;">&lt;</span>IDBInitialize<span style="color: #800080;">&gt;</span> pDbInitialize<span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">const</span> HRESULT nResult <span style="color: #808030;">=</span> pDbInitialize<span style="color: #808030;">.</span>CoCreateInstance<span style="color: #808030;">(</span><span style="color: #800000;">L"</span><span style="color: #0000e6;">Microsoft.Jet.OLEDB.4.0</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> <span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> CLSCTX_INPROC_SERVER<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _tprintf<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nResult 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nResult<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoUninitialize<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #800080;">}</span></pre>
<p>Oops, the code gives error REGDB_E_CLASSNOTREG 0&#215;80040154 &#8220;Class not registered&#8221;. It looked like system was unable to locate one of the internally used DLLs &#8211; oledb32.dll, and if we help by uncommenting the line commented in the code snippet above, the error changes to ERROR_MOD_NOT_FOUND 0x8007007e &#8220;The specified module could not be found&#8221;.</p>
<p>The problem appears to be that one of the system components, which is involved, &#8220;Microsoft OLE DB Data Conversion Library&#8221; is registered with the system using a <a href="http://msdn.microsoft.com/en-us/library/ms724884%28VS.85%29.aspx">REG_EXPAND_SZ</a> value, to be located using path &#8220;%CommonProgramFiles(x86)%\System\Ole DB\oledb32.dll&#8221;. It is obvious that <strong>CommonProgramFiles(x86)</strong> is placeholder to be expanded, but does the expansion succeed?</p>
<p><span id="more-1086"></span></p>
<p>On my system there was no such environment string, so expansion failed. There however was <strong>CommonProgramFiles</strong>, and it pointed to correct location. So, this hot fix makes it work right:</p>
<pre><span style="color: #603000;">BOOL</span> UpdateEnvironmentVariables<span style="color: #808030;">(</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    <span style="color: #603000;">CString</span> sCommonProgramFilesX86<span style="color: #800080;">;</span>
    sCommonProgramFilesX86<span style="color: #808030;">.</span><span style="color: #400000;">GetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles(x86)</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span>sCommonProgramFilesX86<span style="color: #808030;">.</span>IsEmpty<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span>
    <span style="color: #800080;">{</span>
        <span style="color: #603000;">CString</span> sCommonProgramFiles<span style="color: #800080;">;</span>
        sCommonProgramFiles<span style="color: #808030;">.</span><span style="color: #400000;">GetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">if</span><span style="color: #808030;">(</span><span style="color: #808030;">!</span>sCommonProgramFiles<span style="color: #808030;">.</span>IsEmpty<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span>
        <span style="color: #800080;">{</span>
            ATLVERIFY<span style="color: #808030;">(</span><span style="color: #400000;">SetEnvironmentVariable</span><span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">CommonProgramFiles(x86)</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> sCommonProgramFiles<span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
            <span style="color: #800000; font-weight: bold;">return</span> TRUE<span style="color: #800080;">;</span>
        <span style="color: #800080;">}</span>
    <span style="color: #800080;">}</span>
    <span style="color: #800000; font-weight: bold;">return</span> FALSE<span style="color: #800080;">;</span>
<span style="color: #800080;">}</span>

<span style="color: #800000; font-weight: bold;">int</span> _tmain<span style="color: #808030;">(</span><span style="color: #800000; font-weight: bold;">int</span> argc<span style="color: #808030;">,</span> _TCHAR<span style="color: #808030;">*</span> argv<span style="color: #808030;">[</span><span style="color: #808030;">]</span><span style="color: #808030;">)</span>
<span style="color: #800080;">{</span>
    ATLVERIFY<span style="color: #808030;">(</span>SUCCEEDED<span style="color: #808030;">(</span>CoInitialize<span style="color: #808030;">(</span><span style="color: #7d0045;">NULL</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">{</span>
        UpdateEnvironmentVariables<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        CComPtr<span style="color: #800080;">&lt;</span>IDBInitialize<span style="color: #800080;">&gt;</span> pDbInitialize<span style="color: #800080;">;</span>
        <span style="color: #800000; font-weight: bold;">const</span> HRESULT nResult <span style="color: #808030;">=</span> pDbInitialize<span style="color: #808030;">.</span>CoCreateInstance<span style="color: #808030;">(</span><span style="color: #800000;">L"</span><span style="color: #0000e6;">Microsoft.Jet.OLEDB.4.0</span><span style="color: #800000;">"</span><span style="color: #808030;">,</span> <span style="color: #7d0045;">NULL</span><span style="color: #808030;">,</span> CLSCTX_INPROC_SERVER<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
        _tprintf<span style="color: #808030;">(</span>_T<span style="color: #808030;">(</span><span style="color: #800000;">"</span><span style="color: #0000e6;">nResult 0x</span><span style="color: #0f69ff;">%08x</span><span style="color: #0f69ff;">\n</span><span style="color: #800000;">"</span><span style="color: #808030;">)</span><span style="color: #808030;">,</span> nResult<span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800080;">}</span>
    CoUninitialize<span style="color: #808030;">(</span><span style="color: #808030;">)</span><span style="color: #800080;">;</span>
    <span style="color: #800000; font-weight: bold;">return</span> <span style="color: #008c00;">0</span><span style="color: #800080;">;</span>
<span style="color: #800080;">} </span></pre>
<p>I am under impression that the problem is not specific to Windows 7. I remember similar symptoms on Windows XP system, but they were not critical and not investigated to solution. It rather seems that OLE DB component is registering itself using a reference to environment variable which is not present on a number of systems.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 81px; width: 1px; height: 1px;">
<h3 class="r"><a class="l" onmousedown="return rwt(this,'','','res','1','AFQjCNEiQBNPN2MLUciPFN3dRVUU-1FyJA','&amp;sig2=GPxd_FHW5MyBRM2Op0Da1A','0CAoQFjAA')" href="http://support.software602.com/kb/view.aspx?articleID=987">Error code 80040154. <em>Class not registered</em></a></h3>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/1086/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Microsoft MVP Award in DirectShow/Media Foundation</title>
		<link>http://alax.info/blog/973</link>
		<comments>http://alax.info/blog/973#comments</comments>
		<pubDate>Sat, 04 Jul 2009 08:21:31 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[award]]></category>
		<category><![CDATA[DirectShow]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[mvp]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=973</guid>
		<description><![CDATA[<a href="http://alax.info/blog/973" title="Microsoft MVP Award in DirectShow/Media Foundation"></a>As an appreciation of outstanding contributions in DShow/Media Foundation technical communities during the past year I was presented with the 2009 Microsoft® MVP Award, which I am very much pleased to receive. In an intention to accompany the post with &#8230;<p class="read-more"><a href="http://alax.info/blog/973">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/973" title="Microsoft MVP Award in DirectShow/Media Foundation"></a><p>As an appreciation of outstanding contributions in DShow/Media Foundation technical communities during the past year I was presented with the 2009 <a href="https://mvp.support.microsoft.com/">Microsoft® MVP Award</a>, which I am very much pleased to receive.</p>
<div class="wp-caption aligncenter" style="width: 510px"><a href="http://mvp.support.microsoft.com/" target="_blank"><img class=" " style="margin: 2px;" title="Microsoft Most Valuable Professional Award" src="http://mvp.support.microsoft.com/library/images/support/en-US/MVP_08Banner_EN.jpg" alt="Microsoft Most Valuable Professional Award" width="500" height="80" /></a><p class="wp-caption-text">// Microsoft Most Valuable Professional Award</p></div>
<p>In an intention to accompany the post with useful DirectShow related information, here is the link list of most important DirectShow resources on the Internet:</p>
<ul>
<li>Microsoft:
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/dd375467%28VS.85%29.aspx">DirectShow Reference</a> (do not underestimate official documentation, it is well done and really covers minor but important details)</li>
<li><a href="http://social.msdn.microsoft.com/forums/en-US/windowsdirectshowdevelopment/">DirectShow Development Forum</a></li>
</ul>
</li>
<li>Social:
<ul>
<li><a href="http://groups.google.com/groups/dir?sel=usenet%3Dmicrosoft.public.win32.programmer.directx">Microsoft.public.win32.programmer.directx.* Usenet Groups </a></li>
<li><a href="http://forum.wonderu.com/">DirectShow Forums in Russian</a></li>
</ul>
</li>
<li>Resources online:
<ul>
<li><a href="http://www.riseoftheants.com/mmx/faq.htm">Alessandro Angeli&#8217;s Programming FAQ</a> &#8211; frequently asked questions and answers</li>
<li><a href="http://tmhare.mvps.org/">The March Hare&#8217;s DShow Site</a> &#8211; links, downloads, information</li>
<li><a href="http://www.gdcl.co.uk/">GDCL (Geraint Davies Consulting Ltd) by Geraint Davies</a> &#8211; information and downloads, specifically popular for &#8220;bridge&#8221; solution (<a href="http://www.gdcl.co.uk/gmfbridge/index.htm">GMFBridge</a>) for connecting multiple graphs</li>
<li><a href="http://chrisnet.net/code.htm">Chris P.&#8217;s Code Samples</a> &#8211; especially audio related</li>
<li><a href="http://www.roujansky.com/">Michel Roujansky, Multimedia &amp; IT Consultant and Trainer</a> &#8211; DirectX and DirectShow consulting</li>
<li><a href="http://sourceforge.net/projects/directshownet/">DirectShow.NET Library</a> &#8211; for those who prefer interfacing to DirectShow from managed code, in particular C# (as the .NET questions keep being posted to other places, while they should go directly there)</li>
<li><a href="http://sourceforge.net/projects/guliverkli/">Gabest&#8217;s Guliverkli Project</a> &#8211; on SourceForge, a home of Media Player Classic and various filters</li>
<li><a href="http://blog.monogram.sk/janos/2009/06/14/monogram-graphstudio-0320/">Monogram Multimedia and Igor Jánoš</a> &#8211; with <a href="http://blog.monogram.sk/janos/2009/06/14/monogram-graphstudio-0320/">GraphStudio</a>, an important alternative to Windows SDK GraphEdit, and a home of useful DirectShow <a href="http://blog.monogram.sk/janos/directshow-filters/">filters</a></li>
</ul>
</li>
<li>Non-DirectShow but related:
<ul>
<li><a href="http://software.intel.com/en-us/intel-ipp/">Intel Integrated Performance Primitives Library</a> &#8211; a library with basic media related functions built with performance in mind, provided with sample code that covers a wide range of existing multimedia algorithms and tasks</li>
</ul>
</li>
</ul>
<p><span id="more-973"></span></p>
<div id="attachment_985" class="wp-caption alignleft" style="width: 310px"><a href="http://alax.info/blog/wp-content/uploads/2009/07/img_1056a.jpg"><img class="size-medium wp-image-985" title="Microsoft MVP Award Souvenir and Certificate" src="http://alax.info/blog/wp-content/uploads/2009/07/img_1056a-300x186.jpg" alt="Microsoft MVP Award Souvenir and Certificate" width="300" height="186" /></a><p class="wp-caption-text">Microsoft MVP Award Souvenir and Certificate</p></div>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/973/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Shell integration and Windows Live Messenger: things that should have never been done</title>
		<link>http://alax.info/blog/958</link>
		<comments>http://alax.info/blog/958#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:52:13 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[messenger]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=958</guid>
		<description><![CDATA[<a href="http://alax.info/blog/958" title="Windows Shell integration and Windows Live Messenger: things that should have never been done"></a>If you drag a file over Windows Live Messenger&#8216;s My Sharing Folders shell name space item, it would immediately interrupt dragging with an error message box, even if you never planned to drop onto this folder: This should definitely be &#8230;<p class="read-more"><a href="http://alax.info/blog/958">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/958" title="Windows Shell integration and Windows Live Messenger: things that should have never been done"></a><p>If you drag a file over <a href="http://download.live.com/messenger">Windows Live Messenger</a>&#8216;s <em>My Sharing Folders</em> shell name space item, it would immediately interrupt dragging with an error message box, even if you never planned to drop onto this folder:</p>
<p><img class="alignnone size-full wp-image-957" title="Windows Live Messenger" src="http://alax.info/blog/wp-content/uploads/2009/06/24-image001.png" alt="Windows Live Messenger" width="698" height="388" /></p>
<p>This should definitely be rather implemented a different way. If you ever tried to drag something using slow PC touchpad, you probably have an idea of how annoying such an interruption could be.</p>
<p>Windows Live Messenger was pre-installed. To disable shared folders feature, I wanted to find a proper setting in options, but it did not appear to be easy enough: Help button, Show the menu bar, Tools, Options, Sharing Folders on the left, oops! it was not helpful.</p>
<p>Going another way of finding DLL that hosts the shell extension revealed file named: <em>C:\Program Files\Windows Live\Messenger\fsshext.8.5.1302.1018.dll</em>. Once unregistered, the folder went away from the shell (process restart needed, typically logoff/logon):</p>
<pre>C:\&gt;regsvr32 /u "C:\Program Files\Windows Live\Messenger\fsshext.8.5.1302.1018.dll"</pre>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/958/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Downloading Windows 7 Beta 32-bit</title>
		<link>http://alax.info/blog/787</link>
		<comments>http://alax.info/blog/787#comments</comments>
		<pubDate>Mon, 02 Feb 2009 23:39:12 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[crap]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[seven]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=787</guid>
		<description><![CDATA[<a href="http://alax.info/blog/787" title="Downloading Windows 7 Beta 32-bit"></a>I decided to download a beta of Windows 7, so many people shared their positive impressions of. I am not quite sure I will have time to actually evaluate it, but for the case I would feel like, it is &#8230;<p class="read-more"><a href="http://alax.info/blog/787">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/787" title="Downloading Windows 7 Beta 32-bit"></a><p>I decided to download <a href="https://www.microsoft.com/betaexperience/productkeys/win7-32/enus/default.aspx">a beta of Windows 7</a>, so many people shared their positive impressions of. I am not quite sure I will have time to actually evaluate it, but for the case I would feel like, it is always nice to have the .ISO image ready for a try.</p>
<p>There was nothing worth a word until I reached the download screen which opened an extremely awful Java applet that pretended to be a download manager. It seemed to be a new spin of technology and sort of I don&#8217;t need a nice download manager anymore because direct HTTP links are out of fashion. It started pumping bytes (actually thanks for that) and I my attempt to copy/paste a direct link into my <a href="http://www.downthemall.net/">DownThemAll</a> <a href="http://mozilla.org">FireFox</a> plugin was vain.</p>
<p>At some 20% the download froze without a notice. The download did not even ungray the resume buttons before I restarted FireFox process and then any attempt to resume led to weird message boxes. Frankly at this point I almost lost the desire to actually complete the download. But left a last chance to have it completed by IE. Internet Explorer (expectedly!) preferred ActiveX control to Java applet. It&#8217;s GUI was a bit less scary and it took over incomplete download and&#8230;</p>
<p><a href="http://alax.info/blog/wp-content/uploads/2009/02/02-image001.png"><img class="alignnone size-medium wp-image-788" title="Window 7 Beta Download Manager Crash" src="http://alax.info/blog/wp-content/uploads/2009/02/02-image001-300x185.png" alt="" width="300" height="185" /></a></p>
<p>An attached debugger showed a call stack (oops, I did not save exact call stack) in Manager.exe process in C runtime module, in a CString class method&#8230; It went no further than this crashing at exactly the same point until I manually deleted the incomplete download, when it again repeated a weird message box and then finally restart the download from the start. That was enough for me and found a .torrent with the exactly the same file on <a href="http://thepiratebay.org">thepiratebay.org</a>, which I am quite sure will download without a problem.</p>
<p>Isn&#8217;t it incredibly stupid that significant amount of work was invested into unnecessary task, ugly user interface, buggy implementation (freeze, incapable download manager, weird messages, crash) with a solid residual of inability to conveniently download the thing, while the file could be just put onto regular MS download service?</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/787/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Frame-Pointer Omission /Oy</title>
		<link>http://alax.info/blog/672</link>
		<comments>http://alax.info/blog/672#comments</comments>
		<pubDate>Sat, 18 Oct 2008 18:34:35 +0000</pubDate>
		<dc:creator>Roman</dc:creator>
				<category><![CDATA[Seriously]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://alax.info/blog/?p=672</guid>
		<description><![CDATA[<a href="http://alax.info/blog/672" title="Frame-Pointer Omission /Oy "></a>I just read a post on frame pointer omission (FPO) optimization, also known as /Oy compiler flag. And a comment from Vladimir Scherbina on problems getting the feature actually work. I wondered if there has been any improvement with a &#8230;<p class="read-more"><a href="http://alax.info/blog/672">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://alax.info/blog/672" title="Frame-Pointer Omission /Oy "></a><p>I just read a post on frame pointer omission (FPO) optimization, also known as /Oy compiler flag. And a comment from Vladimir Scherbina on problems getting the feature actually work. I wondered if there has been any improvement with a Visual Studio .NET 2008 SP1. latest compiler from Microsoft and briefly &#8211; the result is yes, the feature seems to be working.</p>
<p>This is the reference code for the feature:</p>
<pre>const volatile INT g_nValueA = 0;
const volatile INT g_nValueB = 0;

#pragma optimize("y", off)

__declspec(dllexport) __declspec(noinline) BOOL STDMETHODCALLTYPE A(const volatile INT&amp; nValue = g_nValueA)
{
	return nValue != 0;
}

#pragma optimize("y", on)

__declspec(dllexport) __declspec(noinline) BOOL STDMETHODCALLTYPE B(const volatile INT&amp; nValue = g_nValueB)
{
	return nValue != 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
	A();
	B();
	return 0;
}</pre>
<p>The code is to be compiled in Release and function A is to be not optimized while B is subject for optimization and omitting the frame pointer.</p>
<p>Disassembly shows for A:</p>
<p><span id="more-672"></span></p>
<pre>__declspec(dllexport) __declspec(noinline) BOOL STDMETHODCALLTYPE A(const volatile INT&amp; nValue = g_nValueA)
{
00401000  push        ebp
00401001  mov         ebp,esp
	return nValue != 0;
00401003  mov         eax,dword ptr [nValue]
00401006  mov         ecx,dword ptr [eax]
00401008  xor         eax,eax
0040100A  test        ecx,ecx
0040100C  setne       al
}
0040100F  pop         ebp
00401010  ret         4</pre>
<p>and for B:</p>
<pre>__declspec(dllexport) __declspec(noinline) BOOL STDMETHODCALLTYPE B(const volatile INT&amp; nValue = g_nValueB)
{
	return nValue != 0;
00401020  mov         eax,dword ptr [esp+4]
00401024  mov         ecx,dword ptr [eax]
00401026  xor         eax,eax
00401028  test        ecx,ecx
0040102A  setne       al
}
0040102D  ret         4</pre>
<p>and the difference is what was actually expected. It looked as it finally got to work but a check with Visual Studio versions 2003 and 2005 shown that optiomization makes a difference on older versions too.</p>
]]></content:encoded>
			<wfw:commentRss>http://alax.info/blog/672/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

