<?php
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// MODULE: Classe Registry
// -----------------------
// Note: A n'utiliser que sur une plateforme windows
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Auteur: PascalZ (www.pascalz.com)
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Déclaration des constantes
if (!defined("HKCR"))
{
define("HKCR","HKEY_CLASSES_ROOT", TRUE);
define("HKCU","HKEY_CURRENT_USER", TRUE);
define("HKLM","HKEY_LOCAL_MACHINE", TRUE);
define("HKU", "HKEY_USERS", TRUE);
define("HKCC","HKEY_CURRENT_CONFIG",TRUE);
}
class Registry
{
// Variable privé du Shell
var $_Shell;
// Constructeur
function Registry()
{
$this->_Shell= &new COM('WScript.Shell');
}
// Gestion des erreurs
function RegError($error)
{
print($error);
error_reporting(E_ALL);
}
// Lecture d'une clé
function Read($key)
{
if (!$this->KeyExists($key))
$this->RegError("La clé n'existe pas !");
else return $this->_Shell->RegRead($key);
}
// Ecriture dans une clé
function Write($key,$value)
{
if (!$this->KeyExists($key))
$this->RegError("La clé n'existe pas !");
else return $this->_Shell->RegWrite($key,$value);
}
// Supprimer la clé
function Delete($key)
{
if (!$this->KeyExists($key))
$this->RegError("La clé n'existe pas !");
else return $this->_Shell->RegDelete($key);
}
// Vérifier que la clé existe
function KeyExists($key)
{
return (@$this->_Shell->RegRead($key) != null);
}
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
?>