title: FormatMessage gets Error 317 while trying to read EventLog
body: <p>I had nearly similar problem with this. 
  <a href="https://stackoverflow.com/questions/6264449/formatmessage-fails-with-error-code-317">FormatMessage Fails with error code 317</a></p>
  
  <p>The difference is it is said as an answer that this is caused by <code>"FORMAT_MESSAGE_FROM_SYSTEM"</code> but when I remove it it happens again.</p>
  
  <p>I am trying to read from <code>EventLog</code> in Windows Server 2003. But when I try to use <code>FormatMessage</code> function I get <code>317</code> error. </p>
  
  <p>Interestingly same code works for Windows Server 2008. How can I fix this or what can I use instead of <code>FormatMessage</code>?</p>
  
  <p>My code:</p>
  
  <pre><code>   FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | 
          FORMAT_MESSAGE_FROM_SYSTEM | 
          FORMAT_MESSAGE_ALLOCATE_BUFFER,
          g_hResources, // handles DLL containing message table 
          MessageId,
          0, // Default language
          (LPWSTR) &amp;pMessage,
          0,
          (va_list*)pArgs )
  </code></pre>
  
  <p>Good day to you..</p>