<?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>Mobile Development - 'Support Side Story'</title><link>http://blogs.msdn.com/b/raffael/</link><description>Broadcasting technical support to Windows Mobile\CE Application Developers to help realizing their potential</description><dc:language>en-US</dc:language><generator>Telligent Community 5.6.583.19199 (Build: 5.6.583.19199)</generator><item><title>Footprint on the Mobile Developer Community</title><link>http://blogs.msdn.com/b/raffael/archive/2011/10/11/footprint-on-the-mobile-developer-community.aspx</link><pubDate>Tue, 11 Oct 2011 13:04:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10223203</guid><dc:creator>Raffaele Limosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=10223203</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2011/10/11/footprint-on-the-mobile-developer-community.aspx#comments</comments><description>&lt;p&gt;"Hello world!" It's been a really long time I don't post anything on this blog... for multiple reasons actually, the main one probably&amp;nbsp;being that Windows CE\Mobile is such a mature technology that "&lt;em&gt;quite&lt;/em&gt;" every problem has been found and addressed! &lt;img alt="Winking" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" /&gt;&amp;nbsp;Another reason is that we provide&amp;nbsp;support for Windows Phone 7&amp;nbsp;through&amp;nbsp;our App Hub Forums community (&lt;a href="http://forums.create.msdn.com"&gt;http://forums.create.msdn.com&lt;/a&gt;), even if for complex scenarios&amp;nbsp;Technical Support is always available through regular Service Requests&amp;nbsp;(last couple of weeks I repeteadly hit my head on a&amp;nbsp;WP7.5 application accessing&amp;nbsp;WCF Services on a IIS accepting Basic Authentication only, over SSL...). Anyway looking at blog-statistics I can see that even if I've not been posting,&amp;nbsp;this blog is still visited&amp;nbsp;by many and that lets me hope&amp;nbsp;it has been having&amp;nbsp;a good impact to the &lt;strong&gt;Mobile Developer Community&lt;/strong&gt; during these 3+ years. There are posts more read than others, and in some cases that surprises me - indeed, what I consider one of my best posts is not the most read one&amp;nbsp;&lt;img alt="Sad" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/sad_smile.gif" /&gt;&amp;nbsp;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx" href="http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx" target="_blank"&gt;Basics on Windows CE\Mobile: an alternative way to approach the Memory Monster&lt;/a&gt;.&amp;nbsp;Actually, the most read ones are the following (why the one on GPS? Probably for&amp;nbsp;some keywords...):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2008/03/25/gps-programming-tips-for-windows-mobile-part-1.aspx" href="http://blogs.msdn.com/b/raffael/archive/2008/03/25/gps-programming-tips-for-windows-mobile-part-1.aspx" target="_blank"&gt;GPS Programming Tips for Windows Mobile - Part 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx" href="http://blogs.msdn.com/b/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx" target="_blank"&gt;Microsoft released a HotFix for NETCF v3.5 on Windows Mobile 6.1.4 onwards, to address basic functionalities of WebBrowser control&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2008/02/21/netcf-memory-leak-now-what.aspx" href="http://blogs.msdn.com/b/raffael/archive/2008/02/21/netcf-memory-leak-now-what.aspx" target="_blank"&gt;NETCF: Memory leak... now what??&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2008/03/01/supporting-kiosk-applications-on-windows-mobile-technically-achievable-vs-supported.aspx" href="http://blogs.msdn.com/b/raffael/archive/2008/03/01/supporting-kiosk-applications-on-windows-mobile-technically-achievable-vs-supported.aspx" target="_blank"&gt;Supporting Kiosk-Applications on Windows Mobile (Technically achievable vs. supported)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2010/02/08/silverlight-for-windows-embedded-ce-6-0-first-sample-codes-stress-and-multiple-instances-of-a-control-in-separate-dll.aspx" href="http://blogs.msdn.com/b/raffael/archive/2010/02/08/silverlight-for-windows-embedded-ce-6-0-first-sample-codes-stress-and-multiple-instances-of-a-control-in-separate-dll.aspx" target="_blank"&gt;Silverlight for Windows Embedded CE 6.0: First sample codes (stress and multiple instances of a control in separate DLL)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2008/09/08/mapi-on-windows-mobile-6-programmatically-retrieve-mail-body-sample-code.aspx" href="http://blogs.msdn.com/b/raffael/archive/2008/09/08/mapi-on-windows-mobile-6-programmatically-retrieve-mail-body-sample-code.aspx" target="_blank"&gt;MAPI on Windows Mobile 6: Programmatically retrieve mail BODY (sample code)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2008/02/26/establishing-gprs-connection-on-windows-ce-and-windows-mobile-sample-codes.aspx" href="http://blogs.msdn.com/b/raffael/archive/2008/02/26/establishing-gprs-connection-on-windows-ce-and-windows-mobile-sample-codes.aspx" target="_blank"&gt;Establishing GPRS Connection on Windows CE and Windows Mobile: Sample Codes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2009/02/27/wireless-programming-on-windows-mobile-supported-or-not-supported.aspx" href="http://blogs.msdn.com/b/raffael/archive/2009/02/27/wireless-programming-on-windows-mobile-supported-or-not-supported.aspx" target="_blank"&gt;Wireless Programming on Windows Mobile: supported or not supported?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2009/09/11/remote-desktop-mobile-rdp-client-disconnects-after-10-minutes-of-inactivity.aspx" href="http://blogs.msdn.com/b/raffael/archive/2009/09/11/remote-desktop-mobile-rdp-client-disconnects-after-10-minutes-of-inactivity.aspx" target="_blank"&gt;Remote Desktop Mobile (RDP Client) disconnects after 10 minutes of inactivity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a title="http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx" href="http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx" target="_blank"&gt;Basics on Windows CE\Mobile: an alternative way to approach the Memory Monster&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I truly hope these have helped Mobile Developers out there!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;~raffaele&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Good luck is another name for tenacity of purpose.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10223203" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category></item><item><title>#WP7: “The importance of being…” SUPPORTED!</title><link>http://blogs.msdn.com/b/raffael/archive/2010/03/16/wp7-the-importance-of-being-supported.aspx</link><pubDate>Tue, 16 Mar 2010 11:11:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9979395</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9979395</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/03/16/wp7-the-importance-of-being-supported.aspx#comments</comments><description>&lt;p&gt;Another non-technical one, but really proud of… &lt;img alt="Winking" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" /&gt; From &lt;a title="http://live.visitmix.com/Resources" href="http://live.visitmix.com/Resources"&gt;http://live.visitmix.com/Resources&lt;/a&gt;, under “Windows Phone 7 Series” category:&lt;/p&gt;  &lt;p&gt;&lt;a title="WP7S MSDN Forum" href="http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="wp7sup" border="0" alt="wp7sup" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/WP7TheimportanceofbeingSUPPORTED_A7DF/wp7sup_3.jpg" width="562" height="157" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Some interesting resources:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a title="WP7S Training Kit" href="http://channel9.msdn.com/learn/courses/WP7TrainingKit" target="_blank"&gt;Windows Phone 7 Series Developer Training Kit&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a title="Charles Petzold&amp;#39;s Programming WP7S" href="http://blogs.msdn.com/microsoft_press/archive/2010/03/15/free-ebook-programming-windows-phone-7-series-draft-preview.aspx" target="_blank"&gt;Charles Petzold’s free ebook: Programming Windows Phone 7 Series (DRAFT Preview)&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;MIX10 sessions at &lt;a href="http://live.visitmix.com"&gt;http://live.visitmix.com&lt;/a&gt;.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Cheers!   &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9979395" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Phone+7+Series/">Windows Phone 7 Series</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/VS2010+Express+for+Windows+Phone/">VS2010 Express for Windows Phone</category></item><item><title>Windows Mobile 6.5 Certifications</title><link>http://blogs.msdn.com/b/raffael/archive/2010/03/09/windows-mobile-6-5-certifications.aspx</link><pubDate>Tue, 09 Mar 2010 08:36:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9975358</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9975358</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/03/09/windows-mobile-6-5-certifications.aspx#comments</comments><description>&lt;p&gt;Certifications for Windows Mobile 6.5 are finishing their beta-phase… so I can now share my current medals: &lt;img alt="Happy" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/WindowsMobileCertifications_82C0/MCTS(rgb)_524_523_1343_1344_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="MCTS(rgb)_524_523_1343_1344" border="0" alt="MCTS(rgb)_524_523_1343_1344" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/WindowsMobileCertifications_82C0/MCTS(rgb)_524_523_1343_1344_thumb.png" width="456" height="83" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Details about the exams on:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-579" target="_blank"&gt;&lt;strong&gt;TS: Windows Mobile 6.5, Configuring&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-580" target="_blank"&gt;&lt;strong&gt;TS: Windows Mobile 6.5, Application Development&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;HTH!    &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9975358" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Scatter+Thoughts/">Scatter Thoughts</category></item><item><title>Fix released for WM6.x devices with HTC and Samsung drivers about UI slowdown</title><link>http://blogs.msdn.com/b/raffael/archive/2010/02/12/fix-released-for-wm6-x-devices-with-htc-and-samsung-drivers-about-ui-slowdown.aspx</link><pubDate>Fri, 12 Feb 2010 10:24:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9962522</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9962522</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/02/12/fix-released-for-wm6-x-devices-with-htc-and-samsung-drivers-about-ui-slowdown.aspx#comments</comments><description>&lt;p&gt;A very quick post: if you’re using devices powered with HTC or Samsung drivers (such as also the Sony-Ericsson Xperia X1, for example) and noticed periodic slowdowns of the UI, then you may benefit of the following fix: &lt;a href="http://support.microsoft.com/kb/979220" target="_blank"&gt;Some GUI interactions no longer work correctly on Windows Mobile 6.1 devices and Windows Mobile 6.5 devices&lt;/a&gt;. This is not strictly required, so make sure to read the Symptoms section. And please remember to fill out the feedback at the bottom of the page! &lt;img alt="Happy" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" /&gt;&lt;/p&gt;  &lt;p&gt;Cheers,    &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9962522" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Utilities/">Utilities</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/HotFix/">HotFix</category></item><item><title>Silverlight for Windows Embedded CE 6.0: First sample codes (stress and multiple instances of a control in separate DLL)</title><link>http://blogs.msdn.com/b/raffael/archive/2010/02/08/silverlight-for-windows-embedded-ce-6-0-first-sample-codes-stress-and-multiple-instances-of-a-control-in-separate-dll.aspx</link><pubDate>Mon, 08 Feb 2010 12:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9959690</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9959690</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/02/08/silverlight-for-windows-embedded-ce-6-0-first-sample-codes-stress-and-multiple-instances-of-a-control-in-separate-dll.aspx#comments</comments><description>&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Intro about SWE (Silverlight for Windows Embedded)&lt;/EM&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Sample code for simple starting stress-test&lt;/EM&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Sample code showing multiple instances of a control, implemented as separate DLL&lt;/EM&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/a0d80c7ee30f_8F10/sweUIs_2.jpg" mce_href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/a0d80c7ee30f_8F10/sweUIs_2.jpg"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=sweUIs border=0 alt=sweUIs src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/a0d80c7ee30f_8F10/sweUIs_thumb.jpg" width=565 height=210 mce_src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/a0d80c7ee30f_8F10/sweUIs_thumb.jpg"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Part of my job as Support Engineer is to handle requests coming from ISVs developing applications for Windows CE: this is not always an easy task because contrarily to Windows Mobile, for which OEMs must stick to some specifications (otherwise their OS would fail the “Windows Mobile Logo Test Kit”), when it comes to Windows CE (or “Windows Embedded CE”, you know what I mean…) the OEMs have the complete freedom of developing whatever module or driver to be included in their OS, so in some cases the only option to understand a problem’s cause or to reach a specific goal programmatically, is to engage the OEM. I surely have already talked about this in the past… &lt;IMG alt=Happy src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif" mce_src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/1.gif"&gt;&lt;/P&gt;
&lt;P&gt;So, requests from ISVs targeting Windows CE are rare compared to the ones for Windows Mobile, but after the release of Windows Embedded CE 6.0 R3 (“&lt;EM&gt;Cashmere”&lt;/EM&gt;) Microsoft did on late September 2009, I’ve started handling some very interesting cases about &lt;STRONG&gt;Silverlight for Windows Embedded&lt;/STRONG&gt; (“&lt;STRONG&gt;SWE&lt;/STRONG&gt;” from now on). During past months many have discussed about this topic and how “particular” it seems to be programming for Silverlight in C++ instead that in .NET… so I’d like to share some info and sample code that I’ve personally been using so far.&lt;/P&gt;
&lt;P&gt;Before doing that, even just because this is the very first post about SWE I’m writing, let me digress a bit so that we can all be on the same page. Above all, if you have no idea what SWE is at all about, then I think that nothing else than watching it in action would help on describing it, and apart from some other videos from latest conferences we may benefit of a 15' minutes-long demo recorded by Mike Hall back in June 2009 together with Jeff MacDuff and Todd Segal, available thru his post &lt;A href="http://blogs.msdn.com/mikehall/archive/2009/06/03/creating-compelling-user-interfaces-for-embedded-devices.aspx" target=_blank mce_href="http://blogs.msdn.com/mikehall/archive/2009/06/03/creating-compelling-user-interfaces-for-embedded-devices.aspx"&gt;&lt;STRONG&gt;Creating compelling user interfaces for embedded devices&lt;/STRONG&gt;&lt;/A&gt;&lt;STRONG&gt; &lt;/STRONG&gt;(even if Jeff and Todd paid attention not to disclose the “name” of the underlying technology, we now know it’s SWE! &lt;IMG alt=Hot src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/shades_smile.gif" mce_src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/shades_smile.gif"&gt;).&lt;/P&gt;
&lt;P&gt;So, the idea is very simple: just divide the job done by designers and by developers and let everyone do what is good at. Designers have their tools to develop the UI (for example, Expression Blend) and developers have theirs to develop the Business Logic (for example, Visual Studio). Developers won’t even need to know how the UI looks like in fact (my sample code below are an example for that). More about this idea is available through the document &lt;A title="Introduction to Application Development with Silverlight for Windows" href="http://download.microsoft.com/download/C/D/6/CD6D5B84-EFF5-4916-8EB6-CEB6C3479D8F/IntroToSilverlightForWindowsEmbedded-Whitepaper.pdf" mce_href="http://download.microsoft.com/download/C/D/6/CD6D5B84-EFF5-4916-8EB6-CEB6C3479D8F/IntroToSilverlightForWindowsEmbedded-Whitepaper.pdf"&gt;Introduction to Application Development with Silverlight for Windows Embedded&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;The important thing is that those out-of-browser applications are possible through a powerful engine, i.e. the &lt;STRONG&gt;XAML Runtime&lt;/STRONG&gt;, that takes care of glueing the UI to the code-behind by supporting a subset of Silverlight 2 XAML. The object model to programmaticaly interact with such runtime is native. &lt;/P&gt;Other introductive videos, as reported by Olivier Bloch &lt;A href="http://blogs.msdn.com/obloch/archive/2009/09/23/windows-embedded-ce-6-0-r3-release.aspx" target=_blank mce_href="http://blogs.msdn.com/obloch/archive/2009/09/23/windows-embedded-ce-6-0-r3-release.aspx"&gt;in his post&lt;/A&gt;: 
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=1" mce_href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=1"&gt;Introduction to Silverlight for Windows Embedded&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=2" mce_href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=2"&gt;Working with XAML in Expression Blend&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=3" mce_href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/silverlightforwe.mspx?session=3"&gt;Create a user control in Silverlight for Windows Embedded&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Now: imagine you’re a Windows Mobile developer or in any case not a CE6.0 OEM – this means you don’t have the tools to even start investigating how programming for SWE looks like. If that’s the case, remember that precisely as it was for its predecessors, also &lt;STRONG&gt;Windows Embedded CE 6.0 R3 has its own evaluation edition&lt;/STRONG&gt; that you can freely download and that is fully functional for 6 months. Note that this is no longer a separate IDE as it was for Windows CE 5.0: it’s an addin that integrates with VS2005 SP1 – follow all the steps &lt;A href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/getting-started.mspx" target=_blank mce_href="http://www.microsoft.com/windowsembedded/en-us/products/windowsce/getting-started.mspx"&gt;here&lt;/A&gt;. The evaluation copy includes the software tool for interaction design, Expression Blend 2.0 and gives you the ability to create a so-called “Private SDK” related to the XAML Runtime-powered CE image (the required component is &lt;EM&gt;SYSGEN_XAML_RUNTIME&lt;/EM&gt;) and containing a Device Emulator image targetable from VS2008 directly.&lt;/P&gt;
&lt;P&gt;Still about tools, Olivier Bloch explained &lt;A href="http://blogs.msdn.com/obloch/archive/2009/11/17/xaml2cpp-the-missing-tool-for-silverlight-for-windows-embedded-developers.aspx" target=_blank mce_href="http://blogs.msdn.com/obloch/archive/2009/11/17/xaml2cpp-the-missing-tool-for-silverlight-for-windows-embedded-developers.aspx"&gt;here&lt;/A&gt; why there’s a lack of really tied integration between the UI and the code-behind: “[…] &lt;EM&gt;Well here is the answer: there has been some decisions made to make this technology available as is because our customers were in urgent need of this technology.&lt;/EM&gt;”. I’ve not yet personally tested it, but this missing functionality seems to be provided by the (Italian! &lt;IMG alt=Winking src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" mce_src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif"&gt;) &lt;STRONG&gt;Microsoft MVP Walter Minute &lt;/STRONG&gt;through his &lt;A href="http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2010/01/20/xaml2cpp-ver-1.0.0.2.aspx" target=_blank mce_href="http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2010/01/20/xaml2cpp-ver-1.0.0.2.aspx"&gt;XAML2CPP tool&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;So, after this quick intro, what I’d like to share here is:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A starting sample code useful for testing purposes &lt;/LI&gt;
&lt;LI&gt;A sample showing how to use multiple instances of a SWE Custom User Control library (DLL separate from the SWE Application) &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;The sample is very easy to read and I used it as starting poing to run specific tests, for example about automating resources-stressing. The code is based on the documentation &lt;A href="http://msdn.microsoft.com/en-us/library/ee503558.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee503558.aspx"&gt;Create a Silverlight for Windows Embedded Application&lt;/A&gt;: &lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//global vars&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;IXRStackPanelPtr m_pStackPanel; &lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;IXRApplicationPtr m_pApp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, &lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; nCmdShow)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; exitCode                    = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT hr                      = S_FALSE;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRVisualHostPtr vhost          = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRFrameworkElementPtr root     = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Initialize Xaml Runtime&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (!XamlRuntimeInitialize())&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; -1;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Get XRAppInstance&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = GetXRApplicationInstance(&amp;amp;m_pApp);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XRWindowCreateParams wp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    ZeroMemory(&amp;amp;wp, &lt;SPAN style="COLOR: #0000ff"&gt;sizeof&lt;/SPAN&gt;(XRWindowCreateParams));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Style       = WS_OVERLAPPED | WS_SYSMENU;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.pTitle      = L&lt;SPAN style="COLOR: #006080"&gt;"SWE Testing"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Left        = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Top         = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Retrieve resource associated to the PAGE.XAML file&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XRXamlSource xamlsrc;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    xamlsrc.SetResource(hInstance,TEXT(&lt;SPAN style="COLOR: #006080"&gt;"XAML"&lt;/SPAN&gt;), MAKEINTRESOURCE(IDR_XAML_PAGE));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Create host&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = m_pApp-&amp;gt;CreateHostFromXaml(&amp;amp;xamlsrc, &amp;amp;wp, &amp;amp;vhost);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Get Root Element of the XAML&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = vhost-&amp;gt;GetRootElement(&amp;amp;root);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Get the Stack Panel&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = root-&amp;gt;FindName(TEXT(&lt;SPAN style="COLOR: #006080"&gt;"LayoutRoot"&lt;/SPAN&gt;), &amp;amp;m_pStackPanel); &lt;SPAN style="COLOR: #008000"&gt;//Grid = StackPanel&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//TODO: Add test code here&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//For automation purposes, create a Timer&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Automation testing code in TimerProc function&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    Timer = SetTimer(0, 0, 250, TimerProc);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    UINT exitcode;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = vhost-&amp;gt;StartDialog(&amp;amp;exitcode);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Exit:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XamlRuntimeUninitialize();&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;)hr;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;void&lt;/SPAN&gt; CALLBACK TimerProc(HWND hwnd, UINT, UINT, DWORD dwTime)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//TODO: Automation code here&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//... &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Just to see the UI refreshed&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    InvalidateRect(GetActiveWindow(), NULL, &lt;SPAN style="COLOR: #0000ff"&gt;TRUE&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;In another case the ISV was interested on maintaining main application (or main page) separate from the control DLLs, so that he could re-use the control separately by other applications. Also, he was interested on having multiple instances of the same control within the same application. &lt;/P&gt;
&lt;P&gt;What I could learn through this Service Request is that the XAML Runtime takes care of (quite) everything for you! &lt;IMG alt="Love Struck" src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/8.gif" mce_src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/8.gif"&gt; I left many comments in the sample code (for me at least!) but probably the most important bit here is that &lt;EM&gt;&lt;U&gt;a control class is derived from &lt;/U&gt;&lt;/EM&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/ee502483.aspx" mce_href="http://msdn.microsoft.com/en-us/library/ee502483.aspx"&gt;&lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;XRCustomUserControlImpl&lt;/STRONG&gt;&amp;lt;Class [,Interface]&amp;gt;&lt;/U&gt;&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;&lt;U&gt;, therefore it’s an abstract class hence can’t be instantiated and needs to have static functions only&lt;/U&gt;&lt;/EM&gt;. This means that you can’t really talk about “visual controls hosted in an application” – what happens instead is that the XAML Runtime executes and renders different bits of XAML code. &lt;STRONG&gt;&lt;FONT color=#ff0000&gt;So, look at “controls” as “chunks of XAML”&lt;/FONT&gt;&lt;/STRONG&gt; (this is not really object-oriented…). This also means that before using the control, you need to initialize it becasue before calling &lt;EM&gt;IXRApplication::CreateHostFromXaml&lt;/EM&gt; from the application EXE code (note closely where &lt;EM&gt;CreateHostFromXaml&lt;/EM&gt; is called in WinMain), the XAML Runtime must know all the associations between Classes and XAML Namespaces.&lt;/P&gt;
&lt;P&gt;In other words, the “initialization” of a control should be done in2 steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Set up the global var for the application instance so that Application’s EXE and Control’s DLL share the same and secondly invoke .Register on the control so that the XAML Runtime knows how to associate XAML Namespace and control class [in the sample, this is &lt;EM&gt;MyControl::MyControlPreInitialize&lt;/EM&gt;] &lt;/LI&gt;
&lt;LI&gt;Initialization of the control, for example in terms of delegates associated to its events [in the sample, this is &lt;EM&gt;MyControl::MyControlInitialize&lt;/EM&gt;] &lt;/LI&gt;&lt;/OL&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//CONTROL CLASS DECLARATION &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; __declspec(uuid(&lt;SPAN style="COLOR: #006080"&gt;"{1F8F37C1-CA69-4894-A6AA-8667F9387E2E}"&lt;/SPAN&gt;)) &lt;SPAN style="COLOR: #008000"&gt;//Change GUID!&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;MyControl : &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt; XRCustomUserControlImpl&amp;lt;MyControl&amp;gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; HRESULT GetXamlSource(XRXamlSource* pXamlSource);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; HRESULT Register(HINSTANCE hInstance);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #008000"&gt;//Added these functions so that they can be exported through a .LIB (created by adding a .DEF to the project)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #008000"&gt;//Any exe application using this control will need to link the .LIB&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; HRESULT MyControlInitialize(IXRFrameworkElementPtr root, LPCTSTR pszControlClassName);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;static&lt;/SPAN&gt; HRESULT MyControlPreInitialize(HINSTANCE hInstance);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;};&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//*************************************************************************************&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//Standard implementation of XRCustomUserControlImpl&amp;lt;&amp;gt;.GetXamlSource&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;HRESULT MyControl::GetXamlSource(XRXamlSource* pXamlSource)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Retrieve the resource (the XAML file) from the DLL Module&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    pXamlSource-&amp;gt;SetResource((HINSTANCE)GetModuleHandle(lpThisModule), TEXT(&lt;SPAN style="COLOR: #006080"&gt;"XAML"&lt;/SPAN&gt;), MAKEINTRESOURCE(IDR_XAML_MYCTRL));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; S_OK;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//Standard implementation of XRCustomUserControlImpl&amp;lt;&amp;gt;.Register&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;HRESULT MyControl::Register(HINSTANCE hInstance)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT hr = S_FALSE;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = XRCustomUserControlImpl::Register(__uuidof(MyControl), L&lt;SPAN style="COLOR: #006080"&gt;"MyControl"&lt;/SPAN&gt;, L&lt;SPAN style="COLOR: #006080"&gt;"clr-namespace:SLForEmbedded"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Exit:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; hr;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;// Setup the global var for the application instance and invoke .Register on the control.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;HRESULT MyControl::MyControlPreInitialize(HINSTANCE hInstance)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    s_appInstance = hInstance;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT hr = S_FALSE;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;/*LEFT FOR COMMENTING PURPOSES, IN CASE THE .XAML WILL CONTAIN IMAGE or FONT &amp;lt;Application.Resources&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    ////Initialize Xaml Runtime --&amp;gt; If needed, then add MyControl::UnInitialize&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //if (!XamlRuntimeInitialize())&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //    return -1;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    ////1. Get XRAppInstance &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //IXRApplicationPtr app;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //hr = GetXRApplicationInstance(&amp;amp;app);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //2. Add control resource &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    /*This is needed when there are resources within the XAML of type XAML_RESOURCE&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //hr = app-&amp;gt;AddResourceModule(hInstance);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    // ONLY IF &amp;lt;Application.Resources&amp;gt; IN THE APPLICATION's XAML:&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //The following code shows an example of XAML markup that must be parsed &lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //into a resource dictionary:&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //&amp;lt;Application.Resources&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //    &amp;lt;SolidColorBrush x:Key="Text_DefaultColor" Color="#FF292F33"/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //&amp;lt;/Application.Resources&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //IXRResourceDictionary* pResourceDictionary;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //XRXamlSource Source;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //Source.SetFile(MAKEINTRESOURCE(IDR_XAML_MYCONTROL));&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //hr = app-&amp;gt;LoadResourceDictionary(&amp;amp;Source, &amp;amp;pResourceDictionary);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //hr = app-&amp;gt;GetResourceDictionary(&amp;amp;pResourceDictionary);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    //CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;    */&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//3. Register control's Namespace&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = MyControl::Register(hInstance);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Exit:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; hr;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//Initialize the control and event handlers&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;HRESULT MyControl::MyControlInitialize(IXRFrameworkElementPtr root, LPCTSTR pszControlClassName)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT hr = S_FALSE;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRControlPtr m_myUserControl;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    BtnEventHandler m_btnUserControlHandler;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRDelegate&amp;lt;XRMouseButtonEventArgs&amp;gt;* m_btnUserControlDelegate;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRButtonBasePtr m_btnUserControl;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//hr = root-&amp;gt;FindName(TEXT("MyUserControl"), &amp;amp;m_myUserControl);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = root-&amp;gt;FindName(pszControlClassName, &amp;amp;m_myUserControl);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//m_btnUserControlHandler.m_StoryboardPaused = FALSE;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//BtnEventHandler::m_StoryboardPaused = FALSE;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    m_StoryboardPaused = &lt;SPAN style="COLOR: #0000ff"&gt;FALSE&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = m_myUserControl-&amp;gt;FindName(TEXT(&lt;SPAN style="COLOR: #006080"&gt;"btnUserControl"&lt;/SPAN&gt;), &amp;amp;m_btnUserControl);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = CreateDelegate(&amp;amp;m_btnUserControlHandler, &amp;amp;BtnEventHandler::btnUserControlOnClick,&amp;amp;m_btnUserControlDelegate);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = m_btnUserControl-&amp;gt;AddClickEventHandler(m_btnUserControlDelegate);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Exit:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; hr;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//TODO: Add event handler code&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; BtnEventHandler&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT btnUserControlOnClick(IXRDependencyObject* pSender, XRMouseButtonEventArgs* pArgs)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    {&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        MessageBox(GetActiveWindow(), L&lt;SPAN style="COLOR: #006080"&gt;"User Control button clicked."&lt;/SPAN&gt;, L&lt;SPAN style="COLOR: #006080"&gt;"Event Handler"&lt;/SPAN&gt;, MB_OK | MB_ICONINFORMATION);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; S_OK;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    }&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;};&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;For the application:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//Application's MAIN Entry Pointint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt; exitCode                    = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    HRESULT hr                      = S_FALSE;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRApplicationPtr app           = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt; &lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//(let's keep it simple here...)This is not needed when the XAML has not &amp;lt;Application.Resources&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//IXRResourceManager* pResourceMgr = NULL;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRVisualHostPtr vhost          = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRFrameworkElementPtr root     = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRButtonBasePtr btn            = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//showing a page with its own button control&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//&amp;lt;Button Margin="200,200,200,200" Content="Button" x:Name="MyButton"/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    IXRDelegate&amp;lt;XRMouseButtonEventArgs&amp;gt;* clickdelegate = NULL;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    PageBtnEventHandler btnHandler;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Initialize Xaml Runtime&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (!XamlRuntimeInitialize())&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; -1;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Get XRAppInstance&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = GetXRApplicationInstance(&amp;amp;app);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;////An application should register an IXRResourceManager object for Silverlight&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;////before the application executes any functionality related to loading resources.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;////&amp;lt;Image Source=foo.jpg" /&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;////&amp;lt;TextBlock x:Name="GridTextBlock10" Grid.Row="1" Grid.Column="0" FontSize="14" FontFamily="castelar.ttf#Castellar" FontStyle='Italic'  Text='Hello'/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;// --&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;////IXRResourceManager* pResourceMgr;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//hr = app-&amp;gt;RegisterResourceManager(pResourceMgr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//This is needed when there are resources within the XAML of type XAML_RESOURCE&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//hr = app-&amp;gt;AddResourceModule(hInstance);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//CHR(hr);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XRWindowCreateParams wp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    ZeroMemory(&amp;amp;wp, &lt;SPAN style="COLOR: #0000ff"&gt;sizeof&lt;/SPAN&gt;(XRWindowCreateParams));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Style       = WS_OVERLAPPED | WS_SYSMENU;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.pTitle      = L&lt;SPAN style="COLOR: #006080"&gt;"SWE Testing"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Left        = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    wp.Top         = 0;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Retrieve resource associated to the PAGE.XAML file&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XRXamlSource xamlsrc;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    xamlsrc.SetResource(hInstance,TEXT(&lt;SPAN style="COLOR: #006080"&gt;"XAML"&lt;/SPAN&gt;), MAKEINTRESOURCE(IDR_XAML_PAGE));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Register control with application instance&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//This method added so that the control code can do init and call Register on the control&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//so that the control's class is tied to the XAML Runtime's namespace&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//and this is done in control's DLL code&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = MyControl::MyControlPreInitialize(hInstance);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Create host&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = app-&amp;gt;CreateHostFromXaml(&amp;amp;xamlsrc, &amp;amp;wp, &amp;amp;vhost);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//Get Root Element of the XAML&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = vhost-&amp;gt;GetRootElement(&amp;amp;root);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//MyButton is a control directly defined and used by the application&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//defined in PAGE.XAML, look at x.Name of the &amp;lt;Button&amp;gt; element&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//left here just to show a control example inside the same application&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = root-&amp;gt;FindName(TEXT(&lt;SPAN style="COLOR: #006080"&gt;"MyButton"&lt;/SPAN&gt;), &amp;amp;btn);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = CreateDelegate(&amp;amp;btnHandler,&amp;amp;PageBtnEventHandler::OnClick,&amp;amp;clickdelegate);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = btn-&amp;gt;AddClickEventHandler(clickdelegate);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//MyControl is the control exported by SilverlightControl DLL project&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//deriving from XRCustomUserControlImpl&amp;lt;MyControl&amp;gt;, it's an abstract class&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #008000"&gt;//i.e. can't be instantiated and needs to have STATIC functions only&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = MyControl::MyControlInitialize(root, TEXT(&lt;SPAN style="COLOR: #006080"&gt;"MyUserControl"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = MyControl::MyControlInitialize(root, TEXT(&lt;SPAN style="COLOR: #006080"&gt;"MyUserControl2"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    UINT exitcode;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    hr = vhost-&amp;gt;StartDialog(&amp;amp;exitcode);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    CHR(hr);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;Exit:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    RELEASE_OBJ(clickdelegate);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    XamlRuntimeUninitialize();&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #0000ff"&gt;int&lt;/SPAN&gt;)hr;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;}&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #008000"&gt;//Handler of a button included directly in the EXE&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;class&lt;/SPAN&gt; PageBtnEventHandler&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;{&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;public&lt;/SPAN&gt;:&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        HRESULT OnClick(IXRDependencyObject* source,XRMouseButtonEventArgs* args)&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        {&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;            MessageBox(NULL,TEXT(&lt;SPAN style="COLOR: #006080"&gt;"Click!"&lt;/SPAN&gt;),TEXT(&lt;SPAN style="COLOR: #006080"&gt;"Button"&lt;/SPAN&gt;),MB_OK);&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;            &lt;SPAN style="COLOR: #0000ff"&gt;return&lt;/SPAN&gt; S_OK;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        }&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;};&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Note how straightforward the XAML for the page (main application) is – quite intuitively, it just contains one line for each control:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;UserControl&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;x:Class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="SLForEmbedded.Page"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns:SLForEmbedded&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="clr-namespace:SLForEmbedded"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="640"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="480"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;  &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Grid&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="LayoutRoot"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Background&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="White"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Button&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="200,200,200,200"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Button"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="MyButton"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;SLForEmbedded:MyControl&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Left"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Top"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="MyUserControl"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;SLForEmbedded:MyControl&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Right"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Top"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="MyUserControl2"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;  &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;UserControl&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;The XAML for the control may be useless for this post, however for the sake of completeness:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;UserControl&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns:x&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns:d&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;xmlns:mc&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;mc:Ignorable&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="d"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #ff0000"&gt;x:Class&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="SLForEmbedded.MyControl"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Grid&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="LayoutRoot"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Button&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="25"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="125"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;HorizontalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Left"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;VerticalAlignment&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Top"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Margin&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="10,10,0,0"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;Content&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="Click User Control"&lt;/SPAN&gt; &lt;SPAN style="COLOR: #ff0000"&gt;x:Name&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;="btnUserControl"&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;/&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: #800000"&gt;UserControl&lt;/SPAN&gt;&lt;SPAN style="COLOR: #0000ff"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;As usual, macros were:&lt;/P&gt;
&lt;DIV style="BORDER-BOTTOM: silver 1px solid; TEXT-ALIGN: left; BORDER-LEFT: silver 1px solid; PADDING-BOTTOM: 4px; LINE-HEIGHT: 12pt; BACKGROUND-COLOR: #f4f4f4; MARGIN: 20px 0px 10px; PADDING-LEFT: 4px; WIDTH: 97.5%; PADDING-RIGHT: 4px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; FONT-SIZE: 8pt; OVERFLOW: auto; BORDER-TOP: silver 1px solid; CURSOR: text; BORDER-RIGHT: silver 1px solid; PADDING-TOP: 4px" id=codeSnippetWrapper&gt;
&lt;DIV style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px" id=codeSnippet&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#pragma&lt;/SPAN&gt; &lt;SPAN style="COLOR: #cc6633"&gt;once&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#ifndef&lt;/SPAN&gt; MACROS&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#define&lt;/SPAN&gt; MACROS&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#define&lt;/SPAN&gt; _ExitLabel Exit&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#define&lt;/SPAN&gt; _ExitCode exitCode&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#define&lt;/SPAN&gt; CHR(hResult) \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt;(S_OK != hResult) { hr = (hResult); &lt;SPAN style="COLOR: #0000ff"&gt;goto&lt;/SPAN&gt; _ExitLabel;} &lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#define&lt;/SPAN&gt; RELEASE_OBJ(s)  \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    &lt;SPAN style="COLOR: #0000ff"&gt;if&lt;/SPAN&gt; (NULL != s)      \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    {                   \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        s-&amp;gt;Release();   \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;        s = NULL;       \&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: white; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;    }&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;PRE style="BORDER-BOTTOM-STYLE: none; TEXT-ALIGN: left; PADDING-BOTTOM: 0px; LINE-HEIGHT: 12pt; BORDER-RIGHT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; PADDING-LEFT: 0px; WIDTH: 100%; PADDING-RIGHT: 0px; FONT-FAMILY: 'Courier New', courier, monospace; DIRECTION: ltr; BORDER-TOP-STYLE: none; COLOR: black; FONT-SIZE: 8pt; BORDER-LEFT-STYLE: none; OVERFLOW: visible; PADDING-TOP: 0px"&gt;&lt;SPAN style="COLOR: #cc6633"&gt;#endif&lt;/SPAN&gt;&lt;/PRE&gt;&lt;!--CRLF--&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this may help out developers learning SWE (like myself… &lt;IMG alt=Winking src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif" mce_src="http://us.i1.yimg.com/us.yimg.com/i/mesg/emoticons7/3.gif"&gt;)&lt;/P&gt;
&lt;P&gt;Cheers, &lt;BR&gt;~raffaele&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9959690" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+CE/">Windows CE</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Silverlight/">Silverlight</category></item><item><title>Windows Mobile: programmatically intercepting phone calls</title><link>http://blogs.msdn.com/b/raffael/archive/2010/02/01/windows-mobile-programmatically-intercepting-phone-calls.aspx</link><pubDate>Mon, 01 Feb 2010 15:51:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9956353</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9956353</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/02/01/windows-mobile-programmatically-intercepting-phone-calls.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;Supported??&lt;/font&gt;&lt;/strong&gt; Expectations about &lt;strong&gt;cprog.exe&lt;/strong&gt;&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;How Communicator Mobile works with “&lt;strong&gt;Work Phone calls&lt;/strong&gt;”&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Sample code to “extend” the State&amp;amp;Notification Broker for &lt;strong&gt;IGNORED phone calls&lt;/strong&gt;&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I recently worked with some ISVs asking support about this, then also answered to a MSDN Forum &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/305cb57a-93e0-4b7d-8b9e-479569a29fe4/#9cf64433-9e85-4d32-b0bc-7a5c42ed9627" target="_blank"&gt;thread&lt;/a&gt; about the same, so I’d say it may be worth to mention it here as well for Community reference. This happens to be one of those common questions that fall under the umbrella of the “not supported as OEM-dependent” or “not supported as it’s not meant to work that way”. I’ve talked about this some times on my blog, for example regarding &lt;a href="http://blogs.msdn.com/raffael/archive/2009/02/27/wireless-programming-on-windows-mobile-supported-or-not-supported.aspx" target="_blank"&gt;Wireless programming&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/raffael/archive/2008/02/27/support-boundaries-for-windows-mobile-programming-developing-drivers-for-example-or-even-wifi-programming.aspx" target="_blank"&gt;Drivers&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/raffael/archive/2008/03/01/supporting-kiosk-applications-on-windows-mobile-technically-achievable-vs-supported.aspx" target="_blank"&gt;Kiosk applications&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/raffael/archive/2008/05/12/setwindowshookex-on-windows-mobile.aspx" target="_blank"&gt;Hooks&lt;/a&gt;… &lt;/p&gt;  &lt;p&gt;The issue is about “intercepting” incoming phone calls and prevent the native UI dialog provided by OS application cprog.exe to take care of it: there are some OEMs that customized the user interface for this phone application, so ISVs may think this could be a common task to achieve? One could say: “Wouldn’t be sufficient to kill cprog.exe?”. Or, in any case, is there a way for ISV Application Developers to programmatically control incoming and outgoing calls *&lt;strong&gt;before&lt;/strong&gt;* or *&lt;strong&gt;instead&lt;/strong&gt;* the Operating System itself?&lt;/p&gt;  &lt;p&gt;The answer is no, but you may possibly find “creative” ways to achieve the same visual effect your application’s final users may look for. The main point is that &lt;u&gt;interfering with the OS Native Phone application (cprog.exe) is not supported for ISV Application Developers, contrarily to Device Manufacturers&lt;/u&gt; (OEMs) who actually build their own OS based on the Windows Mobile platform and therefore can develop and include whatever they want on their Operating Systems, as long as they fulfill the “Windows Mobile Logo Test Kit” (so that their OS is certified as “Windows Mobile”). &lt;/p&gt;  &lt;p&gt;As an example, a thing that the Windows Mobile platform doesn’t test or even consider is killing cprog.exe, which is the process underlying the Phone UI Application. Once the device is booted, cprog.exe executes and even when there is a Out-Of-Memory condition (so that the Shell starts asking every application to shut down, accordingly to this old &lt;a href="http://blogs.msdn.com/windowsmobile/archive/2006/08/16/702746.aspx" target="_blank"&gt;post&lt;/a&gt; from WinMo Dev Team), cprog.exe is not terminated. So the current OS design does not expect it to be killed forcefully. &lt;/p&gt;  &lt;p&gt;In some cases, to meet this requirement you would need to cooperate with the Device OEM\OEMs so that he\they can sponsor you as their “&lt;em&gt;Windows Mobile In-ROM ISV&lt;/em&gt;”. By doing so, you would have access to all the tools a Device Manufacturer has, including the knowledge on the RIL Driver (Radio Interface Layer), developed by the OEM, that is responsible to handle every radio-related communication of the device (phone call, GPRS data session, …). So, to intercept phone calls before cprog.exe does it, you should do it at RIL Driver level, and Microsoft has no idea about how the OEM implemented it. &lt;/p&gt;  &lt;p&gt;In other cases, you can let cprog.exe do its work, and play with Windows APIs to hide its window and take control of the phone call via TAPI (Telephony API): that is the “supported” way.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;You may ask: then how does &lt;strong&gt;Microsoft’s Communicator Mobile 2007 R2 &lt;/strong&gt;implement &amp;quot;&lt;strong&gt;Work Phone calls&lt;/strong&gt;”? How can it intercept phone calls, if this is OEM-dependent? Well, actually it doesn’t. CoMo is not working with the RIL to intercept phone-voice calls. Documentation is available through the following &lt;a href="http://download.microsoft.com/download/6/B/C/6BC8CDA8-9035-43AC-AFB8-B5B7DC550949/OCS%202007%20R2%20Technical%20Reference.doc" target="_blank"&gt;Microsoft Office Communications Server 2007 R2 – Technical Reference&lt;/a&gt; (section “&lt;em&gt;Outside Voice Control&lt;/em&gt;”):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;[…] For inbound calls, Office Communications Server 2007 R2 sends a SIP Invite to all registered SIP endpoints of the user including the user’s Communicator Mobile (2007 R2 release) client running on the phone, over the data channel.&amp;#160;&amp;#160; Office Communications Server 2007 R2 subsequently initiates an outbound PSTN/mobile network call through Office Communications Server 2007 R2 Mediation Server to the user’s mobile phone number.&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So as you can see, when dealing with “Communicator phone-calls” we’re not precisely working with “Voice-Phone calls”: it’s about SIP requests sent over the Data Channel, not the Voice-one.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Among the “supported” ways to deal with phone calls, developers can rely on the State&amp;amp;Notification Broker states like PhoneCallTalking and PhoneIncomingCall: a state that may be missing is about the &lt;strong&gt;last call being ignored&lt;/strong&gt;. Here it is a managed sample code showing a possible way to achieve this (to be tested… as usual! &lt;img alt="Smile" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/regular_smile.gif" /&gt;):&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; Form1()&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    InitializeComponent();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _PhoneIncomingCall.Changed += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ChangeEventHandler(_PhoneIncomingCall_Changed);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; bTalking = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; bIncoming = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; bIgnoring = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;SystemState _PhoneCallTalking = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SystemState(SystemProperty.PhoneCallTalking);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;SystemState _PhoneIncomingCall = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; SystemState(SystemProperty.PhoneIncomingCall);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; _PhoneCallTalking_Changed(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, ChangeEventArgs args)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    bTalking = (0 != (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)args.NewValue);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #008000"&gt;//_PhoneIncomingCall.Changed += new ChangeEventHandler(_PhoneIncomingCall_Changed);&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    _PhoneCallTalking.Changed -= _PhoneCallTalking_Changed;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;void&lt;/span&gt; _PhoneIncomingCall_Changed(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, ChangeEventArgs args)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    bIncoming = (0 != (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)args.NewValue);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (bIncoming)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//_PhoneIncomingCall.Changed -= _PhoneIncomingCall_Changed;&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        _PhoneCallTalking.Changed += &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ChangeEventHandler(_PhoneCallTalking_Changed);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//answered: bTalking = true&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//ignored: bTalking = false&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        bIgnoring = !bTalking;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        MessageBox.Show(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #006080"&gt;&amp;quot;IgnoredCall: {0}&amp;quot;&lt;/span&gt;, bIgnoring.ToString()));&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #008000"&gt;//reset vars&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        bIncoming = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        bIgnoring = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        bTalking = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9956353" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Phone/">Phone</category></item><item><title>Windows Mobile 6 SDK TEST-ONLY Certificates: new CAB and XML Provisioning</title><link>http://blogs.msdn.com/b/raffael/archive/2010/01/15/windows-mobile-6-sdk-test-only-certificates-new-cab-and-xml-provisioning.aspx</link><pubDate>Fri, 15 Jan 2010 15:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9948986</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9948986</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/01/15/windows-mobile-6-sdk-test-only-certificates-new-cab-and-xml-provisioning.aspx#comments</comments><description>&lt;p&gt;SDK Test Certificates expired last December 31 and the Product Group &lt;a href="http://windowsteamblog.com/blogs/wmdev/archive/2010/01/12/new-windows-mobile-developer-certificates.aspx" target="_blank"&gt;provided a new set of Test Certificates&lt;/a&gt; (and accordingly to mainly &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/0b611f03-0587-411d-afcc-f1113f31023a" target="_blank"&gt;this MSDN Forum thread&lt;/a&gt; many ISVs had found alternatives in the meantime). The aim of this post if to provide an addendum to that notification, specifically related to the following sentence: “[…] &lt;em&gt;If you’re a tester, you can follow these &lt;/em&gt;&lt;a href="http://technet.microsoft.com/en-us/library/cc182301.aspx"&gt;&lt;em&gt;instructions&lt;/em&gt;&lt;/a&gt;&lt;em&gt; to create a provisioning file for a device, so that you don’t need Visual Studio to push certificates onto test platforms.&lt;/em&gt;”. In other words, the certificates you can download from &lt;a href="http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/wmdev/WM65Certs.zip" target="_blank"&gt;here&lt;/a&gt; don’t contain a Certs.XML and a Certs.CAB files, contrarily to a standard installation of Windows Mobile 6 SDKs. I have simply created them by using the known technique and made them available through this post (click &lt;a href="http://blogs.msdn.com/raffael/attachment/9948986.ashx" target="_blank"&gt;here&lt;/a&gt; to download the zip), hoping they may help “testers” saving time in case “developers” use the new certs. Note that they can also cohexist with expired certificates on a test device\emulator. &lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9948986" width="1" height="1"&gt;</description><enclosure url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-09-94-89-86/NewCerts.zip" length="9743" type="application/x-zip-compressed" /><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/SDK+Certificates/">SDK Certificates</category></item><item><title>Get help now! A Vademecum about requesting Technical Support from Microsoft</title><link>http://blogs.msdn.com/b/raffael/archive/2010/01/11/get-help-now-a-vademecum-about-requesting-technical-support-from-microsoft.aspx</link><pubDate>Mon, 11 Jan 2010 15:33:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9946555</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9946555</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2010/01/11/get-help-now-a-vademecum-about-requesting-technical-support-from-microsoft.aspx#comments</comments><description>&lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://support.microsoft.com/gethelp/default.aspx?content=ph;en-us;12913"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" alt="" align="left" src="http://support.microsoft.com/library/images/support/en-US/Help_support_55.gif" width="45" height="45" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h6&gt;&lt;font size="4"&gt;&amp;#160; Get Help Now&lt;/font&gt;&lt;/h6&gt;  &lt;h6&gt;&lt;font size="4"&gt;&amp;#160; &lt;/font&gt;&lt;a href="http://support.microsoft.com/gethelp/default.aspx?content=ph;en-us;12913"&gt;&lt;font color="#ff0000" size="4"&gt;&lt;u&gt;Contact a Support Professional by E-mail, Online, or Phone&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/h6&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I often receive questions related to how to open Service Requests at &lt;strong&gt;Microsoft Customer Care &amp;amp; Technical Support&lt;/strong&gt;, the last of which was in &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/8790a194-0db8-446c-963c-9693bc99b232" target="_blank"&gt;this MSDN Forum thread&lt;/a&gt; regarding the NETCF v3.5’s FIX about the WebBrowser control (which I’ve discussed about &lt;a href="http://blogs.msdn.com/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx" target="_blank"&gt;here&lt;/a&gt;). So I’d say it could be a good investment to describe in detail how you can ask to be contacted by a Support Professional: I’ve already done it &lt;a href="http://blogs.msdn.com/raffael/archive/2008/05/14/get-what-you-paid-for.aspx" target="_blank"&gt;once&lt;/a&gt; some time ago (wow, that was nearly 2 years ago!), but the following is a kind of updated process..&lt;/p&gt;  &lt;p&gt;Well, above all: are you using Visual Studio 2008 and need support? As a starting point, apart from MSDN Forums, have you ever clicked on Visual Studio’s menu &lt;strong&gt;Help\Technical Support&lt;/strong&gt;? &lt;img alt="Open-mouthed" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/teeth_smile.gif" /&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled" border="0" alt="Untitled" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled_thumb.jpg" width="634" height="458" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;That leads to a documentation page containing details and .doc files relevant to Developers\IT Professionals\Value Add Partners, Resellers, Consultants\Microsoft Certified Partners\OEMs. The same page contains (800)-* phone numbers to open a Service Request in the US:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled2_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled2" border="0" alt="Untitled2" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled2_thumb.jpg" width="597" height="266" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;And to know international phone numbers you can use to open Service Requests at &lt;strong&gt;Microsoft Customer Care &amp;amp; Technical Support &lt;/strong&gt;over the phone, you can start from the &lt;a href="http://support.microsoft.com/common/international.aspx" target="_blank"&gt;International Support&lt;/a&gt; page.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;However, opening the Service Request over the phone is not the only option: you can do it also online. For example, let’s assume you have a copy of Visual Studio 2008 Professional Edition and you need help regarding a Smart Device application, which falls precisely under my area of specialty... Well, you can start from the &lt;a href="http://support.microsoft.com/ph/12913/en-us/" target="_blank"&gt;Visual Studio 2008 Solution Center&lt;/a&gt;, which also contains useful info to address the issue on your own, and apart from that contains a link to:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://support.microsoft.com/gethelp/default.aspx?content=ph;en-us;12913"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" border="0" alt="" align="left" src="http://support.microsoft.com/library/images/support/en-US/Help_support_55.gif" width="45" height="45" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;h6&gt;&lt;font size="4"&gt;&amp;#160; Get Help Now&lt;/font&gt;&lt;/h6&gt;  &lt;h6&gt;&lt;font size="4"&gt;&amp;#160; &lt;/font&gt;&lt;a href="http://support.microsoft.com/gethelp/default.aspx?content=ph;en-us;12913"&gt;&lt;font color="#ff0000" size="4"&gt;&lt;u&gt;Contact a Support Professional by E-mail, Online, or Phone&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/h6&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;That links to the same page as &lt;a href="http://support.microsoft.com/select/Default.aspx?target=assistance" target="_blank"&gt;&lt;strong&gt;Assisted Support Options&lt;/strong&gt;&lt;/a&gt;, which lets you begin a step-by-step procedure to gather details of your eligibility of support, along with details about the product and the problem. Here it comes.. remember that developers programming Smart Device application don’t ask for support about the products “&lt;strong&gt;Windows Mobile&lt;/strong&gt;” or “&lt;strong&gt;Windows CE&lt;/strong&gt;”: they’re asking for support about the product “&lt;strong&gt;Visual Studio&lt;/strong&gt;”!&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;1- &lt;/strong&gt;Quick product finder:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled3_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled3" border="0" alt="Untitled3" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled3_thumb.jpg" width="362" height="155" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;2- &lt;/strong&gt;Select a product:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled4_4.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled4" border="0" alt="Untitled4" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled4_thumb_1.jpg" width="708" height="239" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;3- &lt;/strong&gt;Select a support topic:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled5_4.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled5" border="0" alt="Untitled5" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled5_thumb_1.jpg" width="709" height="394" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;   &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;4- &lt;/strong&gt;Provide product ID:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled6_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Untitled6" border="0" alt="Untitled6" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/GetHelpnow_9A9B/Untitled6_thumb.jpg" width="710" height="333" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Note the words “&lt;strong&gt;NO-CHARGE SUPPORT&lt;/strong&gt;”: they’re what I meant “what you’ve already paid” in my post &lt;a href="http://blogs.msdn.com/raffael/archive/2008/05/14/get-what-you-paid-for.aspx" target="_blank"&gt;get what you paid for!!&lt;/a&gt; The Product ID for Developer Tools can be retrived by:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Start the program. &lt;/li&gt;    &lt;li&gt;On the menu bar, click &lt;strong&gt;Help&lt;/strong&gt;, and then click &lt;strong&gt;About Microsoft &lt;em&gt;product name&lt;/em&gt;&lt;/strong&gt;. &lt;/li&gt;    &lt;li&gt;The Product ID (PID) is under &lt;strong&gt;This product is licensed to&lt;/strong&gt;. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Or you can let Microsoft locate the Product ID by allowing the control to run through Internet Explorer. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;5- &lt;/strong&gt;At this point, if you have an “&lt;strong&gt;ACCESS ID&lt;/strong&gt;” related to a Technical Support contract (MSDN Subscription, Partner, Premier, Professional 5-Pack, etc), here it’s the right time to use it. If you don’t have it, then you can click on “Skip this” button and reach a page that would allow you to pay to open a so-called “Pay Per Incident”. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;6- &lt;/strong&gt;Eventually you’ll reach a page containing fields you can fill in order to describe the issue, to set the severity and to submit the request.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hope this will help ISVs out there on correctly opening Service Requests!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Cheers,    &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9946555" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category></item><item><title>Basics on Windows CE\Mobile: an alternative way to approach the Memory Monster</title><link>http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx</link><pubDate>Mon, 16 Nov 2009 16:27:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923003</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9923003</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/11/16/basics-on-windows-ce-mobile-an-alternative-way-to-approach-the-memory-monster.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;Introduction on Windows CE\Mobile&lt;/em&gt;&amp;#160;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;Virtual Memory on Windows CE 5.0\Mobile (a visual approach)&lt;/em&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Troubleshooting Memory Leaks for NETCF applications&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Lately I’ve been involved on starting up my team blog: if you read Italian and want to listen about stories from Support Engineers working on various technologies, you can’t avoid signing up to the feed: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/itasupport" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="itasupport" border="0" alt="itasupport" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/aaa_CC57/itasupport_1.png" width="567" height="72" /&gt;&lt;/a&gt; &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Now guess what’s been the topic of the posts I’ve been writing there… &lt;img alt="Open-mouthed" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/teeth_smile.gif" /&gt; yes! &lt;strong&gt;Memory Management on Windows CE\Mobile and NETCF!!&lt;/strong&gt; (so far the &lt;a href="http://blogs.msdn.com/itasupport/archive/2009/09/16/gestione-della-memoria-nella-net-compact-framework-e-in-windows-mobile-introduzione.aspx" target="_blank"&gt;intro&lt;/a&gt; and then part &lt;a href="http://blogs.msdn.com/itasupport/archive/2009/09/17/gestione-della-memoria-nella-net-compact-framework-e-windows-mobile-parte-0-windows-ce-e-windows-mobile.aspx" target="_blank"&gt;0&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/itasupport/archive/2009/10/12/ready-gestione-della-memoria-nella-net-compact-framework-e-in-windows-mobile-parte-1-memoria-virtuale-su-windows-ce.aspx" target="_blank"&gt;1&lt;/a&gt;, &lt;a href="http://blogs.msdn.com/itasupport/archive/2009/11/09/ready-gestione-della-memoria-nella-net-compact-framework-e-in-windows-mobile-parte-2-troubleshooting-di-memory-leak.aspx" target="_blank"&gt;2&lt;/a&gt; – don’t ask me why I made it 0-based, even after an intro… I really don’t remember) And since I’ve been adopting an approach that is not usually the one used to explain how things work, I honestly think I can reuse the same one and translate it here… probably I’m going to repeat some concepts I’ve already blogged about, however it may be worth in order to have one single document, this post, as hopefully a possible quite-ultimate way to describe how memory is handled… is the bar too high??&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;INTRODUCTION ABOUT WINDOWS CE\MOBILE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So, let’s start: Windows CE and Windows Mobile are not the same thing. After working on this for a while it can be obviuos, but if you’re at your first experience with these so-called “Smart Devices” then it may not be so. We must be clear about the terminology, specifically about terms like “platform”, “operating system”, “Platform Builder”, “Adaptation Kit”, “OEM”, “ODM”, etc.. In reality the true name of “Windows CE” would nowadays be “&lt;strong&gt;Windows Embedded CE&lt;/strong&gt;”, however I don’t want to mess with a product that was once known as “Windows XP Embedded” and which nowadays is differentiated in the following products:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;“Windows Embedded Stardard” &lt;/li&gt;    &lt;li&gt;“Windows Embedded Enterprise” &lt;/li&gt;    &lt;li&gt;“Windows Embedded POSReady” &lt;/li&gt;    &lt;li&gt;“Windows Embedded NavReady” &lt;/li&gt;    &lt;li&gt;“Windows Embedded Server” &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So, when I’ll write “Windows CE” here I’ll mean the historical name of “Windows Embedded CE”: let’s forget the other “Windows Embedded X” products (out of my scope) and let’s concentrate on Windows CE\Mobile.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Windows CE is a platform for OEMs &lt;/strong&gt;(Original Equipment Manufacturer)&lt;strong&gt;.&lt;/strong&gt; This means that we provide to the manufacturer an Integrated Development Environment very similar to Visual Studio (indeed, Windows CE 6.0 is integrated with Visual Studio), but with the aim of developing Operating Systems (instead of applications), based on the platform provided by Microsoft. The tool is called &amp;quot;&lt;em&gt;Platform Builder for Windows CE&lt;/em&gt;”, and up to version 5.0 was a separate tool from Visual Studio. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Windows CE is a modular platform.&lt;/strong&gt; This means that the OEM is totally free to include only the modules, drivers and applications of his interest. Microsoft provides about 90% of the source code of the Windows CE platform, as well as code examples for drivers and various recommendations (which the OEM might or might not follow). For example, if the device is not equipped with an audio output, then the OEM won’t add a sound driver. If it doesn’t have a display, then the OEM will not develop nor insert a video driver. And so on for the network connectivity, or a barcode-scanner, a camera, and so on. &lt;em&gt;&lt;u&gt;On a Windows CE-based device, the OEM can include whatever he wants&lt;/u&gt;.&lt;/em&gt; That's why, from the point of view of technical support to application-developers, sometimes we can’t help a programmer who is targeting a specific device whose operating system is based on Windows CE: furthermore, the OEM can decide whether to offer application-developers the opportunity to programmatically interact with special functions of the device through a so-called &amp;quot;Private SDK” (which may also contain a emulator image, for example). &lt;/p&gt;  &lt;p&gt;An important detail: differently from Windows Embedded OSs (Standard \ Enterprise \ POSReady \ NavReady \ Server), for Operating Systems based on Windows CE the OEMs actually *&lt;strong&gt;COMPILE&lt;/strong&gt;* the source code of the platform (apart from about 10% provided by Microsoft and corresponding to the core kernel and other features).&lt;/p&gt;  &lt;p&gt;Now: &lt;strong&gt;Windows Mobile is a particular customization of Windows CE&lt;/strong&gt;, but in this case the OEM needs to create an Operating System that meets a set of requirements, called &amp;quot;&lt;em&gt;Windows Mobile Logo Test Kit&lt;/em&gt;&amp;quot;. The tool used by Windows Mobile-OEM is called &amp;quot;&lt;em&gt;Adaptation Kit for Windows Mobile&lt;/em&gt;&amp;quot;, a special edition of &amp;quot;Platform Builder&amp;quot; and allows to adapt the &amp;quot;Windows Mobile”-Platform to the exact hardware that the OEM has built or that he requested to an ODM (“Original Device Manufacturer”). In the Windows Mobile’s scenario we can’t forget Mobile Operators also, which often &amp;quot;brand&amp;quot; a device requiring the OEM to include specific applications and usually configure the connectivity of the mobile network (GPRS, UMTS, WAP, etc.).. WARNING: nothing prohibits a WinMo-OEM to include special features such as a barcode-scanner or an RFID chip or anything else... the important thing is that the minimal set is the same. Moreover, also WinMo-OEM can provide a “Private SDK” to programmatically expose specific functionality related to their operating system (see for example Samsung SDK containing private APIs for the accelerometer and other features, which are documented and supported by Samsung itself). &lt;/p&gt;  &lt;p&gt;Finally, one last thing before starting talking about memory: Windows Mobile 5.0, 6, 6.1 and 6.5 are all platforms based on Windows CE 5.0. So, they all share the same Virtual Memory management mechanisms, except in some details for the latter (mainly with some benefits for application-developers).&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;VIRTUAL MEMORY ON WINDOWS CE\MOBILE&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;So now we can start talking about how memory is managed on Operating Systems based on Windows CE 5.0. And I’m being specific on Windows Embedded CE *&lt;strong&gt;5.0&lt;/strong&gt;* because on 6.0 memory management is (finally!) totally changed and there are no more the limitations we’re going to discuss in the remainder. Incidentally, this is part of the same limitations described for Windows CE 4.2 by Doug Boling’s &lt;a href="http://msdn.microsoft.com/en-us/library/ms836325.aspx"&gt;&lt;b&gt;Windows CE .NET Advanced Memory Management&lt;/b&gt;&lt;/a&gt;, although the article is dated 2002! Fortunately, some improvements have been introduced from Windows Mobile 6 and especially in 6.1 (and therefore also in 6.5), whereby not only the applications have more virtual memory available, but also the entire operating system is more stable as a whole. &lt;/p&gt;  &lt;p&gt;I don’t want to repeat here what can be found in documentation and on various blogs: in contrast, I’d like to actually &lt;strong&gt;show the theory&lt;/strong&gt;, because only by looking at data like the following you can realize what a good programmer a Developer for Windows Mobile has to be! &lt;img alt="Hot" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/shades_smile.gif" /&gt; The following is the output of a tool developed by Symbol (later acquired by Motorola), which allowed the manufacturer to understand how the device.exe process was responsible (or not) for various problems related to memory. Why? Because &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;device.exe is the process that loads the DLL for the driver in its own address space; &lt;/li&gt;    &lt;li&gt;if it hasn’t yet been loaded by other processes, a DLL will occupy a portion of the virtual memory below the &amp;quot;DLL Load Point&amp;quot;; &lt;/li&gt;    &lt;li&gt;each DLL may have dependencies, also to be loaded; &lt;/li&gt;    &lt;li&gt;each DLL can create its own heap to store data. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The result was something like the following (I obfuscated possibly sensitive data of the software-house I worked with during the Service Request):&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory_4.jpg"&gt;&lt;img title="memory" border="0" alt="memory" src="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory_thumb_1.jpg" width="677" height="413" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory_4.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So, above all, what did Symbol\Motorola mean by “Code” (blue) and “Data” (green)?&lt;/p&gt;  &lt;p&gt;• &amp;quot;Code&amp;quot;: these are the *&lt;b&gt;RAM&lt;/b&gt;* DLLs loaded or mapped into a process-slot. They start from the top of the 32MB slot and goes down. If several processes use the same DLL, the second one maps it to the same address where the first one had loaded it.     &lt;br /&gt;• &amp;quot;Data&amp;quot; is the &lt;b&gt;executable’s compiled code + Heap(s) + Stack&lt;/b&gt;. It starts from the bottom and grows.&lt;/p&gt;  &lt;p&gt;Finally, the red vertical line represents the &amp;quot;&lt;b&gt;DLL Load Point&lt;/b&gt;&amp;quot;, i.e. the address where a DLL is loaded in case it hadn’t yet by any other process.&lt;/p&gt;  &lt;p&gt;That is the situation of only the process slots, not the whole virtual memory - in particular the contents of the Large Memory Area is not shown:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/clip_image003_2.jpg"&gt;&lt;img title="clip_image003" border="0" alt="clip_image003" src="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/clip_image003_thumb.jpg" width="342" height="258" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/clip_image003_2.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Why did I specify *&lt;strong&gt;RAM&lt;/strong&gt;* DLLs? Because those placed by the OEM in the ROM (= firmware) are executed directly there, without the need of the process loading their &amp;quot;compiled&amp;quot; code into its Address Space (they’re XIP DLL, i.e. &amp;quot;Executed in Place&amp;quot; – in Slot 1). &lt;/p&gt;  &lt;p&gt;That picture also shows that the green part &lt;strong&gt;(code + heap + stack) may exceed the DLL Load Point&lt;/strong&gt;. Indeed, the problems related to lack of available virtual memory is usually of 2 types: &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;a process tries to load a DLL that hadn’t been loaded by any other before, trying to move the DLL Load Point in an area already occupied by code + heap + stack &lt;/li&gt;    &lt;li&gt;a process tries to allocate memory (code + heap + stack) but the process slot has got saturated even on sections left free among loaded DLLs &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;That's also because in general one of the advices to avoid memory problems had always been to load all DLLs used by the application itself at application startup, through an explicit call to &lt;i&gt;LoadLibrary()&lt;/i&gt;. Another visual example is the following:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory2_2.jpg"&gt;&lt;img title="memory2" border="0" alt="memory2" src="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory2_thumb.jpg" width="782" height="59" /&gt;&lt;/a&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/itasupport/WindowsLiveWriter/Ges.NETCompactFrameworkeWindowsMobilePar_B110/memory2_2.jpg"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;We’ll later discuss in detail the particularities of NETCF, but it's worth at this point noting a detail: apart from the actual CLR DLLs (mscoree*.dll, netcfagl*.dll), &lt;strong&gt;every other assembly&lt;/strong&gt; doesn’t waste address space in the Process slot, but &lt;strong&gt;is loaded into the Large Memory Area&lt;/strong&gt;. Even more, if you are using the version of the runtime included in the ROM by the OEM, also the runtime DLLs do not affect the process’ virtual memory space. Obviously it is different when the application P/Invoke native DLLs: these will be loaded in the process slot. &lt;/p&gt;  &lt;p&gt;Moreover, if you look at the picture showing all the alive processes, you’ll notice that in the upper bound of all the slots there’s a portion of &amp;quot;blue&amp;quot; virtual memory, which is the same for all the processes. This is the &lt;strong&gt;memory blocked by the Operating System whose size is equal to the sum of the binaries&lt;/strong&gt; (the simple .EXE files) active at any given moment. So large monolithic EXEs (large for example because containing “many” resources) are not recommended at all on Windows CE 5.0! And in general supporting NETCF developers I can say I’ve seen many “big” applications... that is not a good practice for this reason!&lt;/p&gt;  &lt;p&gt;Through those pictures it is also easy to understand why &lt;strong&gt;the whole system stability is a function of all active processes&lt;/strong&gt;, and in particular it is easy to see that very often &lt;strong&gt;DEVICE.EXE can be a source of headaches&lt;/strong&gt;! Think of those Windows Mobile-based devices that have the radio stack (i.e. the phone), Bluetooth, WiFi, Camera, barcode-scanner, etc. .. each of these drivers is a DLL that device.exe has to load (blue line), and each can also create its own stack and heap (green line). Some OEMs allowed developers to programmatically disable some drivers (to reduce pressure done by device.exe), but obviously we can not take for granted for example that a user manually restarts that feature (or this is done by another application...). &lt;/p&gt;  &lt;p&gt;So, what has been done to fight device.exe’s power? In many cases, the driver-DLLs were loaded by services.exe, which is the host process for Service-DLLs on Windows CE. But very often it was not enough... &lt;strong&gt;What Windows Mobile 6.1 introduced is that native DLLs with size &amp;gt; 64KB are typically loaded into the so-called slots 60 and 61&lt;/strong&gt;, which are part of the Large Memory Area. Another improvement in Windows Mobile 6.1 was to dedicate another slot &lt;strong&gt;(slot 59) to the driver stack&lt;/strong&gt; (part of the Green Line to device.exe). Of course, this means that the memory-mapped files have now less space available (and I have recently handled a request for exactly this purpose, coming by a software company that was developing a GPS navigation software that could not load some map files in WinMo6.1), but in general the whole operating system has gained a stability that hadn’t before...&lt;/p&gt;  &lt;p&gt;To conclude, the tool I mentioned was developed by Symbol and I don’t think it’s publicly available. But a similar tool has recently been published on CodePlex (source code included!) through the article &lt;a href="http://www.codeproject.com/KB/mobile/VirtualMemory.aspx"&gt;&lt;strong&gt;Visualizing the Windows Mobile Virtual Memory Monster&lt;/strong&gt;&lt;/a&gt;. The term &amp;quot;&lt;em&gt;Virtual Memory Monster&lt;/em&gt;&amp;quot; was invented years ago by Reed Robison… (&lt;a href="http://blogs.msdn.com/hegenderfer/archive/2007/08/31/slaying-the-virtual-memory-monster.aspx"&gt;part 1&lt;/a&gt; e &lt;a href="http://blogs.msdn.com/hegenderfer/archive/2007/10/01/slaying-the-virtual-memory-monster-part-ii.aspx"&gt;part 2&lt;/a&gt;). I've already been using it in a couple of requests and highly recommend it!&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;TROUBLESHOOTING MEMORY LEAKS FOR NETCF APPLICATIONS&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Instead of explaining how things work in theory, which is a task I leave to more authoritative sources like the documentation itself and various blogs – one for all that of Abhinaba Basu, who is precisely the GC Guru inside the NETCF Dev Team (&lt;a href="http://blogs.msdn.com/abhinaba/archive/2009/01/25/back-to-basic-series-on-dynamic-memory-management.aspx"&gt;Back to basic: Series on dynamic memory management&lt;/a&gt;), I’d like to follow the troubleshooting flow I run through when a new Service Request arrives, about for example the following issues:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;OutOfMemoryException &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;SqlCeException: “Not enough memory to complete this operation” &lt;/em&gt;&lt;/li&gt;    &lt;li&gt;&lt;em&gt;The application can’t load a DLL&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Other misbehaviors that may lead thinking about a problem with the memory&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Firstly, we must determine &lt;strong&gt;whether the problem is specific to an OEM&lt;/strong&gt;. The best approach, when possible, is to verify if the error occurs even on emulators contained in the various Windows Mobile SDK. If not, the help that Microsoft Technical Support can provide is limited, as it is possible that the error is due to a customization of the Windows Mobile platform by the OEM. In this case, it may be helpful to know about what I wrote about device.exe above.&lt;/p&gt;  &lt;p&gt;Another initial step, in the case of applications NETCF v2 SP2, is to check if &lt;strong&gt;just running the application on NETCF v3.5&lt;/strong&gt; gives any improvement. There is no need to recompile the application with the Visual Studio 2008 - just like for .NET Desktop applications, add a configuration XML file in the same folder that contains the file TheApplication.exe, named TheApplication.exe.config and whose content is simply (I mentioned &lt;a href="http://blogs.msdn.com/raffael/archive/2008/04/22/weird-issue-with-netcf-v2-sp2-test-0ut-v3-5-then.aspx" target="_blank"&gt;here&lt;/a&gt;):&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;&amp;lt;configuration&amp;gt;
  &amp;lt;startup&amp;gt;
    &amp;lt;supportedRuntime version=&lt;span class="str"&gt;&amp;quot;v3.5.*&amp;quot;&lt;/span&gt;/&amp;gt;
  &amp;lt;/startup&amp;gt;
