Source code of Windows XP (NT5)
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.

205 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. Support
  5. Abstract:
  6. Miscelaneous support functions for the XCopy directory copy
  7. utility. All functions that are not involved directly in the
  8. copy process go here.
  9. Author:
  10. Ramon Juan San Andres (ramonsa) 02-May-1991
  11. Revision History:
  12. --*/
  13. #include "mode.hxx"
  14. //#include "ulib.hxx"
  15. #include "system.hxx"
  16. //#include "mode.hxx"
  17. VOID
  18. DisplayMessage (
  19. IN MSGID MsgId,
  20. IN PCWSTRING String
  21. )
  22. /*++
  23. Routine Description:
  24. Displays a message, with an optional parameter
  25. Arguments:
  26. MsgId - Supplies the Id of the message to display.
  27. String - Supplies a string parameter for the message.
  28. Return Value:
  29. None.
  30. Notes:
  31. --*/
  32. {
  33. if (MsgId != 0) {
  34. Message->Set( MsgId );
  35. if ( String == NULL ) {
  36. //
  37. // The message has no parameters
  38. //
  39. Message->Display( "" );
  40. } else {
  41. //
  42. // Display it.
  43. //
  44. Message->Display( "%W", String );
  45. }
  46. }
  47. }
  48. VOID
  49. DisplayMessageAndExit (
  50. IN MSGID MsgId,
  51. IN PCWSTRING String,
  52. IN ULONG ExitCode
  53. )
  54. /*++
  55. Routine Description:
  56. Displays a message and exits the program with the supplied error code.
  57. We support a maximum of one string parameter for the message.
  58. Arguments:
  59. MsgId - Supplies the Id of the message to display.
  60. String - Supplies a string parameter for the message.
  61. ExitCode - Supplies the exit code with which to exit.
  62. Return Value:
  63. None.
  64. Notes:
  65. --*/
  66. {
  67. DisplayMessage( MsgId, String );
  68. ExitMode( ExitCode );
  69. }
  70. PWSTRING
  71. QueryMessageString (
  72. IN MSGID MsgId
  73. )
  74. /*++
  75. Routine Description:
  76. Obtains a string object initialized to the contents of some message
  77. Arguments:
  78. MsgId - Supplies ID of the message
  79. Return Value:
  80. PWSTRING - Pointer to initialized string object
  81. Notes:
  82. --*/
  83. {
  84. PWSTRING String;
  85. if ( ((String = NEW DSTRING) == NULL ) ||
  86. !(SYSTEM::QueryResourceString( String, MsgId, "" )) ) {
  87. DisplayMessageAndExit( MODE_ERROR_NO_MEMORY, NULL, (ULONG)EXIT_ERROR );
  88. }
  89. return String;
  90. }
  91. VOID
  92. ExitWithError(
  93. IN DWORD ErrorCode
  94. )
  95. /*++
  96. Routine Description:
  97. Displays a message based on a WIN32 error code, and exits.
  98. Arguments:
  99. ErrorCode - Supplies Windows error code
  100. Return Value:
  101. none
  102. --*/
  103. {
  104. Message->Set( MODE_ERROR_EXTENDED );
  105. Message->Display( "%d", ErrorCode );
  106. ExitMode( (ULONG)EXIT_ERROR );
  107. }
  108. VOID
  109. ExitMode(
  110. IN DWORD ExitCode
  111. )
  112. /*++
  113. Routine Description:
  114. Exits the program
  115. Arguments:
  116. ExitCode - Supplies the exit code
  117. Return Value:
  118. none
  119. --*/
  120. {
  121. exit( (int)ExitCode );
  122. }