Click here to Skip to main content
12,067,652 members (28,010 online)
Click here to Skip to main content
Articles » Web Development » PHP » General » Downloads

Tagged as

Stats

17.7K views
5 bookmarked
Posted

Registry Key Handling Through PHP

, 10 Jul 2012 CPOL
This article is basically helpfull in handling Registry Key through PHP code.
reg_handling.zip
reg_handling
<?php

	//
	//Reading Registry entry.
	//
	$Wshshell= new COM('WScript.Shell');
	$data= $Wshshell->regRead('HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip\path');
	echo "Data--->".$data."<br/>";


	//
	//Function for writing to the 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;echo "<br/>"; 
			return($result);
	  }
	  catch(Exception $e){
		echo "Some Exception in Registry writing".$e;echo "<br/>";
	  }

	  return false;
	}
	
	
	//
	//Function for deleting the entry from the registry.
	//
	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:<br/>".$e;
		}
		return false;
		
	}

	$folder = "7-ZIP";
	$key = "Mac";
	$value = "123";
	
	//
	//If you want to use the registry_write() function,than use that function.
	//If you want to use the registry_delete() function,than use that function.
	//
	
	
	//registry_write($folder,$key,$value);
	registry_delete($folder,$key,$value);
?>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

amitjha1611
C-DAC Hyderabad
India India
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.160208.1 | Last Updated 10 Jul 2012
Article Copyright 2012 by amitjha1611
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid