<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Join Them</title>
	<atom:link href="http://possemeeg.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://possemeeg.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sat, 29 Oct 2011 14:00:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='possemeeg.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Join Them</title>
		<link>http://possemeeg.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://possemeeg.wordpress.com/osd.xml" title="Join Them" />
	<atom:link rel='hub' href='http://possemeeg.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Reg Edit &#8211; take ownership &#8211; create explorer meny</title>
		<link>http://possemeeg.wordpress.com/2011/10/29/reg-edit-take-ownership-create-explorer-meny/</link>
		<comments>http://possemeeg.wordpress.com/2011/10/29/reg-edit-take-ownership-create-explorer-meny/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 14:00:37 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/?p=42</guid>
		<description><![CDATA[Found these reg settings that are very useful and didn't know where to put them for future reference. So here they are. Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\runas] @="Take Ownership" "NoWorkingDirectory"="" [HKEY_CLASSES_ROOT\*\shell\runas\command] @="cmd.exe /c takeown /f \"%1\" &#38;&#38; icacls \"%1\" /grant administrators:F" "IsolatedCommand"="cmd.exe /c takeown /f \"%1\" &#38;&#38; icacls \"%1\" /grant administrators:F" [HKEY_CLASSES_ROOT\Directory\shell\runas] @="Take Ownership" [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=42&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<pre>Found these reg settings that are very useful and didn't know where to put them for future reference.  So here they are.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" &amp;&amp; icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" &amp;&amp; icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y &amp;&amp; icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y &amp;&amp; icacls \"%1\" /grant administrators:F /t"</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=42&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2011/10/29/reg-edit-take-ownership-create-explorer-meny/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>WPF Screen Resolution in Pixels</title>
		<link>http://possemeeg.wordpress.com/2009/04/07/wpf-screen-resolution-in-pixels/</link>
		<comments>http://possemeeg.wordpress.com/2009/04/07/wpf-screen-resolution-in-pixels/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 18:22:40 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2009/04/07/wpf-screen-resolution-in-pixels/</guid>
		<description><![CDATA[I needed my WPF controls size in pixels to retrieve the correct sized image from a web service.&#160; The answer hit me one night and it’s very simple: Create a known size image (say 100 x 100 pixels), put it in a image control on some bit of WPF screen (Hidden not collapsed), ensure no [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=34&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I needed my WPF controls size in pixels to retrieve the correct sized image from a web service.&#160; The answer hit me one night and it’s very simple:</p>
<p>Create a known size image (say 100 x 100 pixels), put it in a image control on some bit of WPF screen (Hidden not collapsed), ensure no stretching by putting Stretch=None and a non-stretch value for both Horizontal and Vertical alignment and make the calculation from the Image controls actual width and height.</p>
<p>This bit of xaml shows what I did: </p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">Grid</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Image</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;A100x100ImageControl&quot;</span>
    <span class="attr">Source</span><span class="kwrd">=&quot;/images/100x100.jpg&quot;</span> <span class="attr">Stretch</span><span class="kwrd">=&quot;None&quot;</span>
        <span class="attr">HorizontalAlignment</span><span class="kwrd">=&quot;Left&quot;</span> <span class="attr">VerticalAlignment</span><span class="kwrd">=&quot;Top&quot;</span>
        <span class="attr">Visibility</span><span class="kwrd">=&quot;Hidden&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Image</span> <span class="attr">x:Name</span><span class="kwrd">=&quot;ImageControl&quot;</span> <span class="attr">Stretch</span><span class="kwrd">=&quot;Uniform&quot;</span><span class="kwrd">/&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">Grid</span><span class="kwrd">&gt;</span></pre>
<p>A calculation with look something like this:</p>
<p>(In my case I wrapped it up in a UserControl with SizeTarget, a bound property, being a specific interface with just width and height that can be implemented elsewhere.)</p>
</p>
<pre class="csharpcode">SizeTarget.PixelWidth = (<span class="kwrd">int</span>)Math.Truncate(ActualWidth * 100 /
                A100x100ImageControl.ActualWidth);</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=34&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2009/04/07/wpf-screen-resolution-in-pixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting listening ports and addresses programmatically</title>
		<link>http://possemeeg.wordpress.com/2007/11/10/getting-listening-ports-and-addresses-programmatically/</link>
		<comments>http://possemeeg.wordpress.com/2007/11/10/getting-listening-ports-and-addresses-programmatically/#comments</comments>
		<pubDate>Sat, 10 Nov 2007 09:31:06 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Sockets]]></category>
		<category><![CDATA[Windows API]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/11/10/getting-listening-ports-and-addresses-programmatically/</guid>
		<description><![CDATA[My problem: A program was using 127.0.0.2 (an alias for 127.0.0.1) to make a local connection on a specific port. However, one Windows 2003 server box was configured so that this port was being listened to on a specific network adapter (and hence a specific IP address). Hence, my local connection failed even though the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=32&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>My problem: A program was using 127.0.0.2 (an alias for 127.0.0.1) to make a local connection on a specific port. However, one Windows 2003 server box was configured so that this port was being listened to on a specific network adapter (and hence a specific IP address). Hence, my local connection failed even though the port was open for listening.</p>
<p>Background: Type &#8220;netstat -p tcp -a -n&#8221; at the command prompt to get details of listening ports. The &#8220;Local Address&#8221; is adapter specific; &#8220;0.0.0.0&#8243; means it&#8217;s listening on all adapters (thus allowing connections to 127.0.0.1). In the case of this 2003 box, the port I wanted was specific to a particular IP address (adapter).</p>
<p>So, my program needed to connect to the adapter specific IP address and not 127.0.0.1. This is how to get the IP addresses and ports they&#8217;re listening on:</p>
<p><code><br />
void DoItAgain()<br />
{<br />
   DWORD err;<br />
   DWORD size = 0;<br />
   // first get the size of the buffer required<br />
   if((err=GetTcpTable (0,&amp;size,FALSE))!=ERROR_INSUFFICIENT_BUFFER)<br />
   {<br />
      std::cerr &lt;&lt; "Error " &lt;&lt; err &lt;&lt;<br />
         " getting tcp table size." &lt;&lt; std::endl;<br />
      return;<br />
   }<br />
   // next get the table<br />
   std::vector buf(size);<br />
   MIB_TCPTABLE *tbl = reinterpret_cast(&amp;(*buf.begin()));<br />
   if((err=GetTcpTable(tbl,&amp;size,FALSE))!=NO_ERROR)<br />
   {<br />
      std::cerr &lt;&lt; "Error " &lt;&lt; err &lt;&lt;<br />
         " getting tcp table." &lt;&lt; std::endl;<br />
      return;<br />
   }<br />
   // iterate through the entries<br />
   for (DWORD dw = 0; dw &lt; tbl-&gt;dwNumEntries; ++dw)<br />
   {<br />
      if(tbl-&gt;table[dw].dwState == MIB_TCP_STATE_LISTEN)<br />
      {<br />
         in_addr ad;<br />
         ad.S_un.S_addr = tbl-&gt;table[dw].dwLocalAddr;<br />
         std::cout &lt;&lt; "Listening " &lt;&lt; inet_ntoa(ad) &lt;&lt;<br />
            ", port " &lt;&lt; ntohs(tbl-&gt;table[dw].dwLocalPort) &lt;&lt; std::endl;<br />
      }<br />
   }<br />
}<br />
</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=32&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/11/10/getting-listening-ports-and-addresses-programmatically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>System.Drawing.Icon and embedded rersources</title>
		<link>http://possemeeg.wordpress.com/2007/09/06/systemdrawingicon-and-embedded-rersources/</link>
		<comments>http://possemeeg.wordpress.com/2007/09/06/systemdrawingicon-and-embedded-rersources/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 14:15:00 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/09/06/systemdrawingicon-and-embedded-rersources/</guid>
		<description><![CDATA[To use an icon resource embedded into your assemply:  1) Add icon to project and make it an &#8220;Embedded Resource&#8221; type (no need to copy to output directory). 2) Construct your System.Drawing.Icon like this: new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyShinyApp.hammer.ico")); Where MyShinyApp is the value specified in &#8220;Default namespace&#8221; property of your project (Application tab of project properties) and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=31&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To use an icon resource embedded into your assemply: </p>
<p>1) Add icon to project and make it an &#8220;Embedded Resource&#8221; type (no need to copy to output directory).</p>
<p>2) Construct your System.Drawing.Icon like this:</p>
<p><code><br />
new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyShinyApp.hammer.ico"));<br />
</code></p>
<p>Where MyShinyApp is the value specified in &#8220;Default namespace&#8221; property of your project (Application tab of project properties) and hammer.ico is the name of your icon.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/31/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/31/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=31&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/09/06/systemdrawingicon-and-embedded-rersources/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>Minimize to tray icon in WPF</title>
		<link>http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/</link>
		<comments>http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/#comments</comments>
		<pubDate>Thu, 06 Sep 2007 10:32:23 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/</guid>
		<description><![CDATA[I had to do a bit of searching so, here&#8217;s how to minimize your WPF app to a tray icon.  Assume your window is called Window1 for the code below.  Trap Closing, StateChanged and IsVisibleChanged (see xaml).  xaml: &#60;window x:Class="MyApp.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   Title="WCFAppVisualHost" Height="383" Width="680" Closing="OnClose" StateChanged="OnStateChanged" IsVisibleChanged="OnIsVisibleChanged"   &#62; Associated cs: private System.Windows.Forms.NotifyIcon m_notifyIcon; public Window1() { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=30&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had to do a bit of searching so, here&#8217;s how to minimize your WPF app to a tray icon.  Assume your window is called Window1 for the code below.  Trap Closing, StateChanged and IsVisibleChanged (see xaml). </p>
<p>xaml:<br />
<code><br />
&lt;window x:Class="MyApp.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
  Title="WCFAppVisualHost" Height="383" Width="680" Closing="OnClose" StateChanged="OnStateChanged" IsVisibleChanged="OnIsVisibleChanged"<br />
  &gt;<br />
</code><br />
Associated cs:<br />
<code><br />
private System.Windows.Forms.NotifyIcon m_notifyIcon;</code></p>
<p><code></code><code>public Window1()<br />
{</code><code> </code><code>    // initialise code here<br />
    m_notifyIcon = new System.Windows.Forms.NotifyIcon();<br />
    m_notifyIcon.BalloonTipText = "The app has been minimised. Click the tray icon to show.";<br />
    m_notifyIcon.BalloonTipTitle = "The App";<br />
    m_notifyIcon.Text = "The App";<br />
    m_notifyIcon.Icon = new System.Drawing.Icon("TheAppIcon.ico");<br />
    m_notifyIcon.Click += new EventHandler(m_notifyIcon_Click);<br />
}</code></p>
<p><code></code><code>void OnClose(object sender, CancelEventArgs args)<br />
{<br />
    m_notifyIcon.Dispose();<br />
    m_notifyIcon = null;<br />
}</code><code> </code></p>
<p><code></code><code>private WindowState m_storedWindowState = WindowState.Normal;<br />
void OnStateChanged(object sender, EventArgs args)<br />
{<br />
    if (WindowState == WindowState.Minimized)<br />
    {<br />
        Hide();<br />
        if(m_notifyIcon != null)<br />
            m_notifyIcon.ShowBalloonTip(2000);<br />
    }<br />
    else<br />
        m_storedWindowState = WindowState;<br />
}<br />
void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs args)<br />
{<br />
    CheckTrayIcon();<br />
}</code><code> </code></p>
<p><code></code><code>void m_notifyIcon_Click(object sender, EventArgs e)<br />
{<br />
    Show();<br />
    WindowState = m_storedWindowState;<br />
}<br />
void CheckTrayIcon()<br />
{<br />
    ShowTrayIcon(!IsVisible);<br />
}</code><code> </code></p>
<p><code></code><code>void ShowTrayIcon(bool show)<br />
{<br />
    if (m_notifyIcon != null)<br />
        m_notifyIcon.Visible = show;<br />
}</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/30/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/30/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=30&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/09/06/minimize-to-tray-icon-in-wpf/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8220;Loss of information&#8221;</title>
		<link>http://possemeeg.wordpress.com/2007/08/08/loss-of-information/</link>
		<comments>http://possemeeg.wordpress.com/2007/08/08/loss-of-information/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 19:34:37 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows API]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/08/08/loss-of-information/</guid>
		<description><![CDATA[I&#8217;ve always wondered (and again two days ago) what &#8220;irreversible loss of information&#8221; is being referd to when you reset a local user password from the &#8220;Computer Management&#8221; console.  Independantly, I&#8217;ve been tracking down a bug reported by one PMG Connect user in which the connection routine fails. These things are linked.  The bug was a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=29&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always wondered (and again two days ago) what &#8220;irreversible loss of information&#8221; is being referd to when you reset a local user password from the &#8220;Computer Management&#8221; console.  Independantly, I&#8217;ve been tracking down a bug reported by one PMG Connect user in which the connection routine fails.</p>
<p>These things are linked.  The bug was a call to cryptography API CryptAquireContext failing with error NTE_BAD_KEY_STATE.  (Ok, I admit, if the software was reporting faults better, this could have been determined ages ago.)  In short, it was attempting to open a key container that existed but couldn&#8217;t be used because the user had reset the password.  Checkin the web, this occurs with a lot of software (one suggested work-around was to create a new user account!).</p>
<p>So, that&#8217;s some of what loss of information occurs.  To fix this problem, the software attempts to open key containers with different names when that error is encounted.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/29/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/29/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=29&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/08/08/loss-of-information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>Block Sock Block</title>
		<link>http://possemeeg.wordpress.com/2007/08/07/block-sock-block/</link>
		<comments>http://possemeeg.wordpress.com/2007/08/07/block-sock-block/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 21:16:23 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Sockets]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows API]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/08/07/block-sock-block/</guid>
		<description><![CDATA[WinHttpGetProxyForUrl also blocks.  This is despite the documentation saying that it won&#8217;t if you close the handle during it&#8217;s operation.  (Let&#8217;s face it, Microsoft programmers often have a very loose sense of the meaning of block, what&#8217;s a minute or two.)  Anyway, this called for a generic class for blocking things (see previous post re [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=28&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>WinHttpGetProxyForUrl also blocks.  This is despite the documentation saying that it won&#8217;t if you close the handle during it&#8217;s operation.  (Let&#8217;s face it, Microsoft programmers often have a very loose sense of the meaning of block, what&#8217;s a minute or two.)  Anyway, this called for a generic class for blocking things (see previous post re gethostbyname and getaddrinfo blocking).  Anyway, the class (as before Thread is a pretty basic personal thread class):<br />
<code><br />
class CAbortableAction : public Thread<br />
{<br />
public:<br />
    CAbortableAction() : m_abort(CreateEvent(0,TRUE,FALSE,0),0,CloseHandle) {}<br />
    virtual void AbortAction() {SetEvent(m_abort);}<br />
protected:<br />
    virtual bool StartAction()<br />
    {<br />
        ResetEvent(m_abort);<br />
        if(!Create().Valid())<br />
            return false;<br />
        HANDLE handles[] = {ThreadHandle(),m_abort};<br />
        return (<br />
            WaitForMultipleObjects(sizeof(handles)/sizeof(handles[0]),<br />
                    handles,FALSE,INFINITE)=WAIT_OBJECT_0);<br />
    }<br />
    virtual void DoAction() = 0;<br />
    bool IsAborted() { return EventHandle(m_abort).IsSet();}<br />
private:<br />
    auto_HANDLE m_abort;<br />
    DWORD ThreadProc() {DoAction();return 0;}<br />
};</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/28/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/28/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=28&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/08/07/block-sock-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>PMG Connect Alpha builds</title>
		<link>http://possemeeg.wordpress.com/2007/08/06/pmg-connect-alpha-builds/</link>
		<comments>http://possemeeg.wordpress.com/2007/08/06/pmg-connect-alpha-builds/#comments</comments>
		<pubDate>Mon, 06 Aug 2007 08:33:53 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[PMG Connect]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/08/06/pmg-connect-alpha-builds/</guid>
		<description><![CDATA[The latest alpha build is on the Possemeeg Software site.  Interested parties should check from time to time for updates.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=27&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The latest alpha build is on the <a href="http://www.possemeeg.com" title="Possemeeg Software home">Possemeeg Software site</a>.  Interested parties should check from time to time for updates.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=27&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/08/06/pmg-connect-alpha-builds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>gethostbyname or getaddrinfo that doesn&#8217;t block</title>
		<link>http://possemeeg.wordpress.com/2007/07/24/gethostbyname-or-getaddrinfo-that-doesnt-block/</link>
		<comments>http://possemeeg.wordpress.com/2007/07/24/gethostbyname-or-getaddrinfo-that-doesnt-block/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 06:07:13 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/07/24/gethostbyname-or-getaddrinfo-that-doesnt-block/</guid>
		<description><![CDATA[gethostbyname and getaddrinfo block.  There is no way to stop them once they&#8217;ve started.  (BTW, getaddrinfo is recommended over gethostbyname as it&#8217;s IPv6 compatible.)  This little class will provide a neat way to get the info without blocking.  Classes extra::Thread and extra::auto_HANDLE are thread and and auto handle closing classes respectivly (is that english?).  When the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=26&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>gethostbyname and getaddrinfo block.  There is no way to stop them once they&#8217;ve started.  (BTW, getaddrinfo is recommended over gethostbyname as it&#8217;s IPv6 compatible.)  This little class will provide a neat way to get the info without blocking.  Classes extra::Thread and extra::auto_HANDLE are thread and and auto handle closing classes respectivly (is that english?).  When the user requires to cancel the request or connect, call m_hostNameGetter.Abort() from within MySocketClass.</p>
<p>The Class:<br />
<code><br />
class CGetAddrInfoThread : private extra::Thread<br />
{<br />
public:<br />
    CGetAddrInfoThread();<br />
    void Abort();<br />
    struct addrinfo *GetAddrInfo(const extra::tstring &amp;host, ULONG nPort);<br />
private:<br />
    extra::auto_HANDLE m_abort;<br />
    extra::tstring m_host;<br />
    ULONG m_port;<br />
    struct addrinfo *m_ret;<br />
    virtual DWORD ThreadProc();<br />
};</code><br />
The Implementation<br />
<code><br />
CGetAddrInfoThread::CGetAddrInfoThread() :<br />
        m_port(0), m_ret(0), m_abort(0,0,CloseHandle)<br />
{<br />
}<br />
void CGetAddrInfoThread::Abort()<br />
{<br />
    SetEvent(m_abort);<br />
}<br />
struct addrinfo *CGetAddrInfoThread::GetAddrInfo(const extra::tstring &amp;host, ULONG nPort)<br />
{<br />
    if(!m_abort.Valid())<br />
        m_abort = CreateEvent(0,TRUE,FALSE,0);<br />
    m_host = host;<br />
    m_port = nPort;<br />
    m_ret = 0;<br />
    ResetEvent(m_abort<br />
    if(!Create().Valid())<br />
        return 0<br />
    HANDLE handles[] = {ThreadHandle(),m_abort};<br />
    return ((WaitForMultipleObjects(sizeof(handles)/sizeof(handles[0]),<br />
                handles,FALSE,INFINITE)==WAIT_OBJECT_0) ? m_ret : 0);<br />
}</code><code>DWORD CGetAddrInfoThread::ThreadProc()<br />
{<br />
    char port[16];<br />
    if(_ultoa_s(m_port,port,10))<br />
        return 0;<br />
    struct addrinfo aiHints;<br />
    memset(&amp;aiHints, 0, sizeof(aiHints));<br />
    aiHints.ai_family = AF_INET;<br />
    aiHints.ai_socktype = SOCK_STREAM;<br />
    aiHints.ai_protocol = IPPROTO_TCP;</code><code>    if (::getaddrinfo(CT2CA(m_host.c_str()), port, &amp;aiHints, &amp;m_ret))<br />
        m_ret = 0;</code><code>    return 0;<br />
}</p>
<p>Using the class:<br />
<code><br />
void MySocketClass::MyConnectingMethod()<br />
{<br />
    // do stuff<br />
    struct addrinfo *aiList = m_hostNameGetter.GetAddrInfo(host,nPort);<br />
    if(!aiList)<br />
        return 0;<br />
    // do stuff<br />
}</code></p>
<p></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=26&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/07/24/gethostbyname-or-getaddrinfo-that-doesnt-block/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
		<item>
		<title>Dictionary, IEquatable, Equals and GetHashCode</title>
		<link>http://possemeeg.wordpress.com/2007/07/19/dictionary-iequatable-equals-and-gethashcode/</link>
		<comments>http://possemeeg.wordpress.com/2007/07/19/dictionary-iequatable-equals-and-gethashcode/#comments</comments>
		<pubDate>Thu, 19 Jul 2007 13:01:29 +0000</pubDate>
		<dc:creator>possemeeg</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://possemeeg.wordpress.com/2007/07/19/dictionary-iequatable-equals-and-gethashcode/</guid>
		<description><![CDATA[The docs for the .NET Dictionary class lead you to believe that implementing IEquatable for a dictionary key is good enough to get the dictionary to use your Equals method.  However, one must also override GetHashCode.  Given the way a dictionary works, this is logical but not documented.  The interesting part, is that the Remove [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=25&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The docs for the .NET Dictionary class lead you to believe that implementing IEquatable for a dictionary key is good enough to get the dictionary to use your Equals method.  However, one must also override GetHashCode.  Given the way a dictionary works, this is logical but not documented.  The interesting part, is that the Remove method on the dictionary will use your Equals with or without GetHashCode being implemented.  In this way, you can add identical items and remove more than one with one remove.  Not that you&#8217;d want to.  Anyway, this class will work as a dictionary key:</p>
<p><code><br />
public class MyDickKey : IEquatable&lt;MyDickKey&gt;<br />
{<br />
    private string m_comparableString;<br />
    private string ComparableString<br />
    { get {<br />
        return (m_comparableString != null ?<br />
            m_comparableString : GenComparableString()); } }<br />
    private void ResetComparableString()<br />
        { m_comparableString = null; }<br />
    private string GenComparableString()<br />
        {/*m_comparableString = something */}<br />
    public MyDickKey() { }<br />
    public bool Equals(MyDickKey rhs)<br />
    {<br />
        return this.ComparableString.Equals(rhs.ComparableString);<br />
    }<br />
    public override int GetHashCode()<br />
    {<br />
        return ComparableString.GetHashCode();<br />
    }<br />
};</code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/possemeeg.wordpress.com/25/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/possemeeg.wordpress.com/25/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/possemeeg.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/possemeeg.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/possemeeg.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=possemeeg.wordpress.com&amp;blog=1263315&amp;post=25&amp;subd=possemeeg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://possemeeg.wordpress.com/2007/07/19/dictionary-iequatable-equals-and-gethashcode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1b751831ad5995be0a6f1ea12945ccc0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">possemeeg</media:title>
		</media:content>
	</item>
	</channel>
</rss>
