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.

86 lines
1.6 KiB

  1. //
  2. // System level IO verification configuration utility
  3. // Copyright (c) Microsoft Corporation, 1999
  4. //
  5. //
  6. // module: resutil.cxx
  7. // author: DMihai
  8. // created: 04/19/99
  9. // description: resources manipulation routines
  10. //
  11. #include <windows.h>
  12. #include <tchar.h>
  13. #include "resutil.hxx"
  14. //////////////////////////////////////////////////////////////////////
  15. BOOL
  16. GetStringFromResources(
  17. UINT uIdResource,
  18. TCHAR *strResult,
  19. int nBufferLen )
  20. {
  21. UINT LoadStringResult;
  22. LoadStringResult = LoadString (
  23. GetModuleHandle (NULL),
  24. uIdResource,
  25. strResult,
  26. nBufferLen );
  27. assert_ (LoadStringResult > 0);
  28. return (LoadStringResult > 0);
  29. }
  30. //////////////////////////////////////////////////////////////////////
  31. void
  32. PrintStringFromResources(
  33. UINT uIdResource)
  34. {
  35. TCHAR strStringFromResource[ 1024 ];
  36. BOOL bResult;
  37. bResult = GetStringFromResources(
  38. uIdResource,
  39. strStringFromResource,
  40. ARRAY_LEN( strStringFromResource ) );
  41. if( bResult == TRUE )
  42. {
  43. _putts( strStringFromResource );
  44. }
  45. }
  46. //////////////////////////////////////////////////////////////////////
  47. void
  48. __cdecl
  49. DisplayErrorMessage(
  50. UINT uFormatResId,
  51. ... )
  52. {
  53. TCHAR strMsgFormat[ 256 ];
  54. BOOL bResult;
  55. va_list prms;
  56. va_start (prms, uFormatResId);
  57. bResult = GetStringFromResources(
  58. uFormatResId,
  59. strMsgFormat,
  60. ARRAY_LEN( strMsgFormat ) );
  61. if( bResult == TRUE )
  62. {
  63. _vtprintf ( strMsgFormat, prms);
  64. _tprintf ( _TEXT( "\n" ) );
  65. }
  66. va_end (prms);
  67. }