home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / pipe / mrustrings.cpp < prev    next >
C/C++ Source or Header  |  1998-04-02  |  1KB  |  72 lines

  1. // MRUStrings.cpp: implementation of the CMRUStrings class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4.  
  5. #include "stdafx.h"
  6. #include "pipe.h"
  7. #include "MRUStrings.h"
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[]=__FILE__;
  12. #define new DEBUG_NEW
  13. #endif
  14.  
  15. //////////////////////////////////////////////////////////////////////
  16. // Construction/Destruction
  17. //////////////////////////////////////////////////////////////////////
  18.  
  19. CMRUStrings::CMRUStrings()
  20. {
  21. }
  22.  
  23. CMRUStrings::~CMRUStrings()
  24. {
  25.  
  26. }
  27.  
  28. BOOL CMRUStrings::Create(CRegKey &key, CString& strName)
  29. {
  30.     BOOL fOK = TRUE;
  31.  
  32.     m_regKey = key;
  33.     m_strName = strName;
  34.  
  35.     return(fOK);
  36. }
  37.  
  38. BOOL CMRUStrings::GetString(int i, CString& strVal)
  39. {
  40.     CString strT;
  41.     unsigned long lSize;
  42.     BOOL fOK = FALSE;
  43.     long lRes;
  44.  
  45.     strT.Format(_T("%s%d"), m_strName, i);
  46.     strVal.Empty();
  47.     lRes = m_regKey.QueryValue(strVal.GetBuffer(_MAX_PATH), strT, &lSize);
  48.     strVal.ReleaseBuffer();
  49.     fOK = !strVal.IsEmpty();    
  50.     return(fOK);
  51. }
  52.  
  53. BOOL CMRUStrings::SetString(int i, CString &strVal)
  54. {
  55.     CString strT;
  56.     BOOL fOK = FALSE;
  57.     long lRes;
  58.  
  59.     strT.Format(_T("%s%d"), m_strName, i);
  60.     lRes = m_regKey.SetValue(strVal, strT);
  61.     return(lRes == ERROR_SUCCESS);
  62. }
  63.  
  64. BOOL CMRUStrings::Create(HKEY hKeyParent, LPCTSTR lpszKeyName, CString &strName)
  65. {
  66.     long lRes;
  67.  
  68.     lRes = m_regKey.Create(hKeyParent, lpszKeyName);
  69.     m_strName = strName;
  70.     return(lRes == ERROR_SUCCESS);
  71. }
  72.