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.

75 lines
1.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1996 - 1999
  6. //
  7. // File: printfu.cpp
  8. //
  9. // Contents: Unicode Console Printf's
  10. //
  11. // History: 02-May-1997 xiaohs created
  12. // 06-May-1997 pberkman converted to C++
  13. //
  14. //--------------------------------------------------------------------------
  15. #include "global.hxx"
  16. #include <stdio.h>
  17. #include <stdarg.h>
  18. #include "unicode.h"
  19. #include "gendefs.h"
  20. #include "printfu.hxx"
  21. PrintfU_::PrintfU_(DWORD ccMaxString)
  22. {
  23. hModule = GetModuleHandle(NULL);
  24. pwszDispString = (WCHAR *)new BYTE[ccMaxString * sizeof(WCHAR)];
  25. pwszResString = (WCHAR *)new BYTE[ccMaxString * sizeof(WCHAR)];
  26. ccMax = ccMaxString;
  27. }
  28. PrintfU_::~PrintfU_(void)
  29. {
  30. DELETE_OBJECT(pwszDispString);
  31. DELETE_OBJECT(pwszResString);
  32. }
  33. void _cdecl PrintfU_::Display(DWORD dwFmt, ...)
  34. {
  35. if (!(hModule) || !(pwszDispString) || !(pwszResString))
  36. {
  37. return;
  38. }
  39. va_list vaArgs;
  40. va_start(vaArgs, dwFmt);
  41. vwprintf(this->get_String(dwFmt, pwszDispString, ccMax), vaArgs);
  42. va_end(vaArgs);
  43. }
  44. WCHAR *PrintfU_::get_String(DWORD dwID, WCHAR *pwszRet, DWORD ccRet)
  45. {
  46. if (!(hModule) || !(pwszDispString) || !(pwszResString))
  47. {
  48. return(NULL);
  49. }
  50. if (!(pwszRet))
  51. {
  52. pwszRet = pwszResString;
  53. ccRet = ccMax;
  54. }
  55. LoadStringU(hModule, dwID, pwszRet, ccRet);
  56. return(pwszRet);
  57. }