Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

275 lines
5.2 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, SH Software Co. Ltd.
// = FileName : CXRegObject.h
// = Version : ver2.0
// = Author : zjq
// = CreateDate : 2002-09-09
// = Description: 类的声明
// = Maintainers:
//
//-----------------------------------------------------------------------------+
// This is a part of the Active Template Library.
// Copyright (C) 1996-1998 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Active Template Library Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Active Template Library product.
#ifndef _RegObject_H_
#define _RegObject_H_
class GEOAPI CXRegObject
{
friend class CRegProperty;
public:
class PropMemberEntry
{
CString m_Name;
BYTE * m_pValue ;
public:
PropMemberEntry ( BYTE *pValue , LPCTSTR pszName )
{
ASSERT( pValue );
m_pValue = pValue;
m_Name = pszName;
}
LPCTSTR GetName()
{
return (const TCHAR *)m_Name;
}
BYTE *GetPValue()
{
ASSERT( m_pValue );
return m_pValue;
}
};
class DWORDEntry : public PropMemberEntry
{
public:
DWORDEntry ( DWORD *pValue , LPCTSTR pszName )
: PropMemberEntry ( (BYTE *)pValue , pszName )
{
}
DWORD GetValue()
{
return *(DWORD *)PropMemberEntry::GetPValue();
}
DWORD *GetPValue()
{
return (DWORD *)PropMemberEntry::GetPValue();
}
DWORD &GetReference()
{
return *(DWORD *)PropMemberEntry::GetPValue();
}
};
class intEntry : public PropMemberEntry
{
public:
intEntry ( int *pValue , LPCTSTR pszName )
: PropMemberEntry ( (BYTE *)pValue , pszName )
{
}
int GetValue()
{
return *(int *)PropMemberEntry::GetPValue();
}
int *GetPValue()
{
return (int *)PropMemberEntry::GetPValue();
}
int &GetReference()
{
return *(int *)PropMemberEntry::GetPValue();
}
};
class boolEntry : public PropMemberEntry
{
public:
boolEntry ( bool *pValue , LPCTSTR pszName )
: PropMemberEntry ( (BYTE *)pValue , pszName )
{
;
}
bool GetValue()
{
return *(bool *)PropMemberEntry::GetPValue();
}
bool *GetPValue()
{
return (bool *)PropMemberEntry::GetPValue();
}
bool &GetReference()
{
return *(bool *)PropMemberEntry::GetPValue();
}
};
class CStringEntry : public PropMemberEntry
{
public:
CStringEntry ( CString *pValue , LPCTSTR pszName )
: PropMemberEntry ( (BYTE *)pValue , pszName )
{
}
CString GetValue()
{
return *(CString *)PropMemberEntry::GetPValue();
}
CString *GetPValue()
{
return (CString *)PropMemberEntry::GetPValue();
}
CString &GetReference()
{
return *(CString *)PropMemberEntry::GetPValue();
}
};
public:
CXRegObject(const CXRegObject &regObj);
CXRegObject(LPCTSTR pszObjectKey, bool bVersionized = FALSE, LPCTSTR pszClassname = NULL, CRegProperty *pobjMaster= NULL, bool bDeleteByRegProperty = FALSE);
virtual ~CXRegObject ();
virtual bool Store();
virtual bool Read();
virtual bool Exchange( bool bStoring );
CXRegObject & operator = ( const CXRegObject & );
void SetTopRootKey(HKEY hKey);
void SetMaster( CRegProperty * pobjMaster );
void SetObjectKey( LPCTSTR pszObjectKey );
void SetClassname( LPCTSTR pszClassname );
void SetMasterKey( LPCTSTR pszMasterKey );
CString GetKey() const;
CString GetMasterKey() const;
bool Init();
bool SetValue ( LPCTSTR pszName , int nValue);
bool SetValue ( LPCTSTR pszName , bool bValue);
bool SetValue ( LPCTSTR pszName , DWORD dwValue);
bool SetValue ( LPCTSTR pszName , double dValue);
bool SetValue ( LPCTSTR pszName , LPCTSTR *pszValue);
bool SetValue ( LPCTSTR pszName , BYTE *pValue , DWORD size);
bool SetValue ( LPCTSTR pszName , LPCTSTR pszValue , bool bUnExanded = FALSE);
bool GetValue ( LPCTSTR pszName , int &nValue);
bool GetValue ( LPCTSTR pszName , bool &bValue);
bool GetValue ( LPCTSTR pszName , DWORD &dwValue);
bool GetValue ( LPCTSTR pszName , double &dValue);
bool GetValue ( LPCTSTR pszName , BYTE *pValue , DWORD size);
bool GetValue ( LPCTSTR pszName , CString &Value , bool * pbUnExanded = NULL);
bool GetValue ( LPCTSTR pszName , LPTSTR pszValue , DWORD size , bool * pbUnExanded);
bool AttachValue ( int *pintValue , LPCTSTR pszName);
bool AttachValue ( DWORD *pdwValue , LPCTSTR pszName);
bool AttachValue ( bool *pboolValue , LPCTSTR pszName);
bool AttachValue ( CString *pstrValue , LPCTSTR pszName);
protected:
CXRegObject ();
bool CheckExists ();
bool Open (bool bCreate = true, REGSAM samDesired = KEY_READ | KEY_WRITE);
void Close ();
bool GetValue ( LPCTSTR pszName );
protected:
BYTE *m_pData;
DWORD m_DataType;
DWORD m_DataSize;
private:
void init ();
void clear ();
private:
CRegProperty * m_pobjMaster;
LONG m_Retcode;
HKEY m_hkObject;
HKEY m_hKeyTopRoot;
bool m_bVersionized;
bool m_bDeleteByRegProperty;
DWORD m_dwDisposition;
REGSAM m_bOpen;
CString m_ObjectKey;
CString m_Classname;
CPtrArray m_ArrDWORD;
CPtrArray m_ArrCString;
CPtrArray m_ArrInt;
CPtrArray m_ArrBool;
};
#define CRegObject CXRegObject
#endif