&amp;lt;/configuration&amp;gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;So, after having considered possible “trivial” causes, you can proceed to the analysis... Historically NETCF developers haven’t had an easy time in troubleshooting due to lack of appropriate tools – unlike Desktop cousins! – but over the years Microsoft has released tools that have gradually evolved over the current &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=c8174c14-a27d-4148-bf01-86c2e0953eab"&gt;&lt;strong&gt;Power Toys for .NET Compact Framework 3.5&lt;/strong&gt;&lt;/a&gt;. Apart from these you must know the(freeware!) EQATEC’s ones (&lt;a href="http://www.eqatec.com/tools/tracer"&gt;&lt;strong&gt;Tracer&lt;/strong&gt;&lt;/a&gt; and &lt;a href="http://www.eqatec.com/tools/profiler"&gt;&lt;strong&gt;Profiler&lt;/strong&gt;&lt;/a&gt;) and recently a tool on CodeProject that I mentioned earlier, that displays the status of virtual memory (&lt;a href="http://www.codeproject.com/KB/mobile/VirtualMemory.aspx"&gt;VirtualMemory&lt;/a&gt;, with source code). &lt;/p&gt;

&lt;p&gt;Regarding power-toys, when you are dealing with a problem around memory, you have 2 of them that are of great help: the &amp;quot;&lt;strong&gt;CLR Profiler&lt;/strong&gt;&amp;quot; and &amp;quot;&lt;strong&gt;Remote Performance Monitor (RPM)&lt;/strong&gt;”. The first one is useful in visually making problems with objects’ allocation almost immediate and allows you to notice the problem in a visual way. Info on how using it are available through &lt;em&gt;&lt;a href="http://blogs.msdn.com/stevenpr/archive/2008/05/08/the-clr-profiler-for-the-net-compact-framework-series-index.aspx"&gt;The CLR Profiler for the .Net Compact Framework Series Index&lt;/a&gt;. &lt;/em&gt;The second one provides, both in real time and through an analysis a posteriori, counters about the usage of MANAGED memory; also, through the &amp;quot;GC Heap Viewer” it allows not only to study the exact content of the managed heap, but also allows you to compare contents of the heap in different moments, in order to bring out a possible unexpected growth of a certain type of objects. Some images are available on &lt;a href="http://blogs.msdn.com/stevenpr/archive/2007/03/08/finding-managed-memory-leaks-using-the-net-cf-remote-performance-monitor.aspx"&gt;&lt;em&gt;Finding Managed Memory leaks using the .Net CF Remote Performance Monitor&lt;/em&gt;&lt;/a&gt;, which is useful also to get an idea about which counters are available, while a list and related explanations are provided on &lt;em&gt;&lt;a href="http://blogs.msdn.com/davidklinems/archive/2005/12/09/502125.aspx"&gt;Monitoring Application Performance on the .NET Compact Framework - Table of Contents and Index&lt;/a&gt;&lt;/em&gt;. What I'd like to do here is not to repeat the same explanations, already detailed in the links above, but share some practical experience... &lt;/p&gt;

