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.

99 lines
2.5 KiB

  1. //
  2. // Copyright 2001 - Microsoft Corporation
  3. //
  4. // Created By:
  5. // Geoff Pease (GPease) 20-FEB-2001
  6. //
  7. // Maintained By:
  8. // Geoff Pease (GPease) 20-FEB-2001
  9. //
  10. #include "pch.h"
  11. #include "ErrorDlgs.h"
  12. #pragma hdrstop
  13. //
  14. // Description:
  15. // Displays an error dialog in response to persisting properties to
  16. // the select file or files.
  17. //
  18. void
  19. DisplayPersistFailure(
  20. HWND hwndIn
  21. , HRESULT hrIn
  22. , BOOL fMultipleIn
  23. )
  24. {
  25. TraceFunc( "" );
  26. int iRet;
  27. WCHAR szCaption[ 128 ]; // random
  28. WCHAR szText[ 1024 ]; // random
  29. int ids = 0;
  30. switch ( hrIn )
  31. {
  32. case STG_E_ACCESSDENIED:
  33. if ( fMultipleIn )
  34. {
  35. ids = IDS_ERR_ACCESSDENIED_N;
  36. }
  37. else
  38. {
  39. ids = IDS_ERR_ACCESSDENIED_1;
  40. }
  41. break;
  42. case STG_E_LOCKVIOLATION:
  43. if ( fMultipleIn )
  44. {
  45. ids = IDS_ERR_LOCKVIOLATION_N;
  46. }
  47. else
  48. {
  49. ids = IDS_ERR_LOCKVIOLATION_1;
  50. }
  51. break;
  52. default:
  53. //
  54. // For unhandled errors, try to get the system error string for the error.
  55. //
  56. {
  57. DWORD cch;
  58. cch = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM
  59. | FORMAT_MESSAGE_MAX_WIDTH_MASK
  60. , NULL
  61. , hrIn
  62. , MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL )
  63. , szText
  64. , ARRAYSIZE(szText)
  65. , NULL
  66. );
  67. AssertMsg( 0 != cch, "Unhandled error! This function needs to be modified to handle this error." );
  68. if ( 0 == cch )
  69. {
  70. //
  71. // Now what? Let's just display a blank error dialog. Not very usefull, but
  72. // at least there is an /!\ icon.
  73. //
  74. szText[ 0 ] = 0;
  75. }
  76. }
  77. break;
  78. }
  79. iRet = LoadString( g_hInstance, IDS_SUMMARY_ERROR_CAPTION, szCaption, ARRAYSIZE(szCaption) );
  80. AssertMsg( 0 != iRet, "Missing string resource?" );
  81. if ( 0 != ids )
  82. {
  83. iRet = LoadString( g_hInstance, ids, szText, ARRAYSIZE(szText) );
  84. AssertMsg( 0 != iRet, "Missing string resource?" );
  85. }
  86. MessageBox( hwndIn, szText, szCaption, MB_OK | MB_ICONEXCLAMATION );
  87. TraceFuncExit( );
  88. }