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.

74 lines
1.2 KiB

  1. //
  2. // cresstr.h
  3. //
  4. #ifndef CRESSTR_H
  5. #define CRESSTR_H
  6. #include "osver.h"
  7. #include "mui.h"
  8. #include "cicutil.h"
  9. //
  10. // assume we have static g_hInst.
  11. //
  12. extern HINSTANCE g_hInst;
  13. /////////////////////////////////////////////////////////////////////////////
  14. //
  15. // CRStr
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18. class CRStr
  19. {
  20. public:
  21. CRStr(int nResId)
  22. {
  23. _nResId = nResId;
  24. }
  25. operator WCHAR*()
  26. {
  27. LoadStringWrapW(g_hInst, _nResId, _sz, ARRAYSIZE(_sz));
  28. return _sz;
  29. }
  30. operator char*()
  31. {
  32. LoadStringA(g_hInst, _nResId, (char *)_sz, sizeof(_sz));
  33. return (char *)&_sz[0];
  34. }
  35. private:
  36. int _nResId;
  37. WCHAR _sz[64];
  38. };
  39. class CRStr2
  40. {
  41. public:
  42. CRStr2(int nResId)
  43. {
  44. _nResId = nResId;
  45. }
  46. operator WCHAR*()
  47. {
  48. LoadStringWrapW(GetCicResInstance(g_hInst, _nResId), _nResId, _sz, ARRAYSIZE(_sz));
  49. return _sz;
  50. }
  51. operator char*()
  52. {
  53. LoadStringA(GetCicResInstance(g_hInst, _nResId), _nResId, (char *)_sz, sizeof(_sz));
  54. return (char *)&_sz[0];
  55. }
  56. private:
  57. int _nResId;
  58. WCHAR _sz[256];
  59. };
  60. #endif // CRESSTR_H