Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

  1. void DisplayError(DWORD nCode)
  2. /*++
  3. Routine Description:
  4. This routine will display an error message based off of the Win32 error
  5. code that is passed in. This allows the user to see an understandable
  6. error message instead of just the code.
  7. Arguments:
  8. Code - The error code to be translated.
  9. Return Value:
  10. None.
  11. --*/
  12. {
  13. WCHAR sBuffer[200];
  14. DWORD nCount ;
  15. //
  16. // Translate the Win32 error code into a useful message.
  17. //
  18. nCount = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
  19. NULL,
  20. nCode,
  21. 0,
  22. sBuffer,
  23. sizeof( sBuffer )/sizeof( WCHAR ),
  24. NULL) ;
  25. //
  26. // Make sure that the message could be translated.
  27. //
  28. if (nCount == 0)
  29. {
  30. swprintf(sBuffer, L"Unable to translate error code %d", nCode);
  31. MessageBox(NULL, sBuffer, L"Translation Error", MB_OK);
  32. }
  33. else
  34. {
  35. //
  36. // Display the translated error.
  37. //
  38. MessageBox(NULL, sBuffer, L"Error", MB_OK);
  39. }
  40. }