&lt;p&gt;For example, in the vast majority of cases I have handled about memory leaks, the problem was due to &lt;strong&gt;Forms (or Controls) that unexpectedly were NOT removed by the Garbage Collector&lt;/strong&gt;. The instances of the Form class of the application are therefore the first thing to check through the Remote Performance Monitor and GC Heap Viewer. For this reason, where appropriate (e.g. if the total form are &amp;quot;not so many&amp;quot;), to avoid memory problems with NETCF applications it may be useful to adopt the so-called &amp;quot;Singleton Pattern&amp;quot;: this way a single managed instance of a given form will exist throughout the application life cycle. &lt;/p&gt;

&lt;p&gt;So, supposing to be in the following situation: I used the Remote Performance Monitor and saved different .GCLOG files during normal use of the application, and thanks to the GC Heap Viewer I noticed that an unexpected number of forms stays in memory, and also that this increases during the life of the application, although there have been a certain number of Garbage Collections. &lt;strong&gt;Why the memory of a Form is not cleaned up by the garbage collector?&lt;/strong&gt; Thanks to the GC Heap Viewer you can know exactly who maintains a reference to what, in the &amp;quot;Root View&amp;quot; on the right pane. Obviously knowing application’s architecture will help in identifying unexpected roots. &lt;/p&gt;

