note 114558 deleted from configuration.changes by cmb
| From: | cmb@php.net | Date: | Tue, 03 Aug 2021 15:53:30 +0000 |
| Subject: | note 114558 deleted from configuration.changes by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216733@lists.php.net to get a copy of this message | ||
Note Submitter: andy at ddtechnologies dot com
----
Registry Key Handling Through PHP:
This is an ready to use code. You just need to copy this code into a PHP file.
//php Code starts from here......
//Reading the Registry
$Wshshell= new COM('WScript.Shell');
$data= $Wshshell->regRead('HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip\path');
echo "Data is::".$data;
//Function for writing to the registry.
function registry_write($folder, $key, $value, $type="REG_SZ")
{
$WshShell = new COM("WScript.Shell");
$registry = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder . "\\" . $key;
try{
$result = $WshShell->RegWrite($registry, $value, $type);
echo "Entry is Successfully written at:".$registry;
return($result);
}
catch(Exception $e){
echo "Some Exception in Registry writing".$e;
}
return false;
}
// Function to deleting from the Register Entry.
function registry_delete($folder, $key, $value, $type="REG_SZ")
{
$WshShell = new COM("Wscript.shell");
$registry = "HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder . "\\" . $key;
try{
$result = $WshShell->RegDelete($registry);
echo $key." is Successfully deleted from HKEY_LOCAL_MACHINE\\SOFTWARE\\" . $folder ;
return($result);
}
catch(Exception $e){
echo "Some Exception with the code::".$e;
}
return false;
}
//Here 7-ZIP is taken as a example.
$folder = "7-ZIP";
$key = "Key_name";
$value = "Key_Value";
registry_write($folder,$key,$value);
//registry_delete($folder,$key,$value);
?>
...
-------------------------------------------------------------------------------------
http://herobot.net