title: How can I retrieve error strings for DirectX 9
body: <p>I want to retrieve error strings for DirectX 9, but I can find on the web is using the FormatMessage() and _com_error.ErrorMessage(), both of which fail me. </p>
  
  <pre><code>hr = g_pd3dDevice-&gt;GetRenderTargetData(...
  ... // the debugger tells me hr = 0x8876086c
  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
      FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL, hr, 0, (LPTSTR)&amp;lpBuf, 0, NULL))
  // it returns 0 with lpBuf unallocated
  </code></pre>
  
  <p>FormatMessage() fails and I use the it again with GetLastError() to see why FormatMessage() fails:
  "The system cannot find message text for message number 0x%1 in the message file for %2."</p>
  
  <p>_com_error.ErrorMessage() tells me "Unknown error 0x8876086c"</p>