&lt;p&gt;A special consideration must be done for &lt;strong&gt;&lt;font color="#ff0000"&gt;MODAL Forms in .NET&lt;/font&gt; &lt;/strong&gt;(the dialogs, those that on Windows Mobile have the close button &amp;quot;Ok&amp;quot; instead of &amp;quot;X&amp;quot;, and which permits a developer to prevent the user to return to the previous form). In many cases I have handled, the problem was simply due to the fact that the code was not invoking Close() (or. Dispose ()) after .ShowDialog():&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;Form2 f2 = &lt;span class="kwrd"&gt;new&lt;/span&gt; Form2();
f2.ShowDialog();
f2.Close();&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Why should it matter? Because often (not always, for example, not when you expect a DialogResult) on Windows Mobile the user clicks on 'Ok' in the top right &amp;quot;close&amp;quot; the dialog. Also on Desktop, when a dialog is &amp;quot;closed&amp;quot; in this way the window is not closed, but &amp;quot;hidden&amp;quot;! And it could happen that the code creates a new instance of the form, without removing the old one in memory. It’s documented in “&lt;a href="http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx"&gt;Form..::.ShowDialog Method&lt;/a&gt;” (the doc talks about “X” but of course for Windows Mobile refers to the 'Ok' referred to above):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;[…] When a form is displayed as a modal dialog box, clicking the Close button (the button with an X at the upper-right corner of the form) causes the form to be hidden and the &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.dialogresult.aspx"&gt;&lt;em&gt;DialogResult&lt;/em&gt;&lt;/a&gt;&lt;em&gt; property to be set to DialogResult.Cancel. Unlike modeless forms, the &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.close.aspx"&gt;&lt;em&gt;Close&lt;/em&gt;&lt;/a&gt;&lt;em&gt; method is not called by the .NET Framework when the user clicks the close form button of a dialog box or sets the value of the &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.dialogresult.aspx"&gt;&lt;em&gt;DialogResult&lt;/em&gt;&lt;/a&gt;&lt;em&gt; property. Instead the form is hidden and can be shown again without creating a new instance of the dialog box. Because a form displayed as a dialog box is not closed, you must call the &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dispose.aspx"&gt;&lt;em&gt;Dispose&lt;/em&gt;&lt;/a&gt;&lt;em&gt; method of the form when the form is no longer needed by your application.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Anyway, we assumed so far that the memory leak is MANAGED, but in reality it may be that leak is with the NATIVE resources that are used by a .NET instance, which have not been successfully released by implementing the so-called &amp;quot;&lt;strong&gt;&lt;em&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx"&gt;IDisposable Pattern&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;. And around this there are some peculiarities in NETCF, that Desktop-developers don’t need to worry about, particularly with respect to SQL Compact objects and &amp;quot;graphical&amp;quot; objects, i.e. classes of the &lt;strong&gt;System.Drawing&lt;/strong&gt; namespace. In NETCF the Font, Image, Bitmap, Pen, Brush objects are simple wrappers around their native resources, which in the Windows CE-based operating systems are handled by the GWES (Graphics, Windowing and Event Subsystem). What does this mean? It means that in their own .Dispose() they effectively release their native resources, and therefore one *&lt;strong&gt;must invoke .Dispose() for Drawing objects&lt;/strong&gt;* (or invoke methods that indirectly call it, for example .Clear() in ImageList.ImageCollection – which has not the .Dispose() itself). Note that among the counters provided by the Remote Performance Monitor, the category &amp;quot;Windows.Forms&amp;quot; contains indeed: &lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Controls Created &lt;/li&gt;

  &lt;li&gt;Brushes Created &lt;/li&gt;

  &lt;li&gt;Pens Created &lt;/li&gt;

  &lt;li&gt;Bitmaps Created &lt;/li&gt;

  &lt;li&gt;Regions Created &lt;/li&gt;

  &lt;li&gt;Fonts Created &lt;/li&gt;

  &lt;li&gt;Graphics Created (FromImage) &lt;/li&gt;

  &lt;li&gt;Graphics Created (CreateGraphics) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that I’m not talking about only objects directly “born” as Brush, Pen, etc.. I’m talking also about those objects whose properties contain graphic objects, such as a PictureBox or ImageList (or indirectly, an ImageList of a ToolBar). So, when you close a form, remember to: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;this&lt;/span&gt;.ImageList1.Images.Clear();
&lt;span class="kwrd"&gt;this&lt;/span&gt;.ToolBar1.ImageList.Images.Clear();
&lt;span class="kwrd"&gt;this&lt;/span&gt;.PictureBox1.Image.Dispose();
//etc...&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Finally, still about Forms, a simple technique I often used to identify possible problems with items not properly released at the closing of a form has been to emulate user interaction by “automatic” opening and closing of the form. I’m purely talking about a test code like this: &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;int&lt;/span&gt; N = 1000;
&lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 1; i &amp;lt;= N; i++)
{
   &lt;span class="kwrd"&gt;if&lt;/span&gt; (i % 200 == 0)  MessageBox.Show(i.ToString()); &lt;span class="rem"&gt;//just to know it's running&lt;/span&gt;
   &lt;span class="rem"&gt;// and to block execution in case you want to save counters (.STAT)&lt;/span&gt;
   &lt;span class="rem"&gt;// and GC Heap View (.GCLOG)    &lt;/span&gt;
   frmTest frm = &lt;span class="kwrd"&gt;new&lt;/span&gt; frmTest(&lt;span class="rem"&gt;/*...*/&lt;/span&gt;);    
   frm.Show();    
   frm.Close();    
   frm.Dispose(); 
}
MessageBox.Show(&lt;span class="str"&gt;&amp;quot;Over. Done. Finito.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;After running the loop N times, the Remote Performance Monitor will be of considerable help to see what is going wrong... &lt;img alt="Nerd" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/49_49.gif" /&gt;&lt;/p&gt;

&lt;p&gt;A final note before concluding this paragraph. It may be that an application is so complex to require &amp;quot;a lot of&amp;quot; virtual memory. This would not be a problem, as long as there is room for the lines &amp;quot;green&amp;quot; in my previous post. But requiring &amp;quot;a lot of&amp;quot; memory means that the Garbage Collector will get kicked more frequently, thus impacting general application performance (because the GC must first “lock” the threads in a safe state). The point is that if the application is so complex to require too frequent use of garbage collection (and therefore performance may not be acceptable by end-users), then it might be worthwhile to split the application into 2 parts, such as one for memory dog-guard and another for the user interface. This process at the cost of an additional process slot, but often it is something that can be paid. Or, since the managed DLLs are loaded in the Large Memory Area without wasting precious process’ address space, an idea would be to place all classes, even those of the form, not in the EXE but in the DLLs! A simple yet very effective idea, which Rob Tiffany has discussed about in his post &lt;a href="http://blogs.msdn.com/robtiffany/archive/2009/04/09/memmaker-for-the-net-compact-framework.aspx"&gt;&lt;strong&gt;MemMaker for the .NET Compact Framework&lt;/strong&gt;&lt;/a&gt;.&amp;#160; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face="Courier New"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Enjoy!
  &lt;br /&gt;~raffaele 

  &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923003" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+CE/">Windows CE</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Memory/">Memory</category></item><item><title>Microsoft released a HotFix for NETCF v3.5 on Windows Mobile 6.1.4 onwards, to address basic functionalities of WebBrowser control</title><link>http://blogs.msdn.com/b/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx</link><pubDate>Tue, 29 Sep 2009 13:52:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9900786</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9900786</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/09/29/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-6-1-4-onwards-to-address-basic-functionalities-of-webbrowser-control.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;Yet another demonstration of the added value provided by the Technical Support&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;A very impressive example of collaboration between Technical Support and Dev Team&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;FIX is public now&lt;/em&gt; &lt;em&gt;(&lt;a href="http://support.microsoft.com/kb/975281" target="_blank"&gt;link to KB Article&lt;/a&gt;)&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;&lt;font color="#ff0000"&gt;Update&lt;/font&gt;: the fixed CAB is automatically deployed by Marketplace&lt;/em&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;A few weeks ago I’ve started handling a Service Request coming from a ISV whose NETCF v3.5 Application relied on the WebBrowser control to display a HTML FORM with some links on it… Imagine simply the following form’s code:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; m_Html = 
&lt;span class="str"&gt;&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN&amp;lt;/a&amp;gt;&amp;lt;BR&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN&amp;lt;/a&amp;gt;&amp;lt;BR&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN    &amp;lt;/a&amp;gt;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN    &amp;lt;/a&amp;gt;&amp;lt;BR&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN    &amp;lt;/a&amp;gt;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN    &amp;lt;/a&amp;gt;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN&amp;lt;/a&amp;gt;&amp;lt;BR&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;a href=\&amp;quot;http://www.msn.com\&amp;quot;&amp;gt;MSN&amp;lt;/a&amp;gt;&amp;lt;BR&amp;gt;&amp;quot;&lt;/span&gt; +
&lt;span class="str"&gt;&amp;quot;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;&lt;/span&gt;;

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; menuItem2_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
       &lt;span class="kwrd"&gt;this&lt;/span&gt;.webBrowser1.DocumentText = m_Html;
}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;









.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Problem is that, after the HTML is loaded, when using navigation “buttons” (up\down\left\right):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;On WM6 I can navigate through the links: this is the expected behavior… and when pressing the action button the control navigates to the href link. &lt;/li&gt;

  &lt;li&gt;On WM6.1.4 &lt;strong&gt;the whole page is moved instead&lt;/strong&gt;; and &lt;strong&gt;when tapping on a link, nothing happens &lt;/strong&gt;(the expected behavior was that the control navigates) apart from “giving focus” to the link: at this point even if you press the action button the control doesn’t navigate &lt;/li&gt;

  &lt;li&gt;On WM6.5 the behavior is similar to 6.1.4’s, and here even horizontal and vertical scrollbars don’t appear &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem is easily reproduced on the Emulators as well, thus demonstrating that the issue is not OEM-ish…&lt;/p&gt;

&lt;p&gt;I also found at least 2 other developers reporting the problem through &lt;strong&gt;Microsoft Connect&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=474666"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=474666&lt;/a&gt; &lt;/li&gt;

  &lt;li&gt;&lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=484076"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=484076&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Troubleshooting steps included verifying which native control is wrapped by the NETCF v3.5’s WebBrowser: I noticed that when using the NATIVE code &lt;strong&gt;Mike Francis &lt;/strong&gt;provided in &lt;a href="http://blogs.msdn.com/mikefrancis/archive/2009/07/21/windows-mobile-6-5-web-browser-control-enabling-selection-support.aspx" target="_blank"&gt;his blog post&lt;/a&gt; (code sample available &lt;a href="http://cid-e91b74403814953e.skydrive.live.com/self.aspx/BrowserWithGestures/BrowserWithGestures.zip" target="_blank"&gt;here&lt;/a&gt;), then I get the desired behavior on all the 3 Emulators. Mike’s code is based on the WM6’s SDK Sample named “Browse” (\Samples\CPP\Win32\Browse\browse) and explains how to add gesture- and selection-support to a native application hosting the NATIVE web-browser control.&lt;/p&gt;

&lt;p&gt;So, the problem was just with the NETCF v3.5’s WebBrowser here! And interestingly &lt;u&gt;&lt;strong&gt;it’ NOT reproduced with NETCF v2 SP2 that ships in-ROM on WM6.x&lt;/strong&gt;&lt;/u&gt;. So… what are the loaded DLLs (i.e. what is the native control wrapped by the NETCF v3.5’s WebBrowser)? And which Windows? [I was intereseted on Windows’ ClassNames due to a possible technique to customize the WebBrowser’s context-menu, which I discussed &lt;a href="http://blogs.msdn.com/raffael/archive/2009/01/08/disable-webbrowser-s-context-menu-in-netcf-applications.aspx" target="_blank"&gt;here&lt;/a&gt;]&lt;/p&gt;

&lt;table border="1" cellspacing="1" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;&lt;em&gt;using 
          &lt;br /&gt;NETCF v3.5 WebBrowser&lt;/em&gt;&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6.1.4&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6.5&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;WND ClassName&lt;/td&gt;

      &lt;td valign="top" width="76"&gt;PIEHTML&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;Internet Explorer_Server&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;Internet Explorer_server&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;Loaded DLL&lt;/td&gt;

      &lt;td valign="top" width="76"&gt;webview&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;shdocvw&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;shdocvw&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;table border="1" cellspacing="1" cellpadding="2" width="400"&gt;&lt;tbody&gt;
    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;&lt;em&gt;using 
          &lt;br /&gt;Native Control (Mike’s code)&lt;/em&gt;&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6.1.4&lt;/p&gt;
      &lt;/td&gt;

      &lt;td valign="top" width="100"&gt;
        &lt;p align="center"&gt;WM6.5&lt;/p&gt;
      &lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;WND ClassName&lt;/td&gt;

      &lt;td valign="top" width="76"&gt;PIEHTML&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;PIEHTML&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;PIEHTML&lt;/td&gt;
    &lt;/tr&gt;

    &lt;tr&gt;
      &lt;td valign="top" width="124"&gt;Loaded DLL&lt;/td&gt;

      &lt;td valign="top" width="76"&gt;webview + htmlview&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;webview + htmlview&lt;/td&gt;

      &lt;td valign="top" width="100"&gt;webview + htmlview&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;To recap: the issues are due to the NETCF v3.5’s WebBrowser control loading the new native IE6on6 (&lt;b&gt;&lt;font color="#ff0000"&gt;shdocvw.dll&lt;/font&gt;&lt;/b&gt;) instead of relying on the native webview.dll + htmlview.dll, and this makes impossible for the user to (a) click a href link and (b) to navigate through them by using the up\down\left\right pad. Also, (c) on 6.5 the scrollbars are not created. When loading the same HTML by the same NETCF application on a WM6, the behavior is as expected. There’s &lt;u&gt;NO problem&lt;/u&gt; on WM6.1.4 and 6.5 when using the native control directly (&lt;font color="#ff0000"&gt;&lt;strong&gt;htmlview.dll&lt;/strong&gt; &lt;font color="#000000"&gt;and&lt;/font&gt; &lt;strong&gt;webview.dll&lt;/strong&gt;&lt;/font&gt;), for example through the WM6 SDK Sample \Samples\CPP\Win32\Browse\browse.&lt;/p&gt;

&lt;p&gt;What happened at this point? As I mentioned other times (for example &lt;a href="http://blogs.msdn.com/raffael/archive/2009/05/18/yet-another-technical-support-s-added-value-engagement-of-dev-teams.aspx" target="_blank"&gt;here&lt;/a&gt;), one of the added values provided by &lt;strong&gt;Technical Support&lt;/strong&gt; is that we have a channel to the &lt;strong&gt;Dev Teams&lt;/strong&gt; which we can use to &lt;strong&gt;advocate final users’ needs&lt;/strong&gt;. You can imagine how many customers the Technical Support reaches every single day: we’re basically one of the ears of the Product Groups. And also this time I received an impressive collaboration from&amp;#160; the NETCF Dev Team, which firstly accepted to package the FIX, and then did it in a very few days: this is not the usual way it works, so if you’ll ever request a fix then don’t expect this in general. As you can imagine this depends on the code that needs to be modified, in terms of both the complexity and the possible regression risks that a modification introduces, compared to the risks of application usability and other factors if the fix is not provided. For example, many times developers and users can accept a “workaround” while waiting for next version of the product or the possible next Service Pack – I’ve discussed about an example of this &lt;a href="http://blogs.msdn.com/raffael/archive/2009/07/27/sip-button-icon-disappears-after-closing-dialogs-in-netcf-v2-applications.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To conclude: &lt;strong&gt;a FIX is ready to be asked to the Technical Support&lt;/strong&gt;. KB Article is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href=" http://support.microsoft.com/kb/975281" target="_blank"&gt;&lt;strong&gt;FIX: You cannot scroll through a Web page or browse to a link by using a .NET Compact Framework 3.5-based application that hosts a WebBrowser control in Windows Mobile 6.1.4 and 6.5&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the time being it’s a separate hotfix, maybe the Dev team will consider packaging it within a Service Pack – this is not yet decided. This is another demonstration of a kind of historical change, as this is just the second separate hotfix provided for NETCF on Windows Mobile-based OSs. First one was release few months ago and I blogged about it &lt;a href="http://blogs.msdn.com/raffael/archive/2009/05/20/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-now-you-can-use-web-services-over-ssl-without-worrying-about-empty-packets.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A question may arise: can ISVs distribute the FIX? I mean, imagine I’m an ISV and developed a NETCF v3.5 app based on the WebBrowser control: if I want to make my app usable on WM6.1.4 and 6.5 devices of my clients, do I need to ask each of them to open a Service Request to Microsoft asking for the hotfix? The answer is: &lt;strong&gt;ISVs can distribute also the “patched” NETCF’s CAB&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&amp;lt;UPDATE date=”February 4, 2010” topic=”redist of the fix”&amp;gt;&lt;/font&gt;&lt;/strong&gt;At the time I wrote this post, Marketplace was not yet opened so I didn’t mention an interesting detail regarding the distribution of the fixed NETCF v3.5 CAB: well, if you use Marketplace to distribute your application, then you don’t need to worry about the fixed CAB of the NETCF, because Marketplace will distribute the most updated Build of the NETCF runtime your application targets, accordingly also to the &lt;a href="http://developer.windowsphone.com/resources/en-US/Application%20Submission%20Guidelines.pdf" target="_blank"&gt;&lt;em&gt;Application Submission Requirements for Windows® Marketplace for Mobile&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&amp;#160;&lt;/em&gt;whose point “&lt;em&gt;7.4. Restriction on .NET Compact Framework Redistribution&lt;/em&gt;” states:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;i&gt;Application providers should not include the .NET Compact Framework (.NET CF) redistributable package with their applications. The Windows Marketplace installation process will ensure that either the .NET CF 2.0 or .NET CF 3.5 runtime is installed on the device as required.&lt;/i&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I did a quick test with a freeware application I knew was built for NETCF v3.5, on a WM6.5 Emulator (so just hard-reset with only NETCF v2 “in-ROM”) – note the user-friendly process (I grayed the portions naming the application becasue I’m sure there are many others out there based on NETCF v3.5 &lt;img alt="Open-mouthed" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/teeth_smile.gif" /&gt;):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/FIXaboutWebBrowser_9054/before_4.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="before" border="0" alt="before" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/FIXaboutWebBrowser_9054/before_thumb_1.jpg" width="245" height="406" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When the download\install finished, just to verify which exact Build of the NETCF v3.5 was installed, I’ve run \Windows\cgacutil.exe and could see that, at today, the Build is 3.5.9198, which is precisely the one mentioned in the &lt;a href="http://support.microsoft.com/kb/975281" target="_blank"&gt;KB Article&lt;/a&gt; I’ve mentioned above:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/FIXaboutWebBrowser_9054/after_2.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="after" border="0" alt="after" src="http://blogs.msdn.com/blogfiles/raffael/WindowsLiveWriter/FIXaboutWebBrowser_9054/after_thumb.jpg" width="244" height="404" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&amp;lt;/UPDATE&amp;gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;WARNING&lt;/font&gt;&lt;/strong&gt;! Remember that analogously to every other hotfix you can ask to Technical Support about whatever Microsoft’s product, you should install it only if you're sure it’s for the problem you're being affected by. This is because a hotfix is meant to address a specific issue and has been tested precisely for that: it didn't go through the whole regression testing that it's usually done when packaging many hotfixes into a Service Pack. In this precise case, &lt;u&gt;you don’t have to install this hotfix if your NETCF v3.5 applications doesn’t use the WebBrowser control&lt;/u&gt;.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900786" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/HotFix/">HotFix</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/IE6on6/">IE6on6</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/WebBrowser/">WebBrowser</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Marketplace/">Marketplace</category></item><item><title>GPS.NET 3.0: thanks Jon!!</title><link>http://blogs.msdn.com/b/raffael/archive/2009/09/14/gps-net-3-0-thanks-jon.aspx</link><pubDate>Mon, 14 Sep 2009 17:55:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894980</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9894980</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/09/14/gps-net-3-0-thanks-jon.aspx#comments</comments><description>&lt;p&gt;Unfortunately I had to put GPS-Programming in stand-by mode… &lt;img alt="Sad" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/sad_smile.gif" /&gt; but finally some days ago I was reading one of the &lt;a href="http://blogs.msdn.com/raffael/archive/tags/GPS/default.aspx"&gt;posts I wrote about GPS&lt;/a&gt; roughly one year ago, and tried to navigate to a company’s webpage I remembered containing a lot of interesting info and controls about GPS, i.e. &lt;b&gt;GeoFrameworks&lt;/b&gt;: well, I realized that &lt;a href="http://www.geoframeworks.com/Closed.aspx"&gt;GeoFrameworks is now closed&lt;/a&gt;! Luckily their &lt;a href="http://www.geoframeworks.com/Articles/WritingApps1_1.aspx"&gt;Mastering GPS Programming&lt;/a&gt; is still available, but, much better… the founder of GeoFrameworks, &lt;a href="http://www.codeplex.com/site/users/view/jperson"&gt;Jon Person&lt;/a&gt;, “[…] &lt;em&gt;decided to release the full source code of GPS.NET to the public domain for the benefit of the open source development community&lt;/em&gt;”. If you’re interested on GPS-Programming, you must visit &lt;a href="http://gps3.codeplex.com"&gt;&lt;strong&gt;http://gps3.codeplex.com&lt;/strong&gt;&lt;/a&gt;! &lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9894980" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/GPS/">GPS</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Scatter+Thoughts/">Scatter Thoughts</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/GPS-NET/">GPS.NET</category></item><item><title>New opening: Italian Dev Support blog</title><link>http://blogs.msdn.com/b/raffael/archive/2009/09/11/new-opening-italian-dev-support-blog.aspx</link><pubDate>Fri, 11 Sep 2009 16:03:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894166</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9894166</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/09/11/new-opening-italian-dev-support-blog.aspx#comments</comments><description>&lt;p&gt;Yesterday my Italian colleagues in Developer Support and I officially inaugurated our new team blog: if you can read Italian then join us at &lt;a href="http://blogs.msdn.com/itasupport"&gt;http://blogs.msdn.com/itasupport&lt;/a&gt;. &lt;img alt="Hot" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/shades_smile.gif" /&gt;&lt;/p&gt;  &lt;p&gt;CIAO!    &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9894166" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Miscellanea/">Miscellanea</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Scatter+Thoughts/">Scatter Thoughts</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Italian/">Italian</category></item><item><title>Remote Desktop Mobile (RDP Client) disconnects after 10 minutes of inactivity</title><link>http://blogs.msdn.com/b/raffael/archive/2009/09/11/remote-desktop-mobile-rdp-client-disconnects-after-10-minutes-of-inactivity.aspx</link><pubDate>Fri, 11 Sep 2009 15:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894219</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>22</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9894219</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/09/11/remote-desktop-mobile-rdp-client-disconnects-after-10-minutes-of-inactivity.aspx#comments</comments><description>&lt;p&gt;&lt;em&gt;[&lt;strong&gt;UPDATE 10/9/2009: Source-Code and CAB are now available at &lt;/strong&gt;&lt;a href="http://mobilerdpnotimeout.codeplex.com/"&gt;&lt;strong&gt;http://mobilerdpnotimeout.codeplex.com/&lt;/strong&gt;&lt;/a&gt;] &lt;/em&gt;    &lt;br /&gt;&lt;em&gt;[&lt;strong&gt;UPDATE 9/2/2010: v2 of the sample app is available at &lt;/strong&gt;&lt;/em&gt;&lt;a href="http://mobilerdpnotimeout.codeplex.com/"&gt;&lt;strong&gt;&lt;em&gt;http://mobilerdpnotimeout.codeplex.com/&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;em&gt;: it takes care of the battery-life impacted by application continuing to emulate mouse-move even after user closed RDP session – see details below]&lt;/em&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;Error Message: “&lt;font color="#ff0000"&gt;The remote session was ended because the idle timeout limit was reached. This limit is set by the server administrator or by network policy&lt;/font&gt;.”&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;RDP\TSC Clients and Windows Mobile OEMs&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;What’s new in Windows Mobile 6.5 about Remote Desktop Mobile&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This issue should be somehow well known by the Community, but I couldn’t easily find a solution so I had to think one by myself… :-) After &lt;strong&gt;10 minutes of inactivity&lt;/strong&gt; of a Terminal Server session on Windows Mobile devices, the Remote Desktop Mobile application needs you to logon again stating that a timeout “&lt;em&gt;&lt;font color="#ff0000"&gt;set by the server administrator or by network policy&lt;/font&gt;&lt;/em&gt;” occurred. Unfortunately it’s not really a good error message, since many times the server is correctly set and the problem is just client-side... Anyway, probably it was not very frustrating since in the most of the cases one is logged via RDP only to actively work on the server. But this is not always true, so I’d guess either I wasn’t able to find someone with a possible solution, either simply people accepted to live with it…&lt;/p&gt;  &lt;p&gt;Remote Desktop Mobile on WM6.x (and, before this, the TSC client on WM5) is a component that OEMs are not required to include to have their OSs pass the Windows Mobile Logo Test Kit, and this is basically why you may find devices with it in-ROM and others where you need to find alternative solutions. In any case, regarding the inactivity timeout issue, luckily &lt;strong&gt;Windows Mobile 6.5 _&lt;em&gt;should&lt;/em&gt;_ now have an updated version of the Remote Desktop Mobile application that OEMs can include in their images&lt;/strong&gt;, easier to use on the field as it allows, for example, to finally customize an idle timeout!! Unfortunately it’s not included in the emulators coming with the &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=20686a1d-97a8-4f80-bc6a-ae010e085a6e" target="_blank" mce_href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=20686a1d-97a8-4f80-bc6a-ae010e085a6e"&gt;Windows Mobile 6.5 Developer Tool Kit&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Back to the problem… after some researches I understood that&lt;strong&gt; &lt;em&gt;the timer is reset only when the Remote Desktop Mobile’s application window receives mouse or keyboard input&lt;/em&gt;&lt;/strong&gt;. Refreshing the window, or sending exotic WM_xx messages wasn’t enough. So, I came to thinking what was a possible keypress or mouseevent that can be programmatically simulated (through keybd_event() or mouse_event()) that wouldn’t impact application at all?? After some tests I’ve realized that &lt;strong&gt;MOUSEEVENTF_MOVE&lt;/strong&gt;, which is the event of user “moving the mouse”, has no effect on current Windows Mobile-based devices: that event is maintained as codebase with Windows CE, where an OEM may also include a non-touch screen where you really have a mouse to move... but its only effect on Windows Mobile device is for example to modify display’s brightness, in case the display entered a sort of power-safe state (well, obviously the mouse-pointer is moved on the remote server)&lt;/p&gt;  &lt;p&gt;So, the idea was to develop a Win32 Console application that simply launches the Remote Desktop Mobile application and every X minutes (5? 9?) simulates a mouse-movement of some pixels and after a short time another one to place the mouse on the previous position.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;This is NOT elegant code at all, absolutely, but it does what was meant to run a specific task… &lt;img alt="Nerd" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/49_49.gif" mce_src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/49_49.gif" /&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Obviously this watch-dog application would “waste” one of the 30 process slots… is it acceptable? As you can see the application doesn’t do anything special or unsupported: it’s simply a monitor-console application with no particularly elegant code. As usual, I would strongly encourage on adding some error-checking!!&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;&lt;font color="#008000"&gt;&lt;/font&gt;
&lt;span class="kwrd"&gt;int&lt;/span&gt; _tmain(&lt;span class="kwrd"&gt;int&lt;/span&gt; argc, _TCHAR* argv[])
{
    &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; FIVEMINUTES = 1000*60*5;
    HWND hWndRDM = NULL;
    
    &lt;span class="rem"&gt;//Firstly launch RDP Client&lt;/span&gt;
    SHELLEXECUTEINFO sei = {0};
    sei.cbSize = &lt;span class="kwrd"&gt;sizeof&lt;/span&gt;(sei);
    sei.nShow = SW_SHOWNORMAL; 
    sei.lpFile = TEXT(&lt;span class="str"&gt;&amp;quot;\\Windows\\wpctsc.exe&amp;quot;&lt;/span&gt;);
    sei.lpParameters = TEXT(&lt;span class="str"&gt;&amp;quot; &amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!ShellExecuteEx(&amp;amp;sei))
    {
        MessageBox(NULL, TEXT(&lt;span class="str"&gt;&amp;quot;Couldn't launch RDP Client&amp;quot;&lt;/span&gt;), TEXT(&lt;span class="str"&gt;&amp;quot;Remote Desktop Launcher&amp;quot;&lt;/span&gt;), MB_OK);
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;
    }


    &lt;span class="rem"&gt;//Now every X minutes check if it's still running and if so &amp;quot;refresh&amp;quot; its window&lt;/span&gt;
    &lt;span class="rem"&gt;//if it's no longer running, exit&lt;/span&gt;
    &lt;span class="kwrd"&gt;do&lt;/span&gt; 
    {
        &lt;span class="rem"&gt;//check if RDP Client is running, otherwise exit&lt;/span&gt;
        hWndRDM = FindWindow(_T(&lt;span class="str"&gt;&amp;quot;TSSHELLWND&amp;quot;&lt;/span&gt;), NULL);
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hWndRDM)
        {
            &lt;span class="rem"&gt;////Get foreground window -- this is not needed if RDM is launched Full-Screen as it was in this case&lt;/span&gt;
            &lt;span class="rem"&gt;//hWndForeground = GetForegroundWindow();&lt;/span&gt;
            &lt;span class="rem"&gt;//Sleep(500);&lt;/span&gt;

            &lt;span class="rem"&gt;//Give focus to the RDP Client window (even if the logon screen, in case user logged out in the meantime)&lt;/span&gt;
            SetForegroundWindow(hWndRDM);

            &lt;span class="rem"&gt;//The timer is reset when the rdp window receives mouse or keyboard input&lt;/span&gt;
            &lt;span class="rem"&gt;//with no MOUSEEVENTF_ABSOLUTE the move is relative&lt;/span&gt;

            mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0);
            Sleep(250);
            mouse_event(MOUSEEVENTF_MOVE, -100, 0, 0, 0);

            &lt;span class="rem"&gt;////Give focus back to previous foreground window&lt;/span&gt;
            &lt;span class="rem"&gt;//SetForegroundWindow(hWndForeground);&lt;/span&gt;

            &lt;span class="rem"&gt;//Sleep &lt;/span&gt;
            Sleep(FIVEMINUTES);
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt; 
        {
            &lt;span class="rem"&gt;//RDP Client is not running - let's exit&lt;/span&gt;
            &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;
        }
    }
    &lt;span class="kwrd"&gt;while&lt;/span&gt; (TRUE); &lt;span class="rem"&gt;//The check (NULL != hWndRDM) is already done inside the loop&lt;/span&gt;


Exit:
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hWndRDM)
        CloseHandle(hWndRDM);
    
    &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;
}&lt;/pre&gt;

  &lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;I can imagine that this problem affects more the WinMo Users rather than the WinMo “Devs”, therefore I had in mind to distribute directly the CAB of the application, if anyone else doesn’t want to do it for the Community. I’m wondering if CodePlex would be a good place, I’ll see and update this post. In any case, remember that it’s up to the OEMs to decide if including RDM (\Windows\wpctsc.exe) in their OSs based on Windows Mobile platform!&lt;/p&gt;

