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.

89 lines
1.6 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. CResId::CResId( LPTSTR pszRes )
  4. : m_pszRes(NULL), m_nRes(0), m_bIsString(false)
  5. {
  6. StringRes(pszRes);
  7. }
  8. CResId::CResId( int nRes )
  9. : m_pszRes(NULL), m_nRes(0), m_bIsString(false)
  10. {
  11. NumberRes(nRes);
  12. }
  13. CResId::CResId( const CResId &other )
  14. : m_pszRes(NULL), m_nRes(0), m_bIsString(false)
  15. {
  16. if (other.IsString())
  17. StringRes(other.StringRes());
  18. else NumberRes(other.NumberRes());
  19. }
  20. CResId::~CResId(void)
  21. {
  22. if (m_pszRes)
  23. {
  24. delete[] m_pszRes;
  25. m_pszRes = NULL;
  26. }
  27. }
  28. const CResId &CResId::operator=( const CResId &other )
  29. {
  30. if (other.IsString())
  31. StringRes(other.StringRes());
  32. else NumberRes(other.NumberRes());
  33. return *this;
  34. }
  35. LPCTSTR CResId::ResourceName(void) const
  36. {
  37. if (IsString())
  38. return StringRes();
  39. else return MAKEINTRESOURCE(NumberRes());
  40. }
  41. LPCTSTR CResId::StringRes(void) const
  42. {
  43. return m_pszRes;
  44. }
  45. int CResId::NumberRes(void) const
  46. {
  47. return m_nRes;
  48. }
  49. bool CResId::IsString(void) const
  50. {
  51. return m_bIsString;
  52. }
  53. LPCTSTR CResId::StringRes( LPCTSTR pszRes )
  54. {
  55. if (m_pszRes)
  56. {
  57. delete[] m_pszRes;
  58. m_pszRes = NULL;
  59. }
  60. if (pszRes)
  61. {
  62. m_pszRes = new TCHAR[lstrlen(pszRes)+1];
  63. if (m_pszRes)
  64. {
  65. lstrcpy( m_pszRes, pszRes );
  66. }
  67. }
  68. m_bIsString = true;
  69. return m_pszRes;
  70. }
  71. int CResId::NumberRes( int nRes )
  72. {
  73. m_nRes = nRes;
  74. m_bIsString = false;
  75. return m_nRes;
  76. }