#if !defined(_GREGKEY_H_) && defined(WIN32)
#define _GREGKEY_H_

/// Registry access class
#include "lgi/common/Containers.h"

class LgiClass LRegKey
{
	HKEY k, Root;
	char s[256];
	LString KeyName;

public:
	static bool AssertOnError;

	/// Constructor
	LRegKey
	(
		/// The access type required
		bool WriteAccess,
		/// The key name: you can use printf style syntax and extra arguments
		char *Key,
		...
	);
	~LRegKey();

	/// Returns true if the key was openned
	bool IsOk();
	/// Creates the key if not present
	bool Create();
	/// Returns the key name
	char *Name();

	/// Return a string value
	char *GetStr
	(
		/// Name of the subkey or NULL for the default string.
		const char *Name = 0
	);
	/// Return a string value
	bool GetStr
	(
		/// Name of the subkey or NULL for the default string.
		const char *Name,
		/// The string's value
		LString &Str
	);
	/// Sets a string value
	bool SetStr(const char *Name, const char *Value);

	/// Get an int value
	bool GetInt(const char *Name, uint32_t &Value);
	/// Set an int value
	bool SetInt(const char *Name, uint32_t Value);

	/// Get a binary value
	bool GetBinary(char *Name, void *&Ptr, int &Len);
	/// Set a binary value
	bool SetBinary(char *Name, void *Ptr, int Len);
	/// Delete a value
	bool DeleteValue(char *Name = 0);
	/// Delete a key
	bool DeleteKey();

	/// List all the key names under this key
	bool GetKeyNames(List<char> &n);
	/// List all the key value name under this key
	bool GetValueNames(List<char> &n);
};

#endif