 <p>Your code is leaving uninitialized memory and that might cause <a href="http://en.wikipedia.org/wiki/Undefined_behavior" rel="nofollow">undefined behavior</a>, make sure that every pointer/data is zero'ed out before proceeding setting your flags/pointers:</p> <pre><code>WNDCLASSEX wndClass; memset(&amp;wndClass, 0, sizeof(WNDCLASSEX)); </code></pre> <p>or even better:</p> <pre><code>WNDCLASSEX wndClass = { 0 }; </code></pre>