#ifndef _COMMON_REGKEY_HPP_
#define _COMMON_REGKEY_HPP_
#ifndef _COMMON_REGSAM_HPP_
#include <common/regsam.hpp>
#endif

class String;

class RegKey
{
public:
	enum Key{ClassesRoot=(int)HKEY_CLASSES_ROOT,CurrentUser=(int)HKEY_CURRENT_USER,LocalMachine=(int)HKEY_LOCAL_MACHINE,Users=(int)HKEY_USERS,CurrentConfig=(int)HKEY_CURRENT_CONFIG,DynData=(int)HKEY_DYN_DATA};
	RegKey(void);
  RegKey(const RegKey &someRegKey);
  RegKey(Key regKey);
	virtual ~RegKey();
	RegKey &operator=(const RegKey &someRegKey);
	WORD operator==(const RegKey &someRegKey);
	operator HKEY(void)const;
	WORD openKey(const RegKey &openKey,const String &subKey,const RegSam &regSam=RegSam());
	WORD openKey(const String &subKey,const RegSam &regSam=RegSam());
  WORD openKey(Key regKey,const String &subKey,const RegSam &regSam=RegSam());
	void closeKey(void);
  WORD enumValue(DWORD index,String &nameValue,String &value);
  WORD enumValue(DWORD index,String &valueName,DWORD &longData);
	WORD enumKey(DWORD index,String &strKey);
  WORD connectRegistry(const String &computerName,const RegKey &regKey);
	WORD deleteKey(const String &subKey);
  WORD deleteValue(const String &namedValue);
  WORD createKey(Key regKey,const String &subKey,const RegSam &regSam=RegSam());
	WORD createKey(const RegKey &openKey,const String &subKey,const String &className,const RegSam &regSam=RegSam());
	WORD createKey(const String &subKey,const String &className,const RegSam &regSam=RegSam());
	WORD queryValue(const String &valueName,String &stringData)const;
	WORD queryValue(const String &valueName,DWORD &longData)const;
	WORD setValue(const String &valueName,DWORD longData);
	WORD setValue(const String &valueName,const String &stringData);
	WORD isOpenKey(void)const;
	WORD isOkay(void)const;
private:
  enum {MaxDataLength=256};
  enum Disposition{KeepKey,CloseKey,InvalidKey};
	void isOpenKey(WORD isOpenKey);
	WORD isPredefinedKey(void)const;
  WORD createDescendKey(const String &subKey,const String &className,const RegSam &regSam);
  WORD descendKey(const RegKey &openKey,const String &subKey,const RegSam &regSam);

	HKEY mhKey;
	HKEY mhPrevKey;
	WORD mIsOpenKey;
	Disposition mDisposition;
};
#endif

