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.

66 lines
1.1 KiB

  1. #include "ResourceString.h"
  2. #include "resource.h"
  3. // static member definition.
  4. map< UINT, _bstr_t>
  5. ResourceString::resourceStrings;
  6. ResourceString* ResourceString::_instance = 0;
  7. #if OBSOLETE
  8. // constructor
  9. //
  10. ResourceString::ResourceString()
  11. {}
  12. #endif // OBSOLETE
  13. // Instance
  14. //
  15. ResourceString*
  16. ResourceString::Instance()
  17. {
  18. if( _instance == 0 )
  19. {
  20. _instance = new ResourceString;
  21. }
  22. return _instance;
  23. }
  24. // GetIDString
  25. //
  26. const _bstr_t&
  27. ResourceString::GetIDString( UINT id )
  28. {
  29. // check if string has been loaded previously.
  30. if( resourceStrings.find( id ) == resourceStrings.end() )
  31. {
  32. // first time load.
  33. CString str;
  34. if( str.LoadString( id ) == 0 )
  35. {
  36. // no string mapping to this id.
  37. throw _com_error( WBEM_E_NOT_FOUND );
  38. }
  39. resourceStrings[id] = str;
  40. }
  41. return resourceStrings[ id ];
  42. }
  43. // GETRESOURCEIDSTRING
  44. // helper function.
  45. //
  46. const _bstr_t&
  47. GETRESOURCEIDSTRING( UINT id )
  48. {
  49. #if OBSOLETE
  50. ResourceString* instance = ResourceString::Instance();
  51. return instance->GetIDString( id );
  52. #else
  53. return ResourceString::GetIDString( id );
  54. #endif
  55. }