<?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>Mark Schmidt's Abode : C/C++</title><link>http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx</link><description>Tags: C/C++</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Visual Studio Tip : AutoFormat Your Code</title><link>http://blogs.msdn.com/markhsch/archive/2008/01/10/visual-studio-tip-autoformat-your-code.aspx</link><pubDate>Fri, 11 Jan 2008 00:16:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7062594</guid><dc:creator>markhsch</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/7062594.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=7062594</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=7062594</wfw:comment><description>&lt;p&gt;Has this ever happened to you? You find some code on the Net so you copy and paste it into a source file within Visual Studio and notice that all the formatting is somehow messed up. For example. some lines might be indented while others are not.&lt;/p&gt; &lt;p&gt;To have Visual Studio fix it all up nice and tidy for you, select the text, hold CTRL and hit K followed by F (CTRL+K-F). What I usually do is do a CTRL-A to select all text then do the CTRL+K-F combo. Voila!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7062594" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/Misc/default.aspx">Misc</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category></item><item><title>.NET Sidebar Gadget Creator 2.0 Release</title><link>http://blogs.msdn.com/markhsch/archive/2007/08/09/net-sidebar-gadget-creator-2-0-release.aspx</link><pubDate>Fri, 10 Aug 2007 02:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4315540</guid><dc:creator>markhsch</dc:creator><slash:comments>17</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/4315540.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=4315540</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=4315540</wfw:comment><description>&lt;P&gt;Ok, I finally worked out most of the bugs (I hope). I'll post the link and follow up with some tutorials and Sidebar Gadget development using .NET.&lt;/P&gt;
&lt;P&gt;Here's the file...using the new SkyDrive Beta to host the file!!!&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;IFRAME style="BORDER-RIGHT: #dde5e9 1px solid; PADDING-RIGHT: 0px; BORDER-TOP: #dde5e9 1px solid; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 3px; BORDER-LEFT: #dde5e9 1px solid; WIDTH: 240px; PADDING-TOP: 0px; BORDER-BOTTOM: #dde5e9 1px solid; HEIGHT: 66px; BACKGROUND-COLOR: #ffffff" marginWidth=0 marginHeight=0 src="http://cid-d0866aae93a8e1aa.skydrive.live.com/embedrowdetail.aspx/Blog/NetSBHostCreator.exe" frameBorder=0 scrolling=no mce_src="http://cid-d0866aae93a8e1aa.skydrive.live.com/embedrowdetail.aspx/Blog/NetSBHostCreator.exe"&gt;&lt;/IFRAME&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4315540" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>.NET Sidebar Gadget Creator Update #2</title><link>http://blogs.msdn.com/markhsch/archive/2007/08/01/net-sidebar-gadget-creator-update-2.aspx</link><pubDate>Thu, 02 Aug 2007 03:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4179370</guid><dc:creator>markhsch</dc:creator><slash:comments>9</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/4179370.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=4179370</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=4179370</wfw:comment><description>&lt;P&gt;I had quite the breakthrough today. First off, I totally rewrote major portions of the .NET Sidebar Gadget Creator. It is now a wizard (photos below) that leads you through the steps to create a Vista Sidebar that uses .NET. Here are some of the changes (then I'll explain my breakthrough):&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You can now create any .NET type. You have the "option" of embedding a UserControl as the UI but it isn't required. Have a cool class you want to use. This makes it easy.&lt;/LI&gt;
&lt;LI&gt;A .gadget file is automatically created for you. More often than not, you will need to fiddle around with the final result, but just in case, I went ahead and added this feature anyway&lt;/LI&gt;
&lt;LI&gt;Reworked the entire act of copying to temp directory and registering assemblies...this is the breakthrough&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;As one reader pointed out, they noticed that I was simply copying the .NET assembly to the temp folder, creating the COM Interop registry keys to point to that location and having sidebar/Trident load it up from there. Was that the ideal solution? No way. He was right. It was the wrong way to do it. The benefit was that it allowed you to uninstall your gadget from the Sidebar UI, but left the file in the temp directory and orphaned registry keys.&lt;/P&gt;
&lt;P&gt;Here's the breakthrough. What if I told you that your .NET assemblies are not copyed over. They remain in your gadget directory. What if I also told you, you don't have to worry about registration. Yeah, so. You didn't with previous versions either right since my tool did it for you. Well, what if I told you that my tool also doesn't have to worry about registering your assemblies for COM interop? You heard right. Nothing about your assembly ever gets registered into the registry (i.e. I don't register your assembly for COM interop). However, you will still be loaded just fine and if you are a UserControl based object, you will be embedded. Additionally, you can still be safely uninstalled and all the gadget files will be deleted just fine.&lt;/P&gt;
&lt;P&gt;If you have a clue as to how I do this...feel free to submit your best guesses. I'm going to put the finishing touches on the tool and send it out. After that, I'll have a series of tutorials and an examination of the code (as well as my solution to how I solved this problem).&lt;/P&gt;
&lt;P&gt;Here's some pics:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179230/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179230/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179230/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179230/thumb.aspx"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179236/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179236/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179236/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179236/thumb.aspx"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179239/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179239/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179239/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179239/thumb.aspx"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179243/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179243/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179243/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179243/thumb.aspx"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179246/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179246/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179246/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179246/thumb.aspx"&gt;&lt;/A&gt; &lt;A href="http://blogs.msdn.com/photos/markhsch/images/4179256/original.aspx" target=_blank mce_href="http://blogs.msdn.com/photos/markhsch/images/4179256/original.aspx"&gt;&lt;IMG src="http://blogs.msdn.com/photos/markhsch/images/4179256/thumb.aspx" border=0 mce_src="http://blogs.msdn.com/photos/markhsch/images/4179256/thumb.aspx"&gt;&lt;/A&gt; &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4179370" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>Hosting .NET Runtime in C++ Tip o' the day or "Where is IAppDomainSetup?"</title><link>http://blogs.msdn.com/markhsch/archive/2007/07/31/hosting-net-runtime-in-c-tip-o-the-day-or-where-is-iappdomainsetup.aspx</link><pubDate>Wed, 01 Aug 2007 02:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4155337</guid><dc:creator>markhsch</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/4155337.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=4155337</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=4155337</wfw:comment><description>&lt;P&gt;Are you hosting the .NET runtime and trying to create another AppDomain? Notice that you need to call CreateDomainSetup and cast the IUnknown to&amp;nbsp;IAppDomainSetup to set properties? Notice also that IAppDomainSetup isn't defined in mscoree.h? Add the following (stdafx.h or anywhere else):&lt;/P&gt;&lt;FONT color=#0000ff size=2&gt;
&lt;P&gt;#import&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&amp;lt;mscorlib.tlb&amp;gt;&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;raw_interfaces_only&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;no_smart_pointers&lt;/FONT&gt;&lt;B&gt;&lt;FONT size=2&gt; &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;high_property_prefixes&lt;/FONT&gt;&lt;FONT size=2&gt;(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"_get"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"_put"&lt;/FONT&gt;&lt;FONT size=2&gt;,&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"_putref"&lt;/FONT&gt;&lt;FONT size=2&gt;) &lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;then you can say:&lt;/P&gt;&lt;FONT color=#010001 size=2&gt;
&lt;P&gt;CComPtr&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;lt;&lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;mscorlib&lt;/FONT&gt;&lt;FONT size=2&gt;::&lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;IAppDomainSetup&lt;/FONT&gt;&lt;FONT size=2&gt;&amp;gt; &lt;/FONT&gt;&lt;FONT color=#010001 size=2&gt;pAppDomainSetup&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;Ta da!&lt;/P&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4155337" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category></item><item><title>.NET based Sidebar gadget problem solved!</title><link>http://blogs.msdn.com/markhsch/archive/2007/06/26/activex-based-sidebar-gadget-problem-solved.aspx</link><pubDate>Tue, 26 Jun 2007 19:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3548444</guid><dc:creator>markhsch</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/3548444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=3548444</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=3548444</wfw:comment><description>&lt;P&gt;Ok, I just ran a test with some new code that creates an .NETbased sidebar gadget and I was able to get&amp;nbsp;the&amp;nbsp;dll&amp;nbsp;unloaded from the sidebar process so it can uninstall successfully! This is good news for all the people that can't seem to get around this issue (and there's a few of you). I'll get going on a solution and post the results here. If you want to be emailed when its ready, just ping me and I'll add you to a list.&lt;/P&gt;
&lt;P&gt;Want a hint as to how I solved it? Take a look at this post's tags :-)&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3548444" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/.NET/default.aspx">.NET</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category><category domain="http://blogs.msdn.com/markhsch/archive/tags/Cool+Stuff/default.aspx">Cool Stuff</category></item><item><title>XML to COM Object Property Mapping</title><link>http://blogs.msdn.com/markhsch/archive/2004/08/24/219683.aspx</link><pubDate>Tue, 24 Aug 2004 19:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:219683</guid><dc:creator>markhsch</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/markhsch/comments/219683.aspx</comments><wfw:commentRss>http://blogs.msdn.com/markhsch/commentrss.aspx?PostID=219683</wfw:commentRss><wfw:comment>http://blogs.msdn.com/markhsch/rsscomments.aspx?PostID=219683</wfw:comment><description>&lt;p&gt;&lt;font face="Verdana" size="2"&gt;I'm copying this entry that I posted on my old personal blog so I don't lose it.&amp;nbsp; Note that if you read it, convert it to past tense since I wrote it while working for HP.&amp;nbsp; If I remember correctly, the code was the result of browsing through ITypeInfo docs all over the net.&amp;nbsp; Enjoy.&amp;nbsp; One more thing, this code will make you appreciate the Reflection API in .NET even more.&lt;/font&gt;&lt;/p&gt; &lt;p&gt; &lt;hr id="null" /&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana" size="2"&gt;I have various function nuggets that have followed me around like a lost sick puppy over the years and this is one of my most recent.&amp;nbsp; Since I work with a UI architecture that is very dynamic in nature and extremely plugin-oriented, I need to have a set of functions to explore the type information of objects and allow me to dynamically call methods and properties.&amp;nbsp;Here is an example of such a function.&amp;nbsp; Let's say you had some XML that looked something like:&lt;br /&gt;&lt;/font&gt;&lt;font color="#008080" size="2"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;font size="2"&gt;&amp;lt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#800000"&gt;Object&lt;/font&gt;&lt;font color="#ff0000"&gt; type&lt;/font&gt;&lt;font color="#0000ff"&gt;='&lt;/font&gt;Object.ProgID&lt;font color="#0000ff"&gt;'&lt;/font&gt;&lt;font color="#ff0000"&gt; prop1&lt;/font&gt;&lt;font color="#0000ff"&gt;='&lt;/font&gt;XYZ&lt;font color="#0000ff"&gt;'&lt;/font&gt;&lt;font color="#ff0000"&gt; prop2&lt;/font&gt;&lt;font color="#0000ff"&gt;='&lt;/font&gt;true&lt;font color="#0000ff"&gt;'&lt;/font&gt;&lt;font color="#ff0000"&gt; prop3&lt;/font&gt;&lt;font color="#0000ff"&gt;='&lt;/font&gt;43&lt;font color="#0000ff"&gt;'&lt;/font&gt;&lt;font color="#ff0000"&gt; prop4&lt;/font&gt;&lt;font color="#0000ff"&gt;='&lt;/font&gt;3.14159&lt;font color="#0000ff" size="1"&gt;'/&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Verdana" color="#000000" size="2"&gt;This is just an example but just by looking you can see that it defines a COM object (with the progID in the type attribute) with several different properties of varying data types (string, boolean, integer, float).&amp;nbsp; The first thing you need to do is obviously parse the relavent data out.&amp;nbsp; For instance, the parser finds a new &lt;em&gt;Object&lt;/em&gt; tag, grabs the &lt;em&gt;type &lt;/em&gt;attribute and does a &lt;em&gt;CoCreateInstance &lt;/em&gt;to create the COM object (I'll leave that as an exercise for the reader...unless someone really doesn't know how to do it).&amp;nbsp; The parser then enumerates through each attribute grabbing 2 strings, the attribute name and the attribute value.&amp;nbsp; The parser doesn't need to worry about doing any type coercion (the method that follows does it for you).&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Verdana" color="#000000" size="2"&gt;So, at this point a COM object has been created and the parser is enumerating each attribute which corresponds to an actual property name in the COM object.&amp;nbsp; Here's the method that given a instance of a COM object, the property name (string) and the property value (string), calls the correct property setter on the object (criticism is expected but keep in mind the code is still rough since I'm still in implementation phase of the UI engine):&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff" size="1"&gt;&lt;font color="#000000" size="2"&gt;HRESULT CSomeClass::SetObjectProperty( IDispatch* pObject, BSTR propertyName, BSTR propertyValue )&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; USES_CONVERSION;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; HRESULT hr = S_OK;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISPID dispID = 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPEATTR* typeAttr;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UINT puArgError;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// get ITypeInfo from object&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ITypeInfo* pTypeInfo;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hr = pObject-&amp;gt;GetTypeInfo( 0, 0, &amp;amp;pTypeInfo );&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;( FAILED(hr) )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LogMsg( 1, (1, "ERROR:Unable to get type info for pipeline object. Ensure that COM_MAP contains: COM_INTERFACE_ENTRY2( IDispatch, IMainInterfaceName )"));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;return&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; FALSE;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// get type attributes (# functions e.g.)&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;GetTypeAttr(&amp;amp;typeAttr);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;for&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;( WORD iFunction = 0; iFunction &amp;lt; typeAttr-&amp;gt;cFuncs; iFunction++ ) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FUNCDESC* funcDesc;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CComBSTR methodName;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CComVariant vPropValue;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// get function description info&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hr = pTypeInfo-&amp;gt;GetFuncDesc( iFunction, &amp;amp;funcDesc );&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font size="2"&gt;&lt;span class="comment"&gt;&lt;font color="#008000"&gt;// make sure its a propput function&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;( funcDesc-&amp;gt;invkind != INVOKE_PROPERTYPUT &amp;amp;&amp;amp; funcDesc-&amp;gt;invkind != INVOKE_PROPERTYPUTREF )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;ReleaseFuncDesc( funcDesc );&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;continue&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// get method name&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; hr = pTypeInfo-&amp;gt;GetDocumentation(funcDesc-&amp;gt;memid, &amp;amp;methodName, 0, 0, 0);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;( FAILED(hr) ) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;ReleaseFuncDesc( funcDesc ); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;continue&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font size="2"&gt;&lt;span class="comment"&gt;&lt;font color="#008000"&gt;// check to make sure we have the right property&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;( CString(methodName).CompareNoCase(CString(propertyName )) != 0 )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;continue&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// the dispid&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispID = funcDesc-&amp;gt;memid;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font size="2"&gt;&lt;span class="comment"&gt;&lt;font color="#008000"&gt;// at this point we found the correct property function to call&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// now we need to build the VARIANT arg&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vPropValue = propertyValue;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vPropValue.ChangeType( funcDesc-&amp;gt;lprgelemdescParam[0].tdesc.vt );&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font size="2"&gt;&lt;span class="comment"&gt;&lt;font color="#008000"&gt;// build dispparams&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// NOTE: PRB: Error 0x80020004 When Setting a Property (http://support.microsoft.com/support/kb/articles/q175/6/18.asp)&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font color="#000000" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISPPARAMS dispParams;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DISPID dispidNamed = DISPID_PROPERTYPUT;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispParams.rgvarg = NULL;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispParams.rgdispidNamedArgs = &amp;amp;dispidNamed;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispParams.rgvarg = &amp;amp;vPropValue;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispParams.cArgs = 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispParams.cNamedArgs = 1; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// invoke function (which is the propput method)&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HRESULT hr = pTypeInfo-&amp;gt;Invoke( pObject, dispID, funcDesc-&amp;gt;invkind, &amp;amp;dispParams, NULL, NULL, &amp;amp;puArgError );&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;if&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;( FAILED(hr) )&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="comment"&gt;&lt;font color="#008000" size="2"&gt;// error setting property&lt;br /&gt;&lt;/font&gt;&lt;/span&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LogMsg( 1, (1, "Cannot set property \"%s\". hr=0x%x", OLE2T(methodName), hr ));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;ReleaseFuncDesc(funcDesc);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;else&lt;/span&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;ReleaseFuncDesc(funcDesc);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pTypeInfo-&amp;gt;Release();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span class="keyword"&gt;return&lt;/span&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; TRUE;&lt;br /&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Verdana" color="#000000" size="2"&gt;I commented the different sections of the method so it should all be pretty clear.&amp;nbsp; I have several variations that exist but essentially do the same thing. For instance, one variation uses a hashtable of property name -&amp;gt; property values so I don't have to repeatedly call this method over and over again for each property.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font color="#0000ff"&gt;&lt;font face="Verdana" color="#000000" size="2"&gt;There you have it.&amp;nbsp; My first code contribution.&amp;nbsp; I actually have another method that is way cooler than this one.&amp;nbsp; It basically accepts a COM object and a list of property name/property value pairs and calls a method.&amp;nbsp; Those name/value pairs are the parameters to the COM object's method.&amp;nbsp; The cool thing is that the list of pairs can be a) all strings and the method will change the types correctly and b) in any order (i.e. the name/value pairs do not have to match the order of the parameter list for the method. The dynamic method call method will order them and convert types for you).&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;/p&gt;&lt;/font&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=219683" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/markhsch/archive/tags/C_2F00_C_2B002B00_/default.aspx">C/C++</category></item></channel></rss>