/*
 * Copyright (c) 2005-2006 Tom N Harris.
 *
 *     This program is free software; you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation; either version 2 of the License, or
 *     (at your option) any later version.
 *
 *     A copy of the GNU General Public License can be found at
 *     http://www.gnu.org/
 *
 * Written by Tom N Harris <telliamed@whoopdedo.org>
 *
 */

#ifndef SETUP_REGISTRY_H
#define SETUP_REGISTRY_H

#include "win32.h"
#include "cString.h"

namespace Setup
{

class Registry
{
	HKEY m_key;

	DWORD m_numKeys;
	DWORD m_numValues;

	DWORD m_maxClassName;
	DWORD m_maxKeyName;
	DWORD m_maxValueName;
	DWORD m_maxValueSize;
	DWORD m_maxSecurity;

	FILETIME m_writeTime;

	HANDLE m_notify;

	long update();
	bool check();
	void notify();

public:
	Registry()
		: m_key(NULL), m_notify(NULL)
	{
	}
	Registry(HKEY key);
	Registry(Registry const& cpy);
	~Registry();

	Registry& operator=(Registry const& cpy);

	bool operator!() const
		{ return m_key == NULL; }

	static Registry getKey(HKEY root, LPCTSTR key, REGSAM access = KEY_ALL_ACCESS);

	Registry getKey(LPCTSTR key, REGSAM access = KEY_ALL_ACCESS);
	Registry createKey(LPCTSTR key, REGSAM access = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES perm = NULL);
	bool deleteKey(LPCTSTR key);

	DWORD getValueType(LPCTSTR value);
	DWORD getValueSize(LPCTSTR value);
	DWORD getValueInt(LPCTSTR value);
	int getValueString(LPCTSTR value, LPTSTR buf, int len);
	String getValueString(LPCTSTR value);
};

};

#endif