&lt;p&gt;Cheers! 
  &lt;br /&gt;~raffaele &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;EDIT 9/2/2010:&lt;/font&gt;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;font color="#000000"&gt;After interacting with some users of the sample application and tested a v2 build on some scenarios, I’d like to share it now – note that the CodePlex project page will continue containing both versions. The issue was that &lt;/font&gt;MyRDM continued to emulate mouse-move even after user closed session, and this impacted on battery-life: this was not a bug, but simply a well known limitation of the tiny sample application… so we wanted a code that acted on the following possible conditions after every sleep-interval:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Wpstsc is no longer running (user “minimized” and OS closed it) &lt;em&gt;–&amp;gt; in this case, MyRDM.exe exits&lt;/em&gt;&lt;/li&gt;

  &lt;li&gt;Wpstsc is running AND:&lt;/li&gt;

  &lt;ul&gt;
    &lt;li&gt;The “remote session” is foreground &lt;em&gt;–&amp;gt; then MyRDM.exe emulates mouse-move and goes back to sleep&lt;/em&gt;&lt;/li&gt;

    &lt;li&gt;The “remote session” is not foreground for one of the possible causes:&lt;/li&gt;

    &lt;ul&gt;
      &lt;li&gt;User “minimized” wpstsc&lt;em&gt; –&amp;gt; then MyRDM.exe kills wpstsc and exits&lt;/em&gt;&lt;/li&gt;

      &lt;li&gt;User logged off, and the foreground window is the RDM Logon window &lt;em&gt;–&amp;gt; then MyRDM.exe does nothing and simply goes back to sleep&lt;/em&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/ul&gt;
&lt;/ul&gt;

&lt;p&gt;So the main portion of the code is the following (the same disclaimers apply as before):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;do&lt;/span&gt; 
        {
                &lt;span class="rem"&gt;//Sleep &lt;/span&gt;
                Sleep(FIVEMINUTES);

                &lt;span class="rem"&gt;//check if RDP Client is still running, otherwise exit&lt;/span&gt;
                hWndRDM = FindWindow(_T(&lt;span class="str"&gt;&amp;quot;TSSHELLWND&amp;quot;&lt;/span&gt;), NULL);
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hWndRDM)
                {
                        hWndForeground = GetForegroundWindow();
                        &lt;span class="kwrd"&gt;if&lt;/span&gt; (hWndRDM == hWndForeground)
                        {
                                &lt;span class="rem"&gt;//The timer is reset when the rdp window receives mouse or keyboard input&lt;/span&gt;
                                &lt;span class="rem"&gt;//with no MOUSEEVENTF_ABSOLUTE the move is relative&lt;/span&gt;
                                mouse_event(MOUSEEVENTF_MOVE, 100, 0, 0, 0);
                                Sleep(250);
                                mouse_event(MOUSEEVENTF_MOVE, -100, 0, 0, 0);
                        }
                        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;//this means that RDM main windows is no longer foreground, however it may be that the RDP logon page is active&lt;/span&gt;
                        {
                                pid = NULL;
                                threadId = GetWindowThreadProcessId(hWndForeground, &amp;amp;pid);
                                &lt;span class="rem"&gt;//only if the foreground window is not the RDP logon page, then kill wpctsc.exe and exit&lt;/span&gt;
                                &lt;span class="kwrd"&gt;if&lt;/span&gt; (pid != GetProcessIdByName(TEXT(&lt;span class="str"&gt;&amp;quot;wpctsc.exe&amp;quot;&lt;/span&gt;)))
                                {
                                        KillProcessByName(TEXT(&lt;span class="str"&gt;&amp;quot;wpstsc.exe&amp;quot;&lt;/span&gt;));
                                        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;
                                }
                        }
                }
                &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="rem"&gt;//hWndRDM == NULL: RDP Client is not running - let's exit&lt;/span&gt;
                {                       
                        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;
                }
        }
        &lt;span class="kwrd"&gt;while&lt;/span&gt; (TRUE);&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;HTH, ciao!
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9894219" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Utilities/">Utilities</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Remote+Desktop+Mobile/">Remote Desktop Mobile</category></item><item><title>SIP Button Icon disappears after closing dialogs in NETCF v2 applications</title><link>http://blogs.msdn.com/b/raffael/archive/2009/07/27/sip-button-icon-disappears-after-closing-dialogs-in-netcf-v2-applications.aspx</link><pubDate>Mon, 27 Jul 2009 14:39:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9849910</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9849910</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/07/27/sip-button-icon-disappears-after-closing-dialogs-in-netcf-v2-applications.aspx#comments</comments><description>&lt;p&gt;I thought this was something well known by the Mobile Dev Community, but maybe this is not true, since I’ve recently worked on a similar case.. so it may be worth sharing it here! &lt;/p&gt;  &lt;p&gt;Under some special circumstances, which weren’t possible to reproduce for Technical Support and NETCF Dev Team at that time (about 2-3 years ago) – also because it was resolved in NETCF v3.5 – it happened that on NETCF v2 applications when a form gains back the focus after it was given to a dialog (&lt;em&gt;MessageBox.Show()&lt;/em&gt; or &lt;em&gt;anotherForm.ShowDialog()&lt;/em&gt;), then _&lt;em&gt;sometimes&lt;/em&gt;_ that little squared SIP icon at the middle of the menubar at the bottom suddenly disappeared. &lt;/p&gt;  &lt;p&gt;That nasty problem was due to some faulty interaction between the OS and the .NET runtime, in any case no longer reproduced with v3.5. In some cases it had sufficed to reset this.Menu (or this.Parent.Menu) to the main menu. But that wasn’t the case in our service request… and also the simple refresh of the form at form’s OnActivated was NOT enough:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnActivated(EventArgs e)
{
     &lt;span class="kwrd"&gt;this&lt;/span&gt;.Menu = mainMnu;
     &lt;span class="kwrd"&gt;this&lt;/span&gt;.Refresh();

     &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnActivated(e);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;So we had to find a satisfactory temporary solution for NETCF v2 applications (migration to v3.5 was already in progress..). As usual I proposed to play with WINDOWS… :-) and we came up with the following propositions – the first one did the trick! (remember to add error-handling to whatever code I may suggest!!)&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;b&gt;FindWindow + ShowWindow&lt;/b&gt; 

    &lt;ol&gt;
      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnActivated(EventArgs e)
{
    IntPtr hSip = FindWindow(&lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; ((hSip != IntPtr.Zero) &lt;span class="rem"&gt;/*&amp;amp;&amp;amp; (!IsWindowVisible(hSip))) */&lt;/span&gt;
    {
        &lt;span class="kwrd"&gt;bool&lt;/span&gt; retShowWin = ShowWindow(hSip, EShowWindow.SW_SHOW);
    }
    &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnActivated(e);
}


[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr FindWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; _ClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; _WindowName);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsWindowVisible(IntPtr hWnd);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; ShowWindow(IntPtr hwnd, EShowWindow nCmdShow);

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; EShowWindow : &lt;span class="kwrd"&gt;uint&lt;/span&gt;
{ 
    SW_HIDE = 0,
    SW_SHOWNORMAL = 1,
    &lt;span class="rem"&gt;//SW_SHOWNOACTIVATE = 4,&lt;/span&gt;
    SW_SHOW           = 5 ,
    &lt;span class="rem"&gt;//SW_MINIMIZE       = 6,&lt;/span&gt;
    SW_SHOWNA         = 8 &lt;span class="rem"&gt;//,&lt;/span&gt;
    &lt;span class="rem"&gt;//SW_SHOWMAXIMIZED  = 11,&lt;/span&gt;
    &lt;span class="rem"&gt;//SW_MAXIMIZE           = 12,&lt;/span&gt;
    &lt;span class="rem"&gt;//SW_RESTORE            = 13&lt;/span&gt;
}&lt;/pre&gt;

      &lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
      &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;b&gt;FindWindow + BringWindowToTop&lt;/b&gt; 

    &lt;ol&gt;
      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnActivated(EventArgs e)
{
    IntPtr hSip = FindWindow(&lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; ((hSip != IntPtr.Zero) &lt;span class="rem"&gt;/*&amp;amp;&amp;amp; (!IsWindowVisible(hSip))) */&lt;/span&gt;
    {
        &lt;span class="kwrd"&gt;bool&lt;/span&gt; retBringWin = BringWindowToTop(hSip);
    }
    &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnActivated(e);
}


[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr FindWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; _ClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; _WindowName);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsWindowVisible(IntPtr hWnd);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; BringWindowToTop(IntPtr hWnd);&lt;/pre&gt;

      &lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
      &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;
  &lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;FindWindow + GetWindowLong&lt;/strong&gt; 

    &lt;ol&gt;
      &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;override&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnActivated(EventArgs e)
{
    IntPtr hSip = FindWindow(&lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;MS_SIPBUTTON&amp;quot;&lt;/span&gt;);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; ((hSip != IntPtr.Zero) &lt;span class="rem"&gt;/*&amp;amp;&amp;amp; (!IsWindowVisible(hSip))) */&lt;/span&gt;
    { 
        &lt;span class="kwrd"&gt;int&lt;/span&gt; style = GetWindowLong(hSip, GWL_STYLE);
        style |= WS_POPUP | WS_VISIBLE;
        &lt;span class="kwrd"&gt;int&lt;/span&gt; retSetWin = SetWindowLong(hSip, GWL_STYLE, style);

        &lt;span class="kwrd"&gt;int&lt;/span&gt; exstyle = GetWindowLong(hSip, GWL_EXSTYLE);
        exstyle |= WS_EX_ABOVESTARTUP | WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
        retSetWin = SetWindowLong(hSip, GWL_EXSTYLE, exstyle);
    }
    &lt;span class="kwrd"&gt;base&lt;/span&gt;.OnActivated(e);
}


[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr FindWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; _ClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; _WindowName);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; IsWindowVisible(IntPtr hWnd);

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GWL_EXSTYLE = (-20);
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GWL_STYLE = (-16);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GetWindowLong(IntPtr hWnd, &lt;span class="kwrd"&gt;int&lt;/span&gt; nIndex);

[DllImport(&lt;span class="str"&gt;&amp;quot;coredll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; SetWindowLong(IntPtr hWnd, &lt;span class="kwrd"&gt;int&lt;/span&gt; nIndex, &lt;span class="kwrd"&gt;int&lt;/span&gt; dwNewLong);

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt;
    WS_POPUP = &lt;span class="kwrd"&gt;unchecked&lt;/span&gt;((&lt;span class="kwrd"&gt;int&lt;/span&gt;)0x80000000),
    WS_VISIBLE = 0x10000000,
    WS_EX_ABOVESTARTUP = 0x20000000,
    WS_EX_NOACTIVATE = 0x08000000,
    WS_EX_TOOLWINDOW = 0x00000080,
    WS_EX_TOPMOST = 0x00000008;&lt;/pre&gt;
      &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;
  &lt;p&gt;&lt;/p&gt;&amp;#160;&amp;#160; &lt;/b&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9849910" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Win32/">Win32</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/SIP/">SIP</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Forms/">Windows Forms</category></item><item><title>Resolution-Aware CAB on Windows Mobile</title><link>http://blogs.msdn.com/b/raffael/archive/2009/06/17/resolution-aware-cab-on-windows-mobile.aspx</link><pubDate>Wed, 17 Jun 2009 15:46:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9769273</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9769273</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/06/17/resolution-aware-cab-on-windows-mobile.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;GetSystemMetrics or GetDeviceCaps inside a CAB’s Setup.dll &lt;/li&gt;    &lt;li&gt;wceload.exe is not resolution- and DPI-aware &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb158675.aspx"&gt;RESDLL&lt;/a&gt; SDK Sample&amp;#160; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Sincerely I haven’t easily found entries about this over the web, so I think it’s worth mentioning it. Maybe many know, but possible many others don’t… &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt; Imagine you want to perform different actions during install depending on the device’s resolution. A possible code to retrieve resolution can use GetSystemMetrics or GetDeviceCaps. My troubleshooting, as initial step, was as usual to verify if I could reproduce ISV’s problem, even on Device Emulator (thus avoiding possible problems related to OEMs’ customizations). So I included the following in a CAB’s Setup.dll’s Install_Init (Install_Exit is the same):&lt;/p&gt;  &lt;pre class="csharpcode"&gt;        HRESULT hr = S_OK;

        LPTSTR pszBuf = &lt;span class="kwrd"&gt;new&lt;/span&gt; TCHAR[256];
        ZeroMemory(pszBuf, 255);

        &lt;span class="kwrd"&gt;int&lt;/span&gt; X = GetSystemMetrics(SM_CXSCREEN);
        &lt;span class="kwrd"&gt;int&lt;/span&gt; Y = GetSystemMetrics(SM_CYSCREEN);

        hr = StringCchPrintf(pszBuf, 
                        LocalSize(pszBuf) / &lt;span class="kwrd"&gt;sizeof&lt;/span&gt;(TCHAR),
                        TEXT(&lt;span class="str"&gt;&amp;quot;X: %d\r\nY: %d&amp;quot;&lt;/span&gt;), 
                        X, Y);
        CHR(hr);

        MessageBox(hwndParent, pszBuf, TEXT(&lt;span class="str"&gt;&amp;quot;Install_Exit&amp;quot;&lt;/span&gt;), MB_OK);

    Exit:
        &lt;span class="kwrd"&gt;return&lt;/span&gt; codeINSTALL_INIT_CONTINUE; &lt;span class="rem"&gt;//or codeINSTALL_EXIT_DONE for Install_Exit&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Specifically:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;on a VGA WM6 Emulator (&lt;strong&gt;640x480&lt;/strong&gt;) it returned &lt;strong&gt;&lt;font color="#ff0000"&gt;320x240&lt;/font&gt;&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;on a square VGA WM6 Emulator (&lt;strong&gt;480x480&lt;/strong&gt;) it returned &lt;strong&gt;&lt;font color="#ff0000"&gt;240x240&lt;/font&gt;&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;on a square QVGA WM6 Emulator (&lt;strong&gt;320x320&lt;/strong&gt;) it returned &lt;strong&gt;&lt;font color="#ff0000"&gt;240x240&lt;/font&gt;&lt;/strong&gt; &lt;/li&gt;

  &lt;li&gt;on a WM6.1.4 EMULATOR (&lt;strong&gt;480x800&lt;/strong&gt;) it returned &lt;strong&gt;&lt;font color="#ff0000"&gt;240x400&lt;/font&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When using precisely the same code in a Win32 Smart Device Console application, the values returned were the expected ones…&lt;/p&gt;

&lt;p&gt;After working with a colleague (&lt;font color="#ff0000"&gt;thanks Manfred!&lt;/font&gt; &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt;) I got the confirmation about an idea… the problem here is that a CAB’s Setup.dll gets loaded by wceload.exe when installing the CAB, and &lt;strong&gt;wceload.exe is not resolution- and DPI-aware &lt;/strong&gt;. Therefore when setup.dll’s code runs inside the wceload’s context it can’t successfully call GetSystemMetrics or also GetDeviceCaps. &lt;/p&gt;

&lt;p&gt;It turned out that to address this limitation, a sample is provided in the SDKs explaining how to do this: &amp;quot;C:\Program Files (x86)\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\resdll&amp;quot; (MSDN Doc &lt;a href="http://msdn.microsoft.com/en-us/library/bb158675.aspx"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;). Notice that setup.dll’s Install_Exit\_Init containing code to run an external DPI-aware application, whose sample code is also provided.&lt;/p&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9769273" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/CAB/">CAB</category></item><item><title>The right approach to get a Contact’s last communication (IItem’s PIMPR_SMARTPROP)</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/28/the-right-approach-to-get-a-contact-s-last-communication-iitem-s-pimpr-smartprop.aspx</link><pubDate>Thu, 28 May 2009 16:21:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9647145</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9647145</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/28/the-right-approach-to-get-a-contact-s-last-communication-iitem-s-pimpr-smartprop.aspx#comments</comments><description>&lt;p&gt;I've discussed about the “wrong” approach in &lt;a href="http://blogs.msdn.com/raffael/archive/2009/05/04/the-wrong-approach-to-get-a-contact-s-last-communication-edb.aspx"&gt;a previous post of mine&lt;/a&gt;, where I also talked about why using &lt;strong&gt;PIMPR_SMARTPROP&lt;/strong&gt; to retrieve the info about the last way a Windows Mobile-device user communicated with a given contact. Recently 2 MSDN Forums users asked for help about this (“&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/0686b076-0c07-4c2a-b060-f71ccba90f34"&gt;How to get the information of a selected phonecall number?&lt;/a&gt;” and “&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesvbcs/thread/3ca57baf-a4f8-483d-8efa-5325cb2c2cdd"&gt;How to read LastNumber in contact&lt;/a&gt;”) and therefore I wanted to invest some time for the Community, hoping this may help others as well! &lt;img alt="smile_shades" src="http://spaces.live.com/rte/emoticons/smile_shades.gif"&gt; (and also to play with POOM, since managed APIs wrapped so many properties making POOM _&lt;em&gt;quite&lt;/em&gt;_ obsolete…)&lt;/p&gt; &lt;p&gt;Before spreading the code, let me state a thing: &lt;u&gt;the SmartProp property is not set for a contact until the first time the user &lt;br&gt;explicitly changes the default contact method, or it is otherwise explicitly set by an application&lt;/u&gt;. I noticed this when coding this sample, and later I understood that this is the expected behavior. &lt;/p&gt; &lt;p&gt;Ehy, remember that this is not production code: this is for testing\didactic purposes only… indeed the code is simply meant to dump out to a text-file only the First Name, Last Name and the string representing the last way user communicated with the selected contact. The code doesn’t even use the IPOutlookItemCollection::Find to get a specific contact, as this was not the goal here. Yet, I think it was worth sharing as it is, so that who wants can customize it… &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif"&gt; enjoy!!&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;NOTES:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;PIMPR_SMARTPROP is a property of the IItem, not of the IContact: that’s why for example the old POOM NETCF sample code didn’t contain it. So what we need is to retrieve the collection of Contacts and handle them as IItem.  &lt;li&gt;Once you have all the contacts as a collection (IPOutlookItemCollection), you can’t directly retrieve each item – even if IItem implements IDispatch, the right way is the one for example mentioned by my colleague &lt;strong&gt;Xiaoyun Li&lt;/strong&gt; &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/d49c0cfe-0246-47cd-9fcf-0191e8c19efd"&gt;here&lt;/a&gt;, i.e. invoke IPOutlookItemCollection::Item by passing a IContact as IDispatch, then call IContact::get_Oid to retrieve the unique OID and finally use this with IPOutlookApp2::GetItemFromOidEx (see function DumpOutToText below).  &lt;li&gt;At this point you have an IItem object and can query its properties in the usual old way, considering that PIMPR_SMARTPROP will return the property id (e.g. PIMPR_MOBILE_TELEPHONE_NUMBER, PIMPR_SMS, etc); all the propIDs that can be returned as smart prop are listed in the documentation &lt;a href="http://msdn.microsoft.com/en-us/library/bb415504.aspx"&gt;here&lt;/a&gt;.  &lt;li&gt;For each returned property, remember to check if it was really found (&lt;em&gt;.wFlags != CEDB_PROPNOTFOUND&lt;/em&gt;) and if it’s of the expected data type (&lt;em&gt;.propid == CEVT_LPWSTR&lt;/em&gt;). &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;If you know of any smarter way I’ll be more than welcome on continuing this saga about PIMPR_SMARTPROP… &lt;img alt="smile_teeth" src="http://spaces.live.com/rte/emoticons/smile_teeth.gif"&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp; &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="preproc"&gt;#include&lt;/span&gt; &lt;span class="str"&gt;"stdafx.h"&lt;/span&gt;
&lt;span class="preproc"&gt;#include&lt;/span&gt; &lt;span class="str"&gt;&amp;lt;pimstore.h&amp;gt;&lt;/span&gt;

&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;
&lt;span class="rem"&gt;// Globals&lt;/span&gt;
IPOutlookApp2 * g_polApp = NULL;
IUnknown * g_pUnknown = NULL;
LPCTSTR g_pszFilename = TEXT(&lt;span class="str"&gt;"contacts.txt"&lt;/span&gt;);

&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;
&lt;span class="rem"&gt;//Functions&lt;/span&gt;
HRESULT InitPoom(&lt;span class="kwrd"&gt;void&lt;/span&gt;);
HRESULT GetPoomFolder(&lt;span class="kwrd"&gt;int&lt;/span&gt; nFolder, IFolder ** ppFolder);
HRESULT FillFileWithContacts(&lt;span class="kwrd"&gt;void&lt;/span&gt;);
HRESULT DumpOutToText(IPOutlookItemCollection * pItemCol);
HRESULT WriteItemSmartProp(IItem *pItem);
HRESULT Log(LPTSTR szLog);
HRESULT LogToFile(LPTSTR szLog, LPCTSTR pszFilename);

&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;
&lt;span class="rem"&gt;//MAIN&lt;/span&gt;
&lt;span class="kwrd"&gt;int&lt;/span&gt; _tmain(&lt;span class="kwrd"&gt;int&lt;/span&gt; argc, _TCHAR* argv[])
{
    HRESULT hr = E_FAIL;

    &lt;span class="rem"&gt;//Initialize POOM&lt;/span&gt;
    hr = InitPoom();
    CHR(hr);

    &lt;span class="rem"&gt;//Fill file with Contacts&lt;/span&gt;
    hr = FillFileWithContacts();
    CHR(hr);
    
    &lt;span class="rem"&gt;//Success&lt;/span&gt;
    MessageBox(NULL, TEXT(&lt;span class="str"&gt;"Done"&lt;/span&gt;), TEXT(&lt;span class="str"&gt;"Test"&lt;/span&gt;), MB_OK);

Exit:
    &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;
}


&lt;span class="rem"&gt;// ************************************************************************** &lt;/span&gt;
&lt;span class="rem"&gt;//InitPoom&lt;/span&gt;
HRESULT InitPoom(&lt;span class="kwrd"&gt;void&lt;/span&gt;) 
{
    HRESULT hr = E_FAIL;

    hr = CoInitializeEx(NULL, 0);
    CHR(hr);

    hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (&lt;span class="kwrd"&gt;void&lt;/span&gt; **)&amp;amp;g_pUnknown);
    CHR(hr);

    hr = g_pUnknown-&amp;gt;QueryInterface(IID_IPOutlookApp, (&lt;span class="kwrd"&gt;void&lt;/span&gt;**)&amp;amp;g_polApp); 
    CHR(hr);

    hr = g_polApp-&amp;gt;Logon(NULL);
    CHR(hr);

    &lt;span class="rem"&gt;//success&lt;/span&gt;
    hr = S_OK;

Exit:
    RELEASE_OBJ(g_polApp);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}


&lt;span class="rem"&gt;// ************************************************************************** &lt;/span&gt;
&lt;span class="rem"&gt;//FillFileWithContacts&lt;/span&gt;
HRESULT FillFileWithContacts(&lt;span class="kwrd"&gt;void&lt;/span&gt;)
{
    HRESULT hr = E_FAIL;
    IFolder * pCurrFldr = NULL;
    IPOutlookItemCollection * pItemCol = NULL;
    
    &lt;span class="rem"&gt;// Get the Contacts folder and its items&lt;/span&gt;
    hr = GetPoomFolder(olFolderContacts, &amp;amp;pCurrFldr);
    CHR(hr);
        
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED(pCurrFldr-&amp;gt;get_Items(&amp;amp;pItemCol)))
    {
        &lt;span class="rem"&gt;//Dump out First Name, Last Name, SMARTPROP for each item&lt;/span&gt;
        hr = DumpOutToText(pItemCol);
        CHR(hr);
    }

    &lt;span class="rem"&gt;//success &lt;/span&gt;
    hr = S_OK;

Exit:
    RELEASE_OBJ(pItemCol);
    RELEASE_OBJ(pCurrFldr);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}


&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;
&lt;span class="rem"&gt;//GetPoomFolder&lt;/span&gt;
HRESULT GetPoomFolder(&lt;span class="kwrd"&gt;int&lt;/span&gt; nFolder, IFolder ** ppFolder)
{
    HRESULT hr = E_FAIL;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED(g_polApp-&amp;gt;GetDefaultFolder(nFolder, ppFolder)))
    {
        hr = S_OK;
    }

    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}


&lt;span class="rem"&gt;// ************************************************************************** &lt;/span&gt;
&lt;span class="rem"&gt;//DumpOutToText&lt;/span&gt;
HRESULT DumpOutToText(IPOutlookItemCollection * pItemCol)
{
    HRESULT hr = E_FAIL;
    IContact * pContact = NULL;
    IItem * pItem = NULL;
    CEOID oid = 0;   
    &lt;span class="kwrd"&gt;int&lt;/span&gt; cItems = 0;

    &lt;span class="rem"&gt;//Count contacts&lt;/span&gt;
    pItemCol-&amp;gt;get_Count(&amp;amp;cItems);    
    &lt;span class="kwrd"&gt;for&lt;/span&gt; (&lt;span class="kwrd"&gt;int&lt;/span&gt; i = 1; i &amp;lt;= cItems; i++)
    {
        &lt;span class="rem"&gt;//get the item as a IContact&lt;/span&gt;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED(pItemCol-&amp;gt;Item (i, &lt;span class="kwrd"&gt;reinterpret_cast&lt;/span&gt;&amp;lt;IDispatch**&amp;gt;(&amp;amp;pContact))))
        {
            &lt;span class="rem"&gt;//convert the IContact into a IItem...&lt;/span&gt;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED(pContact-&amp;gt;get_Oid((&lt;span class="kwrd"&gt;long&lt;/span&gt;*)&amp;amp;oid)))
            {
                &lt;span class="rem"&gt;//... by using the Oid&lt;/span&gt;
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (SUCCEEDED(g_polApp-&amp;gt;GetItemFromOidEx(oid, 0, &amp;amp;pItem)))
                {
                    &lt;span class="rem"&gt;//Write item's properties to file&lt;/span&gt;
                    hr = WriteItemSmartProp(pItem);
                    
                    RELEASE_OBJ(pItem);
                    CHR(hr);
                }
            }
        }
    }

    &lt;span class="rem"&gt;//success&lt;/span&gt;
    hr = S_OK;

Exit:
    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}


&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;
&lt;span class="rem"&gt;//GetItemSmartProp&lt;/span&gt;
HRESULT WriteItemSmartProp(IItem *pItem)
{
    HRESULT hr = E_FAIL;
    &lt;span class="kwrd"&gt;int&lt;/span&gt; cProps = 20;
    CEPROPID rgPropId[20] = {0};
    CEPROPVAL *prgPropvalUser = NULL;
    ULONG cbBuffer = 0;

    &lt;span class="rem"&gt;// FROM http://msdn.microsoft.com/en-us/library/bb415504.aspx&lt;/span&gt;
    &lt;span class="rem"&gt;// The Smart Property (PIMPR_SMARTPROP) is the Contact property that contains the property ID of the default communication mode.&lt;/span&gt;
    rgPropId[0] = PIMPR_FIRST_NAME; &lt;span class="rem"&gt;//type: CEVT_LPWSTR&lt;/span&gt;
    rgPropId[1] = PIMPR_LAST_NAME;  &lt;span class="rem"&gt;//type: CEVT_LPWSTR&lt;/span&gt;
    rgPropId[2] = PIMPR_SMARTPROP;  &lt;span class="rem"&gt;//type: CEVT_UI4&lt;/span&gt;

    &lt;span class="rem"&gt;//all of the following are of type: CEVT_LPWSTR&lt;/span&gt;
    rgPropId[3] = PIMPR_IM2_ADDRESS;                    
    rgPropId[4] = PIMPR_ASSISTANT_TELEPHONE_NUMBER;        
    rgPropId[5] = PIMPR_BUSINESS_TELEPHONE_NUMBER;        
    rgPropId[6] = PIMPR_BUSINESS2_TELEPHONE_NUMBER;        
    rgPropId[7] = PIMPR_CAR_TELEPHONE_NUMBER;            
    rgPropId[8] = PIMPR_COMPANY_TELEPHONE_NUMBER;        
    rgPropId[9] = PIMPR_EMAIL1_ADDRESS;                    
    rgPropId[10] = PIMPR_EMAIL2_ADDRESS;                    
    rgPropId[11] = PIMPR_EMAIL3_ADDRESS;                
    rgPropId[12] = PIMPR_HOME_TELEPHONE_NUMBER;            
    rgPropId[13] = PIMPR_HOME2_TELEPHONE_NUMBER;        
    rgPropId[14] = PIMPR_IM1_ADDRESS;                                        
    rgPropId[15] = PIMPR_IM3_ADDRESS;                    
    rgPropId[16] = PIMPR_MOBILE_TELEPHONE_NUMBER;        
    rgPropId[17] = PIMPR_PAGER_NUMBER;                    
    rgPropId[18] = PIMPR_RADIO_TELEPHONE_NUMBER;        
    rgPropId[19] = PIMPR_SMS;                            


    &lt;span class="rem"&gt;//FROM: http://msdn.microsoft.com/en-us/library/ms859378.aspx&lt;/span&gt;
    &lt;span class="rem"&gt;// Allocate memory, then get item properties&lt;/span&gt;
    cbBuffer = 0;
    hr = pItem-&amp;gt;GetProps(rgPropId, 0, cProps, &amp;amp;prgPropvalUser, &amp;amp;cbBuffer, NULL);
    &lt;span class="kwrd"&gt;if&lt;/span&gt;(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) == hr)
    {
        prgPropvalUser = (CEPROPVAL *) LocalAlloc(0, cbBuffer); 
    }

    &lt;span class="rem"&gt;// cbBuffer is set to the number of bytes required to hold the data.&lt;/span&gt;
    hr = pItem-&amp;gt;GetProps(rgPropId, 0, cProps, (CEPROPVAL **)&amp;amp;prgPropvalUser, &amp;amp;cbBuffer, NULL);

    &lt;span class="rem"&gt;//better error-checking to do here...&lt;/span&gt;
    &lt;span class="kwrd"&gt;if&lt;/span&gt;(FAILED(hr) || 0 == cbBuffer)
    {
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;
    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[0].wFlags!=CEDB_PROPNOTFOUND)   
    {   
        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[0].propid) == CEVT_LPWSTR)
        {
            Log(prgPropvalUser[0].val.lpwstr);
            Log(TEXT(&lt;span class="str"&gt;"\t"&lt;/span&gt;));
        }
    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[1].wFlags!=CEDB_PROPNOTFOUND)   
    {   
        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[1].propid) == CEVT_LPWSTR)  
        {
            Log(prgPropvalUser[1].val.lpwstr);
            Log(TEXT(&lt;span class="str"&gt;"\t"&lt;/span&gt;));
        }
    }

    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[2].wFlags!=CEDB_PROPNOTFOUND)   
    {   
        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[2].propid) == CEVT_UI4)   
        {
            &lt;span class="kwrd"&gt;switch&lt;/span&gt; (prgPropvalUser[2].val.ulVal)
            {
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_IM2_ADDRESS:
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[3].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[3].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[3].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_ASSISTANT_TELEPHONE_NUMBER:
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[4].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[4].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[4].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_BUSINESS_TELEPHONE_NUMBER:    
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[5].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[5].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[5].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_BUSINESS2_TELEPHONE_NUMBER:    
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[6].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[6].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[6].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_CAR_TELEPHONE_NUMBER:        
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[7].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[7].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[7].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_COMPANY_TELEPHONE_NUMBER:
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[8].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[8].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[8].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_EMAIL1_ADDRESS:                
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[9].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[9].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[9].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_EMAIL2_ADDRESS:                
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[10].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[10].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[10].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_EMAIL3_ADDRESS:                
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[11].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[11].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[11].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_HOME_TELEPHONE_NUMBER:        
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[12].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[12].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[12].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_HOME2_TELEPHONE_NUMBER:        
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[13].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[13].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[13].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_IM1_ADDRESS:                    
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[14].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[14].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[14].val.lpwstr);                            
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_IM3_ADDRESS:                    
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[15].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[15].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[15].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_MOBILE_TELEPHONE_NUMBER:        
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[16].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[16].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[16].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_PAGER_NUMBER:                
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[17].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[17].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[17].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_RADIO_TELEPHONE_NUMBER:        
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[18].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[18].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[18].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                &lt;span class="kwrd"&gt;case&lt;/span&gt; PIMPR_SMS:                            
                    &lt;span class="kwrd"&gt;if&lt;/span&gt;(prgPropvalUser[19].wFlags!=CEDB_PROPNOTFOUND)   
                    {   
                        &lt;span class="kwrd"&gt;if&lt;/span&gt;(LOWORD(prgPropvalUser[19].propid) == CEVT_LPWSTR)   
                        {
                            Log(prgPropvalUser[19].val.lpwstr);
                        }
                    }
                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
            } &lt;span class="rem"&gt;//switch&lt;/span&gt;
        }            
    }
    Log(TEXT(&lt;span class="str"&gt;"\r\n"&lt;/span&gt;));

    &lt;span class="rem"&gt;//success&lt;/span&gt;
    hr = S_OK;

