logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: PHP registry
Author
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 14 Sep '07 10:41    Post subject: PHP registry Reply with quote

Maybe useful for one or the other windows PHP user

Code:

<?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);
   }

}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

?>
Back to top


Reply to topic   Topic: PHP registry View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner