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.

86 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. libmsg.c
  5. Abstract:
  6. Message handling routines.
  7. Author:
  8. Mandar Gokhale(mandarg) 20-Dec-2001
  9. Revision History:
  10. --*/
  11. #include "libmsg.h"
  12. LPTSTR
  13. GetFormattedMessage(
  14. IN HMODULE ThisModule, OPTIONAL
  15. IN BOOL SystemMessage,
  16. OUT PWCHAR Message,
  17. IN ULONG LengthOfBuffer,
  18. IN UINT MessageId,
  19. ...
  20. )
  21. /*++
  22. Routine Description:
  23. Retreive and format a message.
  24. Arguments:
  25. ThisModule - Handle to this module that contains the message.
  26. SystemMessage - specifies whether the message is to be located in
  27. this module, or whether it's a system message.
  28. Message - Message buffer that will contain the formatted message.
  29. LengthOfBuffer - Length of the message buffer in characters.
  30. MessageId - If SystemMessage is TRUE, then this supplies a system message id,
  31. such as a Win32 error code. If SystemMessage is FALSE, the this supplies
  32. the id for the message within this module's resources.
  33. Additional arguments supply values to be inserted in the message text.
  34. Return Value:
  35. Returns a pointer to the message buffer if a message is retrieved
  36. into the messaage buffer otherwise returns NULL.
  37. --*/
  38. {
  39. va_list arglist;
  40. DWORD d;
  41. if (Message && LengthOfBuffer){
  42. *Message = UNICODE_NULL;
  43. va_start(arglist,MessageId);
  44. d = FormatMessage(
  45. SystemMessage ? FORMAT_MESSAGE_FROM_SYSTEM : FORMAT_MESSAGE_FROM_HMODULE,
  46. ThisModule,
  47. MessageId,
  48. 0,
  49. Message,
  50. LengthOfBuffer,
  51. &arglist
  52. );
  53. va_end(arglist);
  54. }
  55. return(Message);
  56. }