Exit:
    LocalFree(prgPropvalUser); 
    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&lt;span class="rem"&gt;// ************************************************************************** &lt;/span&gt;
&lt;span class="rem"&gt;// Log &lt;/span&gt;
HRESULT Log(LPTSTR szLog)
{
    HRESULT hr = E_FAIL;
    hr = LogToFile(szLog, g_pszFilename);
    CHR(hr);

Exit:
    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}


&lt;span class="rem"&gt;// ************************************************************************** &lt;/span&gt;
&lt;span class="rem"&gt;// LogToFile &lt;/span&gt;
&lt;span class="rem"&gt;// Writes szLog into the file named pszFilename&lt;/span&gt;
HRESULT LogToFile(LPTSTR szLog, LPCTSTR pszFilename)
{
    HRESULT hr = E_FAIL;
    
    &lt;span class="rem"&gt;//Open the handle to the file (and create it if it doesn't exist&lt;/span&gt;
    HANDLE hFile = CreateFile(pszFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (INVALID_HANDLE_VALUE == hFile)
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;

    &lt;span class="rem"&gt;//Set the pointer at the end so that we can append szLog&lt;/span&gt;
    DWORD dwFilePointer = SetFilePointer(hFile, 0, NULL, FILE_END);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (0xFFFFFFFF == dwFilePointer)
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;

    &lt;span class="rem"&gt;//Write to the file&lt;/span&gt;
    DWORD dwBytesWritten = 0;
    BOOL bWriteFileRet = WriteFile(hFile, szLog, wcslen(szLog) * 2, &amp;amp;dwBytesWritten, NULL);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!bWriteFileRet)
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;

    &lt;span class="rem"&gt;//Flush the buffer&lt;/span&gt;
    BOOL bFlushFileBuffersRet = FlushFileBuffers(hFile);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!bFlushFileBuffersRet)
        &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;

    &lt;span class="rem"&gt;//Success&lt;/span&gt;
    hr = S_OK;

Exit:
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hFile)
    CloseHandle(hFile);

    &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;
}&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Cheers,&lt;br&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9647145" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/POOM/">POOM</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/PIMPR_5F00_SMARTPROP/">PIMPR_SMARTPROP</category></item><item><title>MAPI on Windows Mobile: Backup and Restore Mails</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/26/mapi-on-windows-mobile-backup-and-restore-mails.aspx</link><pubDate>Tue, 26 May 2009 09:49:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9641139</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9641139</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/26/mapi-on-windows-mobile-backup-and-restore-mails.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;Backup\Restore: is there a standard way?&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;How to programmatically mark messages so that they are downloaded at next sync&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;About linked attachments&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Yet another post about MAPI on Windows Mobile, it seems it became an common topic (not well covered over the web probably)… I recently worked with one of my colleagues in Redmond (&lt;font color="#ff0000"&gt;thanks Alex!&lt;strong&gt; &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt;&lt;/strong&gt;&lt;/font&gt;) about the following topic: how to use MAPI, if possible, to backup and restore e-mails sync-ed with a backend Exchange server (so by using ActiveSync MAPI Store). &lt;/p&gt;  &lt;p&gt;After some investigation about the possible combination of properties, we understood that if the message is partially downloaded (only the header, or partially downloaded, or without downloading attachments) the is no standard way on how to retrieve the rest of information, such as a link or so to click for downloading, after restoring the messages from a backup file – simply because the server at that point will consider the message as different from the initial one.&lt;/p&gt;  &lt;p&gt;At the beginning we imagined the problem was only with message body… and you can programmatically state if a message hasn't fully downloaded by looking at its properties MSGSTATUS_HEADERONLY, MSGSTATUS_PARTIAL_DOWNLOAD or MSGSTATUS_PARTIAL. So… how to programmatically mark messages so that they are downloaded at next sync? To mark a message for download, you should close the messaging application (tmail.exe), add the property &lt;strong&gt;MSGSTATUS_REMOTE_DOWNLOAD&lt;/strong&gt; to the message and then restart the messaging application (tmail.exe). Note that if you don't want the download to start immediately, then you should also modify the message's PR_CE_SUPPRESS_FETCH property in the same call to IItem::SetProps, accordingly to &lt;a href="http://msdn.microsoft.com/en-us/library/bb446137.aspx"&gt;documentation&lt;/a&gt;. I’m talking about something like:&lt;/p&gt;  &lt;blockquote&gt;   &lt;pre class="csharpcode"&gt;SPropValue rgProps[2];

rgProps[0].ulPropTag = PR_MSG_STATUS;
rgProps[0].Value.ul&amp;#160; = ulMsgStatus | MSGSTATUS_REMOTE_DOWNLOAD | MSGSTATUS_REMOTE_DOWNLOAD_ATTACH;
rgProps[1].ulPropTag = PR_CE_SUPPRESS_FETCH;
rgProps[1].Value.ul&amp;#160; = 1;

hr = pMsg-&amp;gt;SetProps(2, &amp;amp;rgProps, NULL);
CHR(hr);&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;




.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Note: MSGSTATUS_REMOTE_DOWNLOAD is not mentioned under the &lt;a href="http://msdn.microsoft.com/en-us/library/bb446051.aspx"&gt;&amp;quot;Windows Mobile Defined MAPI Properties&amp;quot; documentation&lt;/a&gt;, but you can see it defined in the related SDK's header file (&amp;quot;C:\Program Files (x86)\Windows Mobile 6 SDK\PocketPC\Include\Armv4i\cemapi.h&amp;quot;), so you can use it – in other words, the documentation is not complete on that page.&lt;/p&gt;

&lt;p&gt;Note that this may not be a complete solution, accordingly to &lt;strong&gt;Jay Ongg&lt;/strong&gt;'s answer to a comment on a Windows Mobile Dev Team's blog post (&lt;a href="http://blogs.msdn.com/windowsmobile/archive/2007/03/21/getting-started-with-mapi.aspx#2332771"&gt;here&lt;/a&gt;):&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&amp;quot;[...] &lt;i&gt;Regarding MSGSTATUS_PARTIAL, downloading a whole message is actually more complicated than just setting a flag.&amp;#160; Depending on the transport, you have to think about downloading attachments, which is done different for HTML mail vs normal attachments, I believe.&amp;#160; With that said, this might work... try setting the MSGSTATUS_REMOTE_DOWNLOAD flag to start out, and MSGSTATUS_REMOTE_DOWNLOAD_ATTACH as well.&lt;/i&gt;&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Indeed, as reported by Jay, the approach above resolved the problem for message bodies, but not for attachments! &lt;img alt="smile_sad" src="http://spaces.live.com/rte/emoticons/smile_sad.gif" /&gt; So… to recap: imagine you wish to copy a MAPI message that has a non-downloaded attachment into an unspecified backup storage; later, you copy the message from the backup store into the messaging store. What we expected was that the attachment to still be part of the message, but we found that the message's link to download the attachment is missing. &lt;u&gt;Is there any supported way so that the attachment remains in the message after performing the backup and then retrieving the message&lt;/u&gt;? The answer is simply “no”. &lt;strong&gt;Trying to copy (backup) the email message with a non-downloaded attachment will not work.&lt;/strong&gt; The link to the attachment will be lost, the attachment won’t be retrievable. The email and the non-downloaded attachment are associated with each other in Exchange, however the attachment is not actually a part of the message, so copying the message will not make a copy of the attachment. So the solution is to force the attachment to be downloaded before backing up the message (if user wants to maintain the attachment). Obviously saving the message and attachment on the device might not be a workable solution due to the storage space required… but, as usual, that depends on scenarios.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cheers! 
  &lt;br /&gt;~raffaele &lt;font color="#ff0000"&gt;&amp;amp; Alex&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9641139" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/MAPI/">MAPI</category></item><item><title>Microsoft released a HotFix for NETCF v3.5 on Windows Mobile: now you can use Web Services over SSL (without worrying about empty packets)</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/20/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-now-you-can-use-web-services-over-ssl-without-worrying-about-empty-packets.aspx</link><pubDate>Wed, 20 May 2009 18:38:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9632376</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9632376</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/20/microsoft-released-a-hotfix-for-netcf-v3-5-on-windows-mobile-now-you-can-use-web-services-over-ssl-without-worrying-about-empty-packets.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;System.Net.WebException: Unable to read data from the transport connection (System.Net.Sockets.SocketException: Unknown error (0x0))&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Use HotFix responsibly!&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Today my co-worker &lt;strong&gt;Carmelo &lt;/strong&gt;(thanks for sharing this! &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt;) found something that NETCF Developers were waiting since long time ago… a fixed version of NETCF CAB for Windows Mobile that would allow to address a bug about calling Web Services over SSL, which was greatly described by Andrew Arnott &lt;a href="http://blogs.msdn.com/andrewarnottms/archive/2007/11/19/why-net-compact-framework-fails-to-call-some-https-web-servers.aspx"&gt;here&lt;/a&gt; some time ago. The problem was that NETCF couldn’t work with Web Services over SSL that respond with empty encryption packets.&lt;/p&gt;  &lt;p&gt;The link to the hotfix is “&lt;strong&gt;&lt;a href="http://support.microsoft.com/kb/970549"&gt;FIX: A System.Net.WebException occurs when you run an application to send HTTPS Web requests to a server in an embedded device&lt;/a&gt;&lt;/strong&gt;”.&lt;/p&gt;  &lt;p&gt;Does this mean that also NETCF Developers can begin waiting for hotfixes for bugs? No, I personally think that this is a one-shot FIX coming from the NETCF Dev Team, because the problem was affecting so many customers around the globe… they simply deserve it. &lt;u&gt;And, again, Technical Support is your friend&lt;/u&gt;!! I don’t know the story behind this fix, however to convince the Dev Team to produce it I’m sure that a “certain” number of customers made their voice be heard through Service Requests… &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;WARNING&lt;/font&gt;&lt;/strong&gt;! Remember that analogously to every other hotfix you can ask to Technical Support about whatever Microsoft’s product, you should install it only if you're sure it’s for the problem you're being affected by. This is because a hotfix is meant to address a specific issue and has been tested precisely for that: it didn't go through the whole regression testing that it's usually done when packaging many hotfixes into a Service Pack. So, you don’t have to install this hotfix if you’re not interested on Web Services over SSL (sending empty packets).&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9632376" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/HotFix/">HotFix</category></item><item><title>O Service Request (about NETCF Memory Leak…), where art thoU?</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/20/o-service-request-about-netcf-memory-leak-where-art-thou.aspx</link><pubDate>Wed, 20 May 2009 10:45:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9631769</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9631769</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/20/o-service-request-about-netcf-memory-leak-where-art-thou.aspx#comments</comments><description>&lt;p&gt;I’m losing my expertise on this!! &lt;img alt="smile_confused" src="http://spaces.live.com/rte/emoticons/smile_confused.gif" /&gt; After &lt;a href="http://blogs.msdn.com/raffael/archive/2008/02/21/netcf-memory-leak-now-what.aspx"&gt;blogging about it&lt;/a&gt; to spread out the usual suggestions I was used to give to ISVs with troubles around memory, I simply quitted handling this kind of cases! Either v3.5 addressed all known bugs, either NETCF developers are getting skilled about things to do to prevent memory leaks… and I hope I’ve been of some little help! &lt;img alt="smile_shades" src="http://spaces.live.com/rte/emoticons/smile_shades.gif" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Cheers,   &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9631769" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Scatter+Thoughts/">Scatter Thoughts</category></item><item><title>Yet Another Technical Support’s added value: Engagement of Dev Teams</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/18/yet-another-technical-support-s-added-value-engagement-of-dev-teams.aspx</link><pubDate>Mon, 18 May 2009 09:55:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9624878</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9624878</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/18/yet-another-technical-support-s-added-value-engagement-of-dev-teams.aspx#comments</comments><description>&lt;ul&gt;   &lt;li&gt;&lt;em&gt;Some bloggers within Technical Support&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Example of added value given by Technical Support: Devs’ engagement&lt;/em&gt;&amp;#160; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Comments about NETCF on ARMv6 and ARMv7&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I often have to do some marketing for &lt;strong&gt;&lt;a href="http://blogs.msdn.com/raffael/archive/2008/05/14/get-what-you-paid-for.aspx"&gt;Microsoft Technical Support&lt;/a&gt;&lt;/strong&gt;, because it’s something everyone with questions or problems around Microsoft products must test out to understand its added value… Apart from myself &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt; we’re plenty of great people on all technologies: to name just a few, the following are representatives of the Technical Support – watch out their blogs, as they’re so plenty of “knowledge”! &lt;img alt="smile_nerd" src="http://spaces.live.com/rte/emoticons/smile_nerd.gif" /&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/carloc"&gt;Carlo Cardella&lt;/a&gt; – Internet Development &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/andreal"&gt;Andrea Liberatore&lt;/a&gt; – WCF, Web Services &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/carlos"&gt;Carlo Colombo&lt;/a&gt; – WCF, COM+, Distributed &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/tess"&gt;Tess Ferrandez&lt;/a&gt; – Internet Development &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/alejacma"&gt;Alejandro Campos Magencio&lt;/a&gt; – Cryptography, Security &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/johnbreakwell"&gt;John Breakwell&lt;/a&gt; – MSMQ &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/andrekl"&gt;Andreas Klein&lt;/a&gt; – IIS &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/dougste"&gt;Doug Stewart&lt;/a&gt; – Internet Development &lt;/li&gt;    &lt;li&gt;… &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There are many others I simply hadn’t yet the honor to work with, I simply couldn’t mention all of them!&lt;/p&gt;  &lt;p&gt;So, what is the added value I want to present today? This time I’d like to demonstrate that one of benefit of using Technical Support is that we may have a preferential engagement with the Product Groups, when necessary. This may differ in forms depending on the technology, but no doubt that we can engage the people who actually wrote the software. And an example of this happened to me some weeks ago…&lt;/p&gt;  &lt;p&gt;In that particular case who opened a Service Request was the OEM of a Windows CE 6.0-based device: you can say that I help ISVs, but this particular OEM was posing questions about developing a NETCF v3.5 application and wanted to receive support about Application Development rather than OS Customization through Platform Builder, therefore it fell in area of expertise. The device was based on a ARMv7 processor and was used as navigation system, hence it was heavily dependent on mathematical functions. On this processor, the OEM noticed that calling the same mathematical functions in a NETCF application required much more time than in a native application. The impression was that the native application leverages on the mathematical co-processor and asked if there’s any way to configure the NETCF Runtime to do the same either at application-layer or system-wide through an OS Customization. &lt;/p&gt;  &lt;p&gt;To make it short, in this case I had the pleasure to work directly with &lt;strong&gt;&lt;font color="#ff0000"&gt;Abhinaba Basu&lt;/font&gt;&lt;/strong&gt;, member of the NETCF Dev Team – see his blog posts as a result of this co-operation:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/abhinaba/archive/2009/03/27/net-compact-framework-and-arm-fpu.aspx"&gt;.NET Compact Framework and ARM FPU&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/abhinaba/archive/2009/04/06/floating-point-operations-in-net-compact-framework-on-wince-arm.aspx"&gt;Floating point operations in .NET Compact Framework on WinCE+ARM&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Apart from the deep explanations given by Abhinaba in his blog, questions and answers were:&lt;/p&gt;  &lt;p&gt;1- Is this an expected result?    &lt;br /&gt;&lt;em&gt;NetCF 3.5 lacks Armv6/v7 specific optimizations as it is based on Armv4i.&amp;#160; In particular we don’t leverage the FPU (Floating Point Unit), as NETCF does only floating point emulation.&amp;#160; Hence NetCF math functions will be much slower than doing the same in a native C++ program, which in contrast could be compiled to use the hardware FPU.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;2- Is ARMv7 a fully-supported architecture by the NETCF Runtime?    &lt;br /&gt;&lt;em&gt;NetCF 3.5 is based on Armv4i and Armv7 is backward compatible with Armv4i.&amp;#160; Hence all of the functionality of NetCF3.5 should work fine though may not yield optimal performance.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;3- Is there any possible way to achieve similar results with NETCF?    &lt;br /&gt;&lt;em&gt;Math routines could be written in native and the same could be PInvoked from managed code. Obviously you need to ensure that the cost of P/Invoke marshalling is not offsetting the saving in computation perf. A good idea to do that is to reduce the number of P/Invoke calls by bulking the computation.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;In particular, in that specific case the solution proposed was to develop a native DLL that internally invoked native math functions and exposes some “math expressions” to a .NET client. I mean a native DLL exposing f(a,b,c) which internally is like {[sin(a) x sin(b)] / cos(c)}. Moreover, if for example you know that you need to do 3 of these operations then create a buffer of inputs and outputs and push that to the native dll so that it can do all 3 in one go.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Cheers,    &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9624878" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Technical+Support/">Technical Support</category></item><item><title>MAPI GetOutgoingQueue not supported on Windows Mobile (so the Outbox?)</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/11/mapi-getoutgoingqueue-not-supported-on-windows-mobile-so-the-outbox.aspx</link><pubDate>Mon, 11 May 2009 17:00:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9602870</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9602870</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/11/mapi-getoutgoingqueue-not-supported-on-windows-mobile-so-the-outbox.aspx#comments</comments><description>&lt;p&gt;Recently I had to work on a sample code based on my previous post around MAPI that shows &lt;a href="http://blogs.msdn.com/raffael/archive/2008/09/08/mapi-on-windows-mobile-6-programmatically-retrieve-mail-body-sample-code.aspx"&gt;a possible way to extract the BODY of the mails in the Inbox folder of the ActiveSync account&lt;/a&gt;… this time I needed to grab a handle of the Outbox folder, and therefore I had to modify the function SaveMessagesFromStore of that post. Luckily the code was modularized enough… &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt; so, once I had the LPMAPIFOLDER pointer to the Outbox I could continue using basically the same code. I thought there was a MAPI Function similar to &lt;a href="http://msdn.microsoft.com/en-us/library/bb415653.aspx"&gt;IMsgStore::GetReceiveFolder&lt;/a&gt;, but found that quite many functions are not implemented in Windows Mobile 6 – see doc &lt;a href=" http://msdn.microsoft.com/en-us/library/bb159712.aspx"&gt;here&lt;/a&gt;. Luckily MAPI gives different ways to reach a goal, and in this particular case the code was based on the PR_IPM_OUTBOX_ENTRYID property of the MAPI store: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;        &lt;span class="rem"&gt;// Get the Outbox folder&lt;/span&gt;
        ULONG rgTags[] = {1, PR_IPM_OUTBOX_ENTRYID};
        LPSPropValue rgprops = NULL;
        ULONG ulValues = 0;
        hr = pStore-&amp;gt;GetProps((LPSPropTagArray) rgTags, MAPI_UNICODE, &amp;amp;ulValues, &amp;amp;rgprops);
        CHR(hr);
        
        cbEntryId = rgprops[0].Value.bin.cb;
        pEntryId = (LPENTRYID)rgprops[0].Value.bin.lpb;
        
        &lt;span class="rem"&gt;// We have the entryid of the Outbox folder, let's get the folder &lt;/span&gt;
        hr = pStore-&amp;gt;OpenEntry(cbEntryId, pEntryId, NULL, 0, &amp;amp;ulObjType, (LPUNKNOWN*)&amp;amp;pFolder); 
        CHR(hr); 
        
        &lt;span class="rem"&gt;//check &lt;/span&gt;
        CBR(ulObjType == MAPI_FOLDER);&lt;/pre&gt;
