2009-05-08 13:28:41 +00:00
|
|
|
/*
|
|
|
|
* OpenClonk, http://www.openclonk.org
|
|
|
|
*
|
2009-06-05 13:41:20 +00:00
|
|
|
* Copyright (c) 1998-2000, 2004 Matthes Bender
|
|
|
|
* Copyright (c) 2005 Peter Wortmann
|
|
|
|
* Copyright (c) 2005 Günther Brammer
|
2009-05-08 13:28:41 +00:00
|
|
|
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
|
|
|
*
|
|
|
|
* Portions might be copyrighted by other authors who have contributed
|
|
|
|
* to OpenClonk.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
* See isc_license.txt for full license and disclaimer.
|
|
|
|
*
|
|
|
|
* "Clonk" is a registered trademark of Matthes Bender.
|
|
|
|
* See clonk_trademark_license.txt for full license.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Some wrappers for easier access to the Windows registry */
|
|
|
|
|
|
|
|
#ifndef INC_STDREGISTRY
|
|
|
|
#define INC_STDREGISTRY
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
|
|
|
#include "StdCompiler.h"
|
2009-08-15 18:50:32 +00:00
|
|
|
bool DeleteRegistryValue(HKEY hKey, const char *szSubKey,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szValueName);
|
2009-08-15 18:50:32 +00:00
|
|
|
bool DeleteRegistryValue(const char *szSubKey, const char *szValueName);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool GetRegistryDWord(HKEY hKey, const char *szSubKey,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szValueName, DWORD *lpdwValue);
|
2009-08-15 18:50:32 +00:00
|
|
|
bool GetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD *lpdwValue);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool SetRegistryDWord(HKEY hKey, const char *szSubKey,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szValueName, DWORD dwValue);
|
2009-08-15 18:50:32 +00:00
|
|
|
bool SetRegistryDWord(const char *szSubKey, const char *szValueName, DWORD dwValue);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool GetRegistryString(const char *szSubKey, const char *szValueName, char *sValue, DWORD dwValSize);
|
|
|
|
bool SetRegistryString(const char *szSubKey, const char *szValueName, const char *szValue);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool DeleteRegistryKey(HKEY hKey, const char *szSubKey);
|
|
|
|
bool DeleteRegistryKey(const char *szSubKey);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool SetRegClassesRoot(const char *szSubKey,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szValueName,
|
|
|
|
const char *szStringValue);
|
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool SetRegShell(const char *szClassName,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szShellName,
|
|
|
|
const char *szShellCaption,
|
|
|
|
const char *szCommand,
|
2009-08-15 18:50:32 +00:00
|
|
|
bool fMakeDefault = false);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool RemoveRegShell(const char *szClassName,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szShellName);
|
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool SetRegFileClass(const char *szClassRoot,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szExtension,
|
|
|
|
const char *szClassName,
|
|
|
|
const char *szIconPath, int iIconNum,
|
|
|
|
const char *szContentType);
|
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool StoreWindowPosition(HWND hwnd,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szWindowName,
|
|
|
|
const char *szSubKey,
|
2009-08-15 18:50:32 +00:00
|
|
|
bool fStoreSize = true);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
2009-08-15 18:50:32 +00:00
|
|
|
bool RestoreWindowPosition(HWND hwnd,
|
2009-05-08 13:28:41 +00:00
|
|
|
const char *szWindowName,
|
|
|
|
const char *szSubKey,
|
2009-08-15 18:50:32 +00:00
|
|
|
bool fHidden = false);
|
2009-05-08 13:28:41 +00:00
|
|
|
|
|
|
|
// config writer
|
|
|
|
class StdCompilerConfigWrite : public StdCompiler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Construct with root key
|
|
|
|
StdCompilerConfigWrite(HKEY hRoot, const char *szPath);
|
|
|
|
~StdCompilerConfigWrite();
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
virtual bool hasNaming() { return true; }
|
|
|
|
virtual bool forceWrite() { return true; }
|
|
|
|
|
|
|
|
// Naming
|
|
|
|
virtual bool Name(const char *szName);
|
|
|
|
virtual void NameEnd(bool fBreak = false);
|
|
|
|
virtual bool FollowName(const char *szName);
|
|
|
|
virtual bool Default(const char *szName);
|
|
|
|
|
|
|
|
// Seperators
|
|
|
|
virtual bool Seperator(Sep eSep);
|
|
|
|
|
|
|
|
// Data writers
|
|
|
|
virtual void DWord(int32_t &rInt);
|
|
|
|
virtual void DWord(uint32_t &rInt);
|
|
|
|
virtual void Word(int16_t &rShort);
|
|
|
|
virtual void Word(uint16_t &rShort);
|
|
|
|
virtual void Byte(int8_t &rByte);
|
|
|
|
virtual void Byte(uint8_t &rByte);
|
|
|
|
virtual void Boolean(bool &rBool);
|
|
|
|
virtual void Character(char &rChar);
|
|
|
|
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType = RCT_Escaped);
|
|
|
|
virtual void String(char **pszString, RawCompileType eType = RCT_Escaped);
|
|
|
|
virtual void Raw(void *pData, size_t iSize, RawCompileType eType = RCT_Escaped);
|
|
|
|
|
|
|
|
// Passes
|
|
|
|
virtual void Begin();
|
|
|
|
virtual void End();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Key stack
|
|
|
|
int iDepth;
|
|
|
|
struct Key {
|
|
|
|
StdStrBuf Name;
|
|
|
|
HKEY Handle;
|
|
|
|
Key *Parent;
|
|
|
|
} *pKey;
|
|
|
|
|
|
|
|
// Writing
|
|
|
|
void CreateKey(HKEY hParent = 0);
|
|
|
|
void WriteDWord(uint32_t iVal);
|
|
|
|
void WriteString(const char *szStr);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// config reader
|
|
|
|
class StdCompilerConfigRead : public StdCompiler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Construct with root key
|
|
|
|
StdCompilerConfigRead(HKEY hRoot, const char *szPath);
|
|
|
|
~StdCompilerConfigRead();
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
virtual bool isCompiler() { return true; }
|
|
|
|
virtual bool hasNaming() { return true; }
|
|
|
|
|
|
|
|
// Naming
|
|
|
|
virtual bool Name(const char *szName);
|
|
|
|
virtual void NameEnd(bool fBreak = false);
|
|
|
|
virtual bool FollowName(const char *szName);
|
|
|
|
|
|
|
|
// Seperators
|
|
|
|
virtual bool Seperator(Sep eSep);
|
|
|
|
|
|
|
|
// Data writers
|
|
|
|
virtual void DWord(int32_t &rInt);
|
|
|
|
virtual void DWord(uint32_t &rInt);
|
|
|
|
virtual void Word(int16_t &rShort);
|
|
|
|
virtual void Word(uint16_t &rShort);
|
|
|
|
virtual void Byte(int8_t &rByte);
|
|
|
|
virtual void Byte(uint8_t &rByte);
|
|
|
|
virtual void Boolean(bool &rBool);
|
|
|
|
virtual void Character(char &rChar);
|
|
|
|
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType = RCT_Escaped);
|
|
|
|
virtual void String(char **pszString, RawCompileType eType = RCT_Escaped);
|
|
|
|
virtual void Raw(void *pData, size_t iSize, RawCompileType eType = RCT_Escaped);
|
|
|
|
|
|
|
|
// Passes
|
|
|
|
virtual void Begin();
|
|
|
|
virtual void End();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
// Key stack
|
|
|
|
int iDepth;
|
|
|
|
struct Key {
|
|
|
|
StdStrBuf Name;
|
|
|
|
HKEY Handle; // for keys only
|
|
|
|
Key *Parent;
|
|
|
|
bool Virtual;
|
|
|
|
DWORD Type; // for values only
|
|
|
|
} *pKey;
|
|
|
|
|
|
|
|
// Reading
|
|
|
|
uint32_t ReadDWord();
|
|
|
|
StdStrBuf ReadString();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // INC_STDREGISTRY
|