&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Cheers, 
  &lt;br /&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9602870" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/MAPI/">MAPI</category></item><item><title>The wrong approach to get a Contact’s last communication (EDB)</title><link>http://blogs.msdn.com/b/raffael/archive/2009/05/04/the-wrong-approach-to-get-a-contact-s-last-communication-edb.aspx</link><pubDate>Mon, 04 May 2009 18:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9585950</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9585950</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/05/04/the-wrong-approach-to-get-a-contact-s-last-communication-edb.aspx#comments</comments><description>&lt;P&gt;Have you ever played with EDB? I hadn’t… till the moment when I thought that what I needed was not implemented by the POOM and therefore I had to play with the “Contacts Database” contained in pim.vol... Unfortunately I understood only later that I was wrong… &lt;IMG alt=smile_sad src="http://spaces.live.com/rte/emoticons/smile_sad.gif" mce_src="http://spaces.live.com/rte/emoticons/smile_sad.gif"&gt; And luckily this was precisely the same query raised by in the MSDN Forum ‘&lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/0686b076-0c07-4c2a-b060-f71ccba90f34" mce_href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/0686b076-0c07-4c2a-b060-f71ccba90f34"&gt;How to get the information of a selected phonecall number?&lt;/A&gt;’ which I answered having fresh mind on the topic. &lt;/P&gt;
&lt;P&gt;Basically when opening a Contact summary card, you can see 2 info:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Firstly, what is the last time you called this contact by phone, and by using what phone# (mobile, work, home, etc): this is the item at the top, which is removed when user clears the Call Log history (&lt;EM&gt;off-topic:&lt;/EM&gt; &lt;EM&gt;have you ever tried to do programmatically clear the call log?&lt;/EM&gt;), and therefore no longer retrievable by the &lt;A href="http://msdn.microsoft.com/en-us/library/bb416387.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb416387.aspx"&gt;Phone Functions&lt;/A&gt; like PhoneOpenCallLog, PhoneGetCallLogEntry, etc -- masterly wrapped by the SDF's &lt;A href="http://www.opennetcf.com/library/sdf/html/ad0ec80e-3ebc-9402-7e30-9f1175bdecb7.htm" mce_href="http://www.opennetcf.com/library/sdf/html/ad0ec80e-3ebc-9402-7e30-9f1175bdecb7.htm"&gt;OpenNetcf.Phone.CallLog&lt;/A&gt; if you’re using a managed application. &lt;/LI&gt;
&lt;LI&gt;Secondly, what is the last &lt;EM&gt;way&lt;/EM&gt; user communicated with that contact: this is the selected item in the listview and can be phone\sms\mail etc, not necessarily phone. Well, this info is maintained also if user clears the call log history because it’s a property of the “Contacts Database” not of the “CLOG.EDB” database, and accordingly to what I wrote in the &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/0686b076-0c07-4c2a-b060-f71ccba90f34" mce_href="http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/0686b076-0c07-4c2a-b060-f71ccba90f34"&gt;MSDN Forum post above&lt;/A&gt;, it's something you can retrieve by using &lt;STRONG&gt;POOM&lt;/STRONG&gt;, related to the &lt;STRONG&gt;PIMPR_SMARTPROP&lt;/STRONG&gt; property -- see doc &lt;A href="http://msdn.microsoft.com/en-us/library/bb415504.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb415504.aspx"&gt;here&lt;/A&gt;, ‘Remarks’ section: “&lt;EM&gt;The Smart Property (PIMPR_SMARTPROP) is the Contact property that contains the property ID of the default communication mode. This becomes the phone number or address displayed on the second line of the two-line display in the Contact list view, and highlighted in the Contact summary tab.&lt;/EM&gt;”. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;So why on the earth did I mess up with EDB Functions against the “Contacts Database”? Purely because I wasn’t aware of such ad-hoc property!! And I ended up with a code that I want to share in case anyone is approaching to &lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/aa912256.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa912256.aspx"&gt;EDB Functions on Windows Mobile&lt;/A&gt;&lt;/STRONG&gt; as it shows some basic functionalities… as usual it’s provided as-is for didactic purposes and doesn’t contain enough error-check for example. &lt;/P&gt;&lt;PRE class=csharpcode&gt;    DWORD dwError = ERROR_SUCCESS;
    CEGUID guid;
    DWORD dwBufSize, dwIndex;
    BOOL fOk = FALSE;
    HANDLE hSession, hDatabase; 
    WORD wNumProps;
    CEOID oid = 0, ceoid;
    TCHAR szBuffer[MAXBUFFERSIZE] = {0};
    PCEPROPVAL lpProp;

    &lt;SPAN class=rem&gt;//Used for CEVT_STREAM:&lt;/SPAN&gt;
    HANDLE hStream;
    DWORD cbStream;
    LPBYTE pBuffer;
    DWORD cbActualRead;

    &lt;SPAN class=rem&gt;//1- Mount DB&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!CeMountDBVolEx(&amp;amp;guid, TEXT(&lt;SPAN class=str&gt;"\\pim.vol"&lt;/SPAN&gt;), NULL, OPEN_ALWAYS)) 
    {
        dwError = GetLastError();
        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
    }

    &lt;SPAN class=rem&gt;//2- Open Session&lt;/SPAN&gt;
    hSession = CeCreateSession(&amp;amp;guid);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (hSession == INVALID_HANDLE_VALUE) 
    {
        dwError = GetLastError();
        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
    }

    &lt;SPAN class=rem&gt;//3- Open Database&lt;/SPAN&gt;
    hDatabase = CeOpenDatabaseInSession(hSession, &amp;amp;guid, &amp;amp;oid, TEXT(&lt;SPAN class=str&gt;"Contacts Database"&lt;/SPAN&gt;), NULL, 0, NULL);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (hDatabase == INVALID_HANDLE_VALUE) 
    {
        dwError = GetLastError();
        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
    }

    &lt;SPAN class=rem&gt;//4- Iterate through records (there are other ways apart from waiting for ERROR_SEEK...)&lt;/SPAN&gt;
    dwIndex = 0;
    BOOL bFound = FALSE;
    &lt;SPAN class=kwrd&gt;while&lt;/SPAN&gt; (!bFound) 
    {

        &lt;SPAN class=rem&gt;//4.1- Set index into db&lt;/SPAN&gt;
        ceoid = CeSeekDatabaseEx(hDatabase, CEDB_SEEK_BEGINNING, dwIndex, 0, NULL);
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (ceoid == 0) 
        {
            dwError = GetLastError();
            &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
        }

        &lt;SPAN class=rem&gt;//4.2- Read records at index&lt;/SPAN&gt;
        wNumProps = 0;
        ceoid = CeReadRecordPropsEx(hDatabase, CEDB_ALLOWREALLOC, &amp;amp;wNumProps, NULL, (LPBYTE*)&amp;amp;lpProp, &amp;amp;dwBufSize, NULL);            
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (ceoid == 0) 
        {
            dwError = GetLastError();
            &lt;SPAN class=rem&gt;//if (dwError == 122) //ERR_INSUFFICIENT_BUFFER&lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;//e.g. increase buffer and re-try&lt;/SPAN&gt;
            
            &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
        }

        &lt;SPAN class=rem&gt;//4.3- Iterate through columns &lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt;( &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; i = 0; i &amp;lt; wNumProps; i++ )
        {
            &lt;SPAN class=rem&gt;//4.4- switch based on datatype (http://msdn.microsoft.com/en-us/library/aa917573.aspx) &lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;switch&lt;/SPAN&gt;( TypeFromPropID(lpProp[i].propid) )
            {
                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_I2:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"CEVT_I2"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.iVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_UI2:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"CEVT_UI2"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.uiVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_I4:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"CEVT_I4"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.lVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_UI4:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"CEVT_UI4"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.ulVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_LPWSTR:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s\t"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"CEVT_LPWSTR"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    OutputDebugString(lpProp[i].val.lpwstr);
                    OutputDebugString(_T(&lt;SPAN class=str&gt;"\r\n"&lt;/SPAN&gt;));
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_BLOB:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_BLOB"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%s: %li \r\n"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"Size in bytes"&lt;/SPAN&gt;), lpProp[i].val.blob.dwCount );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%s: 0x%x \r\n"&lt;/SPAN&gt;), _T(&lt;SPAN class=str&gt;"Buffer Address"&lt;/SPAN&gt;) ,lpProp[i].val.blob.lpb );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_BOOL:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_BOOL"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_R8:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_R8"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_STREAM:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_STREAM"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);

                    &lt;SPAN class=rem&gt;//OPEN STREAM&lt;/SPAN&gt;
                    hStream = CeOpenStream(hDatabase, lpProp[i].propid, GENERIC_READ);
                    cbStream = &lt;SPAN class=kwrd&gt;sizeof&lt;/SPAN&gt;(hStream);
                    
                    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (hStream == INVALID_HANDLE_VALUE )
                    {
                        dwError = GetLastError();
                        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
                    }
                    
                    &lt;SPAN class=rem&gt;//SET SEEK POSITION AT BEGINNING&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!CeStreamSeek(hStream, 0, STREAM_SEEK_SET, NULL))
                    {
                        dwError = GetLastError();
                        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
                    }

                    &lt;SPAN class=rem&gt;//READ STREAM&lt;/SPAN&gt;
                    pBuffer = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; BYTE[cbStream];
                    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!CeStreamRead(hStream, pBuffer, cbStream, &amp;amp;cbActualRead))
                    {
                        dwError = GetLastError();
                        delete [] pBuffer;
                        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
                    }

                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\tSTREAM: %s\r\n"&lt;/SPAN&gt;), (LPTSTR)(pBuffer));
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_RECID:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_RECID"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_AUTO_I4:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_AUTO_I4"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.lVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;case&lt;/SPAN&gt; CEVT_AUTO_I8:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"CEVT_AUTO_I8"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"\t%d \r\n"&lt;/SPAN&gt;), lpProp[i].val.lVal );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;

                &lt;SPAN class=kwrd&gt;default&lt;/SPAN&gt;:
                    _stprintf(szBuffer, _T(&lt;SPAN class=str&gt;"%d\t %d\t %s: %s \r\n"&lt;/SPAN&gt;), dwIndex, i, _T(&lt;SPAN class=str&gt;"Data Type"&lt;/SPAN&gt;),_T(&lt;SPAN class=str&gt;"Unknown"&lt;/SPAN&gt;) );
                    OutputDebugString(szBuffer);
                    &lt;SPAN class=rem&gt;//lpProp[i].val ??&lt;/SPAN&gt;
                    &lt;SPAN class=kwrd&gt;break&lt;/SPAN&gt;;
            } &lt;SPAN class=rem&gt;//switch&lt;/SPAN&gt;
        } &lt;SPAN class=rem&gt;//for&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;//move to next record&lt;/SPAN&gt;
        dwIndex++;
    } &lt;SPAN class=rem&gt;//while&lt;/SPAN&gt;


    &lt;SPAN class=rem&gt;//5- Unmount db&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!CeUnmountDBVol(&amp;amp;guid))
    {
        dwError = GetLastError();
        &lt;SPAN class=kwrd&gt;goto&lt;/SPAN&gt; Exit;
    }


Exit:
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (NULL != hDatabase) CloseHandle(hDatabase);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (NULL != hSession) CloseHandle(hSession);
    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (dwError == ERROR_SEEK) dwError = ERROR_SUCCESS; &lt;SPAN class=rem&gt;//ERROR_SEEK is expected to exit the while loop&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; dwError;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;~raffaele&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9585950" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/POOM/">POOM</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/EDB/">EDB</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/PIMPR_5F00_SMARTPROP/">PIMPR_SMARTPROP</category></item><item><title>FindWindowEx on Windows Mobile: not supported…</title><link>http://blogs.msdn.com/b/raffael/archive/2009/04/29/findwindowex-on-windows-mobile-not-supported.aspx</link><pubDate>Wed, 29 Apr 2009 11:45:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9575338</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9575338</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/04/29/findwindowex-on-windows-mobile-not-supported.aspx#comments</comments><description>&lt;p&gt;… so how can I grab the handle of a particular child window, considering that FindWindow retrieves all top-level windows? I worked on this when writing &lt;a href="http://blogs.msdn.com/raffael/archive/2009/01/08/disable-webbrowser-s-context-menu-in-netcf-applications.aspx"&gt;a previous post of mine&lt;/a&gt;, and got a wonderful comment from &lt;strong&gt;&lt;a href="http://www.paslatek.net"&gt;Lionel&lt;/a&gt;&lt;/strong&gt; (thanks again &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt;). Today I had to re-use that code, and found that something was missing and also the code required some enhancements… so here it is!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IntPtr FindChildWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; strChildClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; strChildWindowCaption, IntPtr hWndTopLevel)
        {
            IntPtr hwndCur = IntPtr.Zero;
            hwndCur = GetWindow(hWndTopLevel, (&lt;span class="kwrd"&gt;uint&lt;/span&gt;)GetWindowFlags.GW_CHILD);
            &lt;span class="kwrd"&gt;return&lt;/span&gt; RecurseFindWindow(strChildClassName, strChildWindowCaption, hwndCur);
        }

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;bool&lt;/span&gt; m_bFound = &lt;span class="kwrd"&gt;false&lt;/span&gt;;

        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; IntPtr RecurseFindWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; strChildClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; strChildWindowCaption, IntPtr hWndParent)
        {
            &lt;span class="rem"&gt;//bool bFound = false;&lt;/span&gt;
            IntPtr hwndCur = IntPtr.Zero;
            &lt;span class="kwrd"&gt;char&lt;/span&gt;[] chArWindowClass = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;char&lt;/span&gt;[32];
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (hWndParent == IntPtr.Zero)
                &lt;span class="kwrd"&gt;return&lt;/span&gt; IntPtr.Zero;
            &lt;span class="kwrd"&gt;else&lt;/span&gt;
            {
                &lt;span class="rem"&gt;//check if we got the searched class name&lt;/span&gt;
                GetClassName(hWndParent, chArWindowClass, 256);
                &lt;span class="kwrd"&gt;string&lt;/span&gt; strWndClass = &lt;span class="kwrd"&gt;new&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;(chArWindowClass);
                strWndClass = strWndClass.Substring(0, strWndClass.IndexOf(&lt;span class="str"&gt;'\0'&lt;/span&gt;));
                &lt;span class="kwrd"&gt;if&lt;/span&gt; (strWndClass.ToLower() == strChildClassName.ToLower())
                {
                    &lt;span class="rem"&gt;//check if we got the searched window name&lt;/span&gt;
                    &lt;span class="kwrd"&gt;int&lt;/span&gt; length = GetWindowTextLength(hWndParent);
                    StringBuilder sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; StringBuilder(length + 1);
                    GetWindowText(hWndParent, sb, sb.Capacity);
                    m_bFound = (sb.ToString().ToLower() == strChildWindowCaption.ToLower());
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (m_bFound)
                        &lt;span class="kwrd"&gt;return&lt;/span&gt; hWndParent;
                }
                &lt;span class="kwrd"&gt;else&lt;/span&gt;
                {
                    &lt;span class="rem"&gt;//recurse into first child&lt;/span&gt;
                    IntPtr hwndChild = GetWindow(hWndParent, (&lt;span class="kwrd"&gt;uint&lt;/span&gt;)GetWindowFlags.GW_CHILD);
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (hwndChild != IntPtr.Zero)
                        hwndCur = RecurseFindWindow(strChildClassName, strChildWindowCaption, hwndChild);
                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (!m_bFound)
                    {
                        IntPtr hwndBrother = IntPtr.Zero;
                        &lt;span class="rem"&gt;//enumerate each brother windows and recurse into&lt;/span&gt;
                        &lt;span class="kwrd"&gt;do&lt;/span&gt;
                        {
                            hwndBrother = GetWindow(hWndParent, (&lt;span class="kwrd"&gt;uint&lt;/span&gt;)GetWindowFlags.GW_HWNDNEXT);
                            hWndParent = hwndBrother;
                            &lt;span class="kwrd"&gt;if&lt;/span&gt; (hwndBrother != IntPtr.Zero)
                            {
                                hwndCur = RecurseFindWindow(strChildClassName, strChildWindowCaption, hwndBrother);
                                &lt;span class="kwrd"&gt;if&lt;/span&gt; (m_bFound)
                                    &lt;span class="kwrd"&gt;break&lt;/span&gt;;
                            }
                        }
                        &lt;span class="kwrd"&gt;while&lt;/span&gt; (hwndBrother != IntPtr.Zero);
                    }
                }
                &lt;span class="kwrd"&gt;return&lt;/span&gt; hwndCur;
            }
        }


        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr FindWindow(&lt;span class="kwrd"&gt;string&lt;/span&gt; _ClassName, &lt;span class="kwrd"&gt;string&lt;/span&gt; _WindowName);

        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr GetWindow(IntPtr hwnd, &lt;span class="kwrd"&gt;uint&lt;/span&gt; relationship);

        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; IntPtr SendMessage(IntPtr hWnd, &lt;span class="kwrd"&gt;int&lt;/span&gt; msg, &lt;span class="kwrd"&gt;int&lt;/span&gt; wParam, &lt;span class="kwrd"&gt;int&lt;/span&gt; lParam);

        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;, CharSet = CharSet.Unicode)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GetClassName(IntPtr hwnd, &lt;span class="kwrd"&gt;char&lt;/span&gt;[] windowClass, &lt;span class="kwrd"&gt;int&lt;/span&gt; maxText);

        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;, CharSet = CharSet.Unicode)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GetWindowTextLength(IntPtr hWnd);

        [DllImport(&lt;span class="str"&gt;&amp;quot;coredll.dll&amp;quot;&lt;/span&gt;, SetLastError = &lt;span class="kwrd"&gt;true&lt;/span&gt;, CharSet = CharSet.Unicode)]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; GetWindowText(IntPtr hWnd, StringBuilder lpString, &lt;span class="kwrd"&gt;int&lt;/span&gt; nMaxCount);

        [Flags]
        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;enum&lt;/span&gt; GetWindowFlags
        {
            GW_HWNDFIRST = 0,
            GW_HWNDLAST = 1,
            GW_HWNDNEXT = 2,
            GW_HWNDPREV = 3,
            GW_OWNER = 4,
            GW_CHILD = 5,
        }&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;

&lt;p&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9575338" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Win32/">Win32</category></item><item><title>Programmatically Discriminate between Upgrade or Uninstall of a CAB on Windows Mobile</title><link>http://blogs.msdn.com/b/raffael/archive/2009/04/22/programmatically-discriminate-between-upgrade-or-uninstall-of-a-cab-on-windows-mobile.aspx</link><pubDate>Wed, 22 Apr 2009 18:31:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9562504</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9562504</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/04/22/programmatically-discriminate-between-upgrade-or-uninstall-of-a-cab-on-windows-mobile.aspx#comments</comments><description>&lt;p&gt;Recently I've worked with a developer on an interesting issue I’ve not found any clue on the web about, and the solution is based on one of those details that you can &lt;em&gt;empirically&lt;/em&gt; retrieve but that there are not documented anywhere, therefore on future releases may change without any warning. This was for example what happened to the ClassName of NETCF applications... see Daniel Moth's post about this: &amp;quot;&lt;a href="http://www.danielmoth.com/Blog/2005/12/netcfagl.html" target="_blank"&gt;#NETCF_AGL_&lt;/a&gt;&amp;quot;. I’ve also discussed about this in a &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/c251a7c7-d063-4414-9557-b5ece54df591"&gt;MSDN Forum post&lt;/a&gt; I found interesting, where the topic was something like “&lt;em&gt;how to prevent the CLR to not allow a second instance of the same NETCF application to run on Windows Mobile&lt;/em&gt;”. As I probably wrote elsewhere, “undocumented” doesn’t mean “technically not achievable”: it means that Product Group may change it as it doesn’t have to be backward-compatible.&lt;/p&gt;  &lt;p&gt;In this case we had an application that may have been updated at a later time: the ISV was wondering if there’s any way in the setup.dll of application’s CAB to specify, during uninstallation, if the uninstall is taking place during a version-upgrade or if it's a pure uninstallation. This is because, for example, the application's installation copies also some large files that user no longer needs after the uninstall and therefore are deleted: but it still needs them if the user is uninstalling a former version of the app in order to install a newer one. I hope I've been clear... &lt;img alt="smile_confused" src="http://spaces.live.com/rte/emoticons/smile_confused.gif" /&gt; Things can get more complicated by the fact that the when you do an “upgrade” of the same ap&lt;/p&gt;  &lt;p&gt;Well... we found out that there's no documented and standard way to achieve the goal, so we had to be creative - as usual... &lt;img alt="Nerd" src="http://messenger.msn.com/MMM2006-04-19_17.00/Resource/emoticons/49_49.gif" /&gt; To understand how to operate, we needed to understand the actual flow when installing\uninstalling\upgrading (=installing the CAB of a newer version of the app while a older one is installed); moreover, we had to take care a particular condition, i.e. when upgrading the user is prompted with the message “&lt;em&gt;The previous version of… Select Ok to continue or cancel to quit&lt;/em&gt;” -- and here it comes handy the “undocumented but empirically retrievable” info, that I'm going to show in a minute.&lt;/p&gt;  &lt;p&gt;The regular flow when installing and uninstalling is:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Install:&lt;/strong&gt;       &lt;ol&gt;       &lt;li&gt;DLL_PROCESS_ATTACH – Setup.dll is loaded &lt;/li&gt;        &lt;li&gt;Install_Init &lt;/li&gt;        &lt;li&gt;Install_Exit &lt;/li&gt;        &lt;li&gt;DLL_PROCESS_DETACH – Setup.dll is unloaded &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Uninstall:&lt;/b&gt;       &lt;ol&gt;       &lt;li&gt;DLL_PROCESS_ATTACH – Setup.dll is loaded &lt;/li&gt;        &lt;li&gt;Uninstall_Init &lt;/li&gt;        &lt;li&gt;Uninstall_Exit &lt;/li&gt;        &lt;li&gt;DLL_PROCESS_DETACH – Setup.dll is unloaded &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;When upgrading, the flow is as follows:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;    &lt;li&gt;Install_Init &lt;/li&gt;    &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Message prompt to the user to confirm uninstall of previous version&lt;/b&gt;&lt;b&gt;&lt;/b&gt;       &lt;ul&gt;       &lt;li&gt;&lt;strong&gt;Select Ok: &lt;/strong&gt;          &lt;ol&gt;           &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded, *&lt;strong&gt;BUT&lt;/strong&gt;* &lt;em&gt;&lt;font color="#ff0000"&gt;the installer doesn’t know if we’re uninstalling because of a real uninstall or an upgrade&lt;/font&gt;&lt;/em&gt; &lt;/li&gt;            &lt;li&gt;Uninstall_Init &lt;/li&gt;            &lt;li&gt;Uninstall_Exit &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;            &lt;li&gt;Install_Init &lt;/li&gt;            &lt;li&gt;Install_Exit &lt;/li&gt;            &lt;li&gt;running the exec &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;        &lt;li&gt;&lt;b&gt;Select Cancel:&lt;/b&gt;           &lt;ol&gt;           &lt;li&gt;Nothing happens (setup.dll was already unloaded) &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So the problem is how to let the installer know that it’s uninstalling or upgrading… the idea I had was to modify the flow this way, based on the fact that when “upgrading”, the flow involves firstly a Install_Init and secondly a Uninstall_Init; in contrast when “uninstalling” the flow doesn’t involve a first step through Install_Init:&lt;/p&gt;  &lt;p&gt;&lt;b&gt;a. &lt;/b&gt;&lt;b&gt;Install &lt;/b&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Install_Init&lt;/font&gt;&lt;/strong&gt; (&lt;em&gt;&lt;font color="#ff0000"&gt;query if the app is already installed (through the Uninstall CSP) and set a registry key or whatever, e.g.[HKLM\UpgradeKey]Upgrade=0 if it was not installed and 1 viceversa&lt;/font&gt;&lt;/em&gt;) –&amp;gt; now: &lt;strong&gt;Upgrade=0&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;Install_Exit &lt;/li&gt;    &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;b. Upgrade:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;font color="#008080"&gt;Install_Init&lt;/font&gt;&lt;/strong&gt; (&lt;em&gt;&lt;font color="#ff0000"&gt;query if the app is already installed (through the Uninstall CSP) and set a registry key or whatever, e.g.[HKLM\UpgradeKey]Upgrade=0 if it was not installed and 1 viceversa&lt;/font&gt;&lt;/em&gt;) –&amp;gt; now: &lt;strong&gt;Upgrade=1&lt;/strong&gt; &lt;/li&gt;    &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;    &lt;li&gt;&lt;b&gt;Message prompt to the user to confirm uninstall of previous version&lt;/b&gt;       &lt;ul&gt;       &lt;li&gt;&lt;strong&gt;Select Ok: &lt;/strong&gt;          &lt;ol&gt;           &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;            &lt;li&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;Uninstall_Init&lt;/font&gt;&lt;/strong&gt; (&lt;em&gt;&lt;font color="#ff0000"&gt;QUERY [HKLM\UpgradeKey]Upgrade and act accordingly&lt;/font&gt;&lt;/em&gt;) –&amp;gt; now: &lt;strong&gt;Upgrade=1&lt;/strong&gt; (was just set by Install_Init at point 2. of the Upgrade flow, and then it can be set back to 0) &lt;/li&gt;            &lt;li&gt;Uninstall_Exit &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;            &lt;li&gt;Install_Init &lt;/li&gt;            &lt;li&gt;Install_Exit &lt;/li&gt;            &lt;li&gt;running the exec &lt;/li&gt;            &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;        &lt;li&gt;&lt;b&gt;Select Cancel:&lt;/b&gt;           &lt;ol&gt;           &lt;li&gt;Nothing happens (setup.dll was already unloaded) &lt;/li&gt;         &lt;/ol&gt;       &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;c. Uninstall&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;DLL_PROCESS_ATTACH – SetupDLL.dll is loaded &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;Uninstall_Init&lt;/font&gt;&lt;/strong&gt; (&lt;em&gt;&lt;font color="#ff0000"&gt;query if we’re upgrading by looking at the registry key&lt;/font&gt;&lt;/em&gt;) –&amp;gt; now: &lt;strong&gt;Upgrade=0 &lt;/strong&gt;(it wasn’t changed by anyone) &lt;/li&gt;    &lt;li&gt;Uninstall_Exit &lt;/li&gt;    &lt;li&gt;DLL_PROCESS_DETACH – SetupDLL.dll is unloaded &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;To conclude, the idea was to:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Install_Init creates the “Upgrade” registry key (or other info) and sets 0 if the application is NOT already installed and 1 viceversa. To check if an application is already installed I think I’ve already discussed once on the Uninstall Configuration Service Provider… yes, see &lt;a href="http://blogs.msdn.com/raffael/archive/2008/09/04/provisioning-the-uninstall-configuration-service-provider-fails-if-invoked-through-cab-or-cpf.aspx"&gt;this post&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Uninstall_Init checks the value of the key and act accordingly (just as an example, if that’s an “uninstall” then remove some files that are no longer used) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;HOWEVER… &lt;img alt="smile_confused" src="http://spaces.live.com/rte/emoticons/smile_confused.gif" /&gt; this approach had a problem… what happens if user answers “Cancel” to the prompt “&lt;em&gt;The previous version of… Select Ok to continue or cancel to quit&lt;/em&gt;”? Nobody can restore [HKLM\UpgradeKey]Upgrade to 0 after that Install_Init set it to 1, and future possible “Uninstalls” are considered as “Upgrades”! So basically the problem is when user firstly doesn't accept to uninstall the previous version during upgrade and then secondly she uninstalls the previous version on her own: when doing this second action, the uninstall procedure would find that the Upgrade registry key is set to 1 and therefore would consider an upgrade even if in reality it's an uninstall. &lt;/p&gt;  &lt;p&gt;So, next question was: &lt;strong&gt;is there any programmatic way to know if user selects “Cancel” when prompted about uninstalling previous version? &lt;/strong&gt;The only way I could think at was to get ahold of the WCELOAD.EXE process and invoke GetExitCodeProcess() API to retrieve its return value: the assumption was that it was different when user hits “Cancel”… it turned out that this is true, but this approach involved an external application to be launched for example in setup.dll’s DLL_PROCESS_ATTACH, that can monitor WCELOAD.EXE and check its return value during Uninstall phase… Why an external process? Because the prompt comes up EVEN BEFORE the setup.dll can handle Install_Init. &lt;/p&gt;  &lt;p&gt;The “undocumented but empirically retrievable” info I was mentioning at the beginning is precisely the return value of WCELOAD.EXE when user hits Cancel. As I said, not being documented it may change on future releases without any notice..&lt;/p&gt;  &lt;p&gt;And now some code please!!&lt;/p&gt;  &lt;p&gt;I’m talking about the following in setup.dll: &lt;/p&gt;  &lt;blockquote&gt;   &lt;div class="csharpcode"&gt;     &lt;pre class="alt"&gt;&lt;span class="preproc"&gt;#define&lt;/span&gt; DELETE_STR(s) \&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != s) \&lt;/pre&gt;

    &lt;pre class="alt"&gt;delete [] s;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;HINSTANCE g_hinstModule;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;BOOL APIENTRY DllMain(&lt;/pre&gt;

    &lt;pre class="alt"&gt;    HANDLE hModule, &lt;/pre&gt;

    &lt;pre&gt;    DWORD  ul_reason_for_call, &lt;/pre&gt;

    &lt;pre class="alt"&gt;    LPVOID lpReserved&lt;/pre&gt;

    &lt;pre&gt;    )&lt;/pre&gt;

    &lt;pre class="alt"&gt;{&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="rem"&gt;//MessageBox(NULL, TEXT(&amp;quot;Now attach the debugger&amp;quot;), TEXT(&amp;quot;Test&amp;quot;), MB_OK);&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;    &lt;span class="kwrd"&gt;switch&lt;/span&gt; (ul_reason_for_call)&lt;/pre&gt;

    &lt;pre class="alt"&gt;    {&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;case&lt;/span&gt; DLL_THREAD_ATTACH:&lt;/pre&gt;

    &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;case&lt;/span&gt; DLL_THREAD_DETACH:&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;case&lt;/span&gt; DLL_PROCESS_DETACH:&lt;/pre&gt;

    &lt;pre class="alt"&gt;            g_hinstModule = (HINSTANCE)hModule;&lt;/pre&gt;

    &lt;pre&gt;            &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;        &lt;span class="kwrd"&gt;case&lt;/span&gt; DLL_PROCESS_ATTACH:&lt;/pre&gt;

    &lt;pre class="alt"&gt;              g_hinstModule = (HINSTANCE)hModule;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//check if UpgCheck.exe is already available on device (1st time it won't, but in any case we don't need it)&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;              LPCWSTR pszFileNameWithPath = &lt;span class="kwrd"&gt;new&lt;/span&gt; TCHAR[MAX_PATH];&lt;/pre&gt;

    &lt;pre class="alt"&gt;              pszFileNameWithPath = TEXT(&lt;span class="str"&gt;&amp;quot;\\Windows\\UpgCheck.exe&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;              WIN32_FIND_DATA wfdFindFileData;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              HANDLE hFile = FindFirstFile(pszFileNameWithPath, &amp;amp;wfdFindFileData);&lt;/pre&gt;

    &lt;pre&gt;              &lt;span class="kwrd"&gt;if&lt;/span&gt;(hFile == INVALID_HANDLE_VALUE)&lt;/pre&gt;

    &lt;pre class="alt"&gt;              {&lt;/pre&gt;

    &lt;pre&gt;                            DELETE_STR(pszFileNameWithPath);&lt;/pre&gt;

    &lt;pre class="alt"&gt;                            &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;              }&lt;/pre&gt;

    &lt;pre class="alt"&gt;              FindClose(hFile);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//Launch external process that will monitor wceload.exe&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;              BOOL bRet;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              SHELLEXECUTEINFO sei = {0};&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              sei.cbSize = &lt;span class="kwrd"&gt;sizeof&lt;/span&gt;(sei);&lt;/pre&gt;

    &lt;pre&gt;              sei.nShow = SW_SHOWNORMAL; &lt;/pre&gt;

    &lt;pre class="alt"&gt;              sei.lpFile = pszFileNameWithPath;&lt;/pre&gt;

    &lt;pre&gt;              sei.lpParameters = TEXT(&lt;span class="str"&gt;&amp;quot; &amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre class="alt"&gt;              bRet = ShellExecuteEx(&amp;amp;sei);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//if (!bRet)&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;              &lt;span class="rem"&gt;//     MessageBox(NULL, TEXT(&amp;quot;Could not launch UpgCheck&amp;quot;), TEXT(&amp;quot;Test&amp;quot;), MB_OK);&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;              DELETE_STR(pszFileNameWithPath);&lt;/pre&gt;

    &lt;pre class="alt"&gt;              &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre&gt;    }&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="kwrd"&gt;return&lt;/span&gt; TRUE;&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And I’m talking about something similar in the wceload-monitor:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;int&lt;/span&gt; _tmain(&lt;span class="kwrd"&gt;int&lt;/span&gt; argc, _TCHAR* argv[])&lt;/pre&gt;

    &lt;pre&gt;{&lt;/pre&gt;

    &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;int&lt;/span&gt; &lt;span class="kwrd"&gt;const&lt;/span&gt; MAXBUF = 32;&lt;/pre&gt;

    &lt;pre&gt;       HRESULT hr = E_FAIL;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       HANDLE hProcess = NULL;&lt;/pre&gt;

    &lt;pre&gt;       BOOL bRes = FALSE;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       DWORD dwRes = 0;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       LPTSTR lpBuf = &lt;span class="kwrd"&gt;new&lt;/span&gt; TCHAR[MAXBUF];&lt;/pre&gt;

    &lt;pre&gt;       ZeroMemory(lpBuf, MAXBUF - 1);&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;       &lt;span class="rem"&gt;//retrieve process handle of wceload.exe, until it's found&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;do&lt;/span&gt;{&lt;/pre&gt;

    &lt;pre&gt;              hr = GetProcessHandleByName(TEXT(&lt;span class="str"&gt;&amp;quot;wceload.exe&amp;quot;&lt;/span&gt;), &amp;amp;hProcess);&lt;/pre&gt;

    &lt;pre class="alt"&gt;              CHR(hr);&lt;/pre&gt;

    &lt;pre&gt;              Sleep(1000);&lt;/pre&gt;

    &lt;pre class="alt"&gt;       } &lt;span class="kwrd"&gt;while&lt;/span&gt; (INVALID_HANDLE_VALUE == hProcess);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       &lt;span class="rem"&gt;//hr = LogToFile(TEXT(&amp;quot;\r\nwceload found!\r\n&amp;quot;), g_pszFilename);&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;       &lt;span class="rem"&gt;//CHR(hr);&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;       &lt;span class="rem"&gt;//retrieve wceload.exe exit code, until it exits&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;do&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre&gt;              Sleep(1000);&lt;/pre&gt;

    &lt;pre class="alt"&gt;              bRes = GetExitCodeProcess(hProcess, &amp;amp;dwRes);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;              &lt;span class="kwrd"&gt;if&lt;/span&gt; ( !bRes )&lt;/pre&gt;

    &lt;pre&gt;              {&lt;/pre&gt;

    &lt;pre class="alt"&gt;                     &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit; &lt;span class="rem"&gt;//GetLastError&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;              }&lt;/pre&gt;

    &lt;pre class="alt"&gt;       } &lt;span class="kwrd"&gt;while&lt;/span&gt; (STILL_ACTIVE == dwRes); &lt;/pre&gt;

    &lt;pre&gt;       &lt;/pre&gt;

    &lt;pre class="alt"&gt;       hr = StringCchPrintf(lpBuf, &lt;/pre&gt;

    &lt;pre&gt;              LocalSize(lpBuf) / &lt;span class="kwrd"&gt;sizeof&lt;/span&gt;(TCHAR),&lt;/pre&gt;

    &lt;pre class="alt"&gt;              TEXT(&lt;span class="str"&gt;&amp;quot;ExitCode %d&amp;quot;&lt;/span&gt;),&lt;/pre&gt;

    &lt;pre&gt;              dwRes); &lt;span class="rem"&gt;//2147754005 when user select Cancel (0x80042015)&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       CHR(hr);&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       hr = LogToFile(lpBuf, g_pszFilename);&lt;/pre&gt;

    &lt;pre&gt;       CHR(hr);      &lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;       &lt;span class="rem"&gt;//success&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;       hr = S_OK;&lt;/pre&gt;

    &lt;pre&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre class="alt"&gt;Exit:&lt;/pre&gt;

    &lt;pre&gt;       DELETE_STR(lpBuf);&lt;/pre&gt;

    &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;       &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;&lt;/pre&gt;

    &lt;pre class="alt"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Where the helper functions are:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;div class="csharpcode"&gt;
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="rem"&gt;// Function Name: GetProcessHandleByName&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;HRESULT GetProcessHandleByName (LPCTSTR pszProcessName, LPHANDLE phProcessHandle)&lt;/pre&gt;

      &lt;pre&gt;{&lt;/pre&gt;

      &lt;pre class="alt"&gt;       HRESULT hr = E_FAIL;&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (pszProcessName == NULL)&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (hSnapshot == INVALID_HANDLE_VALUE)&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       *phProcessHandle = NULL;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       PROCESSENTRY32 pe;&lt;/pre&gt;

      &lt;pre&gt;       pe.dwSize = &lt;span class="kwrd"&gt;sizeof&lt;/span&gt;(pe);&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (Process32First(hSnapshot, &amp;amp;pe))&lt;/pre&gt;

      &lt;pre class="alt"&gt;       {&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="kwrd"&gt;do&lt;/span&gt; {&lt;/pre&gt;

      &lt;pre class="alt"&gt;                     &lt;span class="rem"&gt;//log Exe name&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;                     hr = LogToFile(pe.szExeFile, g_pszFilename);&lt;/pre&gt;

      &lt;pre class="alt"&gt;                     CHR(hr);&lt;/pre&gt;

      &lt;pre&gt;                     hr = LogToFile(TEXT(&lt;span class="str"&gt;&amp;quot;\r\n&amp;quot;&lt;/span&gt;), g_pszFilename);&lt;/pre&gt;

      &lt;pre class="alt"&gt;                     CHR(hr);&lt;/pre&gt;

      &lt;pre&gt;                     &lt;/pre&gt;

      &lt;pre class="alt"&gt;                     &lt;span class="rem"&gt;//compare current Exe name with passed Process Name&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;                     &lt;span class="kwrd"&gt;if&lt;/span&gt; (lstrcmpi(pszProcessName, pe.szExeFile) == 0)&lt;/pre&gt;

      &lt;pre class="alt"&gt;                     {&lt;/pre&gt;

      &lt;pre&gt;                           &lt;span class="rem"&gt;//get the handle of the Exe name in case we reached the Exe we were looking for&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;                           *phProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;                           CloseHandle(hSnapshot);&lt;/pre&gt;

      &lt;pre&gt;                           &lt;span class="kwrd"&gt;return&lt;/span&gt; TRUE;&lt;/pre&gt;

      &lt;pre class="alt"&gt;                     }&lt;/pre&gt;

      &lt;pre&gt;              } &lt;span class="kwrd"&gt;while&lt;/span&gt; (Process32Next(hSnapshot, &amp;amp;pe));&lt;/pre&gt;

      &lt;pre class="alt"&gt;       }&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="rem"&gt;//Success&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;       hr = S_OK;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;Exit:&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hSnapshot)&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="rem"&gt;//UPDATE: thanks Vino!&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//Contrarily to desktop Win32, don't invoke CloseHandle() to close the snapshot call.&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="rem"&gt;//Desktop (http://msdn.microsoft.com/en-us/library/ms682489(VS.85).aspx): &lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//       &amp;quot;[...] To destroy the snapshot, use the CloseHandle function.&amp;quot;.&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="rem"&gt;//Windows CE\Mobile (http://msdn.microsoft.com/en-us/library/aa911386.aspx): &lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;              &lt;span class="rem"&gt;//       &amp;quot;[...] To close a snapshot, call the CloseToolhelp32Snapshot function.&amp;quot;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;              CloseToolhelp32Snapshot(hSnapshot);&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;&lt;/pre&gt;

      &lt;pre class="alt"&gt;}&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="rem"&gt;// **************************************************************************&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="rem"&gt;// Function Name: LogToFile &lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;HRESULT LogToFile(LPTSTR szLog, LPCTSTR pszFilename)&lt;/pre&gt;

      &lt;pre class="alt"&gt;{&lt;/pre&gt;

      &lt;pre&gt;       HRESULT hr = E_FAIL;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="rem"&gt;//Open the handle to the file (and create it if it doesn't exist&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       HANDLE hFile = CreateFile(pszFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (INVALID_HANDLE_VALUE == hFile)&lt;/pre&gt;

      &lt;pre class="alt"&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="rem"&gt;//Set the pointer at the end so that we can append szLog&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;       DWORD dwFilePointer = SetFilePointer(hFile, 0, NULL, FILE_END);&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (0xFFFFFFFF == dwFilePointer)&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="rem"&gt;//Write to the file&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       DWORD dwBytesWritten = 0;&lt;/pre&gt;

      &lt;pre&gt;       BOOL bWriteFileRet = WriteFile(hFile, szLog, wcslen(szLog) * 2, &amp;amp;dwBytesWritten, NULL);&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (!bWriteFileRet)&lt;/pre&gt;

      &lt;pre&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="rem"&gt;//Flush the buffer&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       BOOL bFlushFileBuffersRet = FlushFileBuffers(hFile);&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (!bFlushFileBuffersRet)&lt;/pre&gt;

      &lt;pre class="alt"&gt;              &lt;span class="kwrd"&gt;goto&lt;/span&gt; Exit;&lt;/pre&gt;

      &lt;pre&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="rem"&gt;//Success&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;       hr = S_OK;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;Exit:&lt;/pre&gt;

      &lt;pre class="alt"&gt;       &lt;span class="kwrd"&gt;if&lt;/span&gt; (NULL != hFile)&lt;/pre&gt;

      &lt;pre&gt;              CloseHandle(hFile);&lt;/pre&gt;

      &lt;pre class="alt"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;       &lt;span class="kwrd"&gt;return&lt;/span&gt; hr;&lt;/pre&gt;

      &lt;pre class="alt"&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/blockquote&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Hope this can help someone that absolutely has to distinguish if the application needs to be uninstalled or upgraded… but maybe the code above can find other meaningful usage! &lt;img alt="smile_nerd" src="http://spaces.live.com/rte/emoticons/smile_nerd.gif" /&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;/p&gt;

&lt;p&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9562504" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Windows+Mobile/">Windows Mobile</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/CAB/">CAB</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Win32/">Win32</category></item><item><title>Yet another post about Memory on Windows Mobile</title><link>http://blogs.msdn.com/b/raffael/archive/2009/03/24/yet-another-post-about-memory-on-windows-mobile.aspx</link><pubDate>Tue, 24 Mar 2009 18:11:39 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9504436</guid><dc:creator>RaffaeleLimosani</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/raffael/rsscomments.aspx?WeblogPostID=9504436</wfw:commentRss><comments>http://blogs.msdn.com/b/raffael/archive/2009/03/24/yet-another-post-about-memory-on-windows-mobile.aspx#comments</comments><description>&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;em&gt;Abhinaba’s blog&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;What’s new in Windows Mobile 6.1 and 6.5 around memory&lt;/em&gt; &lt;/li&gt;    &lt;li&gt;&lt;em&gt;Dynamic assembly unloading&lt;/em&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Again again again… I've discussed about Memory Management in &lt;a href="http://blogs.msdn.com/raffael/archive/2008/02/21/netcf-memory-leak-now-what.aspx"&gt;my very first post&lt;/a&gt;, which I suggest reading as it may help you on avoiding memory leaks and also improving memory management of your NETCF application. I’ve discussed about this other times, and to demonstrate how sensible this topic is, recently &lt;strong&gt;Abhinaba Basu&lt;/strong&gt; (Developer working on the &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa497273.aspx"&gt;.NET Compact Framework&lt;/a&gt; team) started &lt;a href="http://blogs.msdn.com/abhinaba "&gt;blogging&lt;/a&gt; about how the NETCF runtime handles memory: &lt;u&gt;thanks Abhinaba for all those details&lt;/u&gt;! &lt;img alt="smile_regular" src="http://spaces.live.com/rte/emoticons/smile_regular.gif" /&gt;&lt;/p&gt;  &lt;p&gt;So, why am I still talking about memory?? Because that’s the scarcest resource whose lack mobile developers have to face sometimes… btw let me digress: remember that Windows Mobile 6.1 and 6.5 help a lot ISVs on preventing OOM by modifying some details of the memory management, in particular to alleviate memory pressure on the process slot 0 basically (considering all the &amp;quot;drivers&amp;quot; that OEMs have come up with, which need to be loaded by device.exe process -- thus lowering the DLL Load point (in previous versions of the OS)). &lt;strong&gt;Doug Boling discussed about this &lt;/strong&gt;&lt;a href="http://bolingconsulting.com/blog/?p=4"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;Obviously a downside for this is that there’s less room for memory-mapped files in the Large Memory Area (LMA), but, apart from some special circumstances, this shouldn’t affect ISVs’ job, considering also that the LMA may be used by the OS and by other applications, therefore ISVs shouldn’t expect it to be totally available for their usage.&lt;/p&gt;  &lt;p&gt;Also, I’m still talking about memory because from time to time I got questions like “… &lt;em&gt;ok, so why don’t we dynamically load and unload assemblies?&lt;/em&gt;”. When this question arises, I usually answer suggesting to start by reading some quite old references:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/jasonz/archive/2004/05/31/145105.aspx"&gt;Why isn't there an Assembly.Unload method?&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/suzcook/archive/2003/07/08/57211.aspx"&gt;Unloading an Assembly&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;As documented &lt;a href="http://msdn.microsoft.com/en-us/library/56e3y6t8.aspx"&gt;here&lt;/a&gt;, “[…] &lt;em&gt;To unload managed code running in a process from memory so that memory can be used for other purposes, the host must unload the application domain in which the code is running. Individual assemblies or types cannot be unloaded.&lt;/em&gt;”. A quite complex “trick” (I wouldn’t really recommend for NETCF applications) is to create a new AppDomain (AppDomain.CreateDomain is supported by the NETCF) and load an assembly into it. The point is that as soon as you try to create objects from that assembly which is loaded into the new AppDomain, the assembly will be loaded into the current AppDomain. In order to solve this problem, you have to use a middle assembly, which is loaded into both the current AppDomain and the new AppDomain. Once the new AppDomain is unloaded, the assembly will be unloaded from the memory as well. However, the middle assembly, will stay in the memory. This approach might be known among DESKTOP .NET developers: I don’t know if anyone has ever tried to implement this within a NETCF application. &lt;/p&gt;  &lt;p&gt;IN ANY CASE, &lt;u&gt;assemblies are loaded into the system’s 1GB area, therefore the benefit would only be for PHYSICAL memory in this case (and for the JIT-ed code)&lt;/u&gt;. And we’re usually talking about roughly 25% of the size of the assembly. If you only need to have certain assemblies loaded at certain times, but never all at once then AppDomains can help; if you plan to have all your assemblies loaded simultaneously then AppDomains don’t offer much (for memory pressure relief).&lt;/p&gt;  &lt;p&gt;Note: what if an assembly depends on a native DLL (so loaded into the 32MB process slot) for example via P/Invoke? When the assembly is unloaded (by destroying the AppDomain), starting on NETCF v3.5, if the native DLL is used only by that assembly then its virtual memory is released from the process slot. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Cheers,&lt;/p&gt;  &lt;p&gt;~raffaele&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9504436" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/raffael/archive/tags/-NET+Compact+Framework/">.NET Compact Framework</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Troubleshooting/">Troubleshooting</category><category domain="http://blogs.msdn.com/b/raffael/archive/tags/Memory/">Memory</category></item></channel></rss>