IPB

Welcome Guest ( Log In | Register )

Recommended
BootDisk.com

Active Users

 
Reply to this topicStart new topic
[App Scripts Guide] Adding Registry keys, Explaining how to write and delete keys from the registry
Rating 5 V
 
Nuno Brito
post Aug 24 2008, 09:58 PM
Post #1


Advanced Member
***

Group: .script developer
Posts: 6,137
Thank(s): 127
Joined: 13-July 06
From: Azores
Member No.: 1


Portugal


App Scripts Guide





Index

Chapter 1 - Introduction
Chapter 2 - How to create a new app script
Chapter 3 - Adding Registry keys




Chapter 3 - Adding Registry keys






Introduction


On the previous chapter we've learned how to create a single script that only required to add a few files and nothing else.

But what happens when if your program needs to read keys from the registry?

For these cases, we'll explain exactly how you can write your own registry keys on the target registry so that everything works as you need.



Explaining Registry Hives


When we are building a boot disk based on windows, it's most often the need for editing the registry structure of this boot disk and the registry keys are all collected inside binary files called registry hives.

Registry hives can commonly be found inside the Windows\System32\Config folder and as a few other special hives such as setupreg.hiv

To avoid the need of knowing the full pathnames to hives or even knowing the equivalent hives across different platforms like XP vs Vista, we use a set of alias to make your life a bit easier when it comes to know in which hive you need to write your data.

These are the values you can use when specifying a hive:
[User,Default or HKCU],[Machine or HKU] and [System or HKLM]

Note that you can select only one of the values inside brackets [].



Loading and unloading Hives



On our app script code we need to load a registry hive before writing anything new and then unload the hive when we no longer need it so that other scripts can also use the same hives.


Here is the code used for loading and unloading an hive:
CODE
Hive_Load,HKCU
Hive_Unload


Notice that the first command will tell to load the HKCU hive - this is an alias that means "Header Key for Current User" that we mentioned above.

Using this Hive_Load will tell the system to load and prepare our hive to be written. This hive will only be unloaded when we the final lines mentioning Hive_Unload are used.






Writing registry keys



After loading the respective hive comes the time when you will be able to write your registry keys.

This is done using the Reg_Add command.

Here is an example:
CODE
reg_add,0x1,"%reg%\Software\Microsoft\Windows\CurrentVersion\Explorer\Test,Temp,ABCDEFG


This code snippet will write a registry key on Software\Microsoft\Windows\CurrentVersion\Explorer\Test on valuename Temp with the ValueData of ABCDEFG

As it expected on registry keys you will also need to specify the type of key to write.

Here is a quick list of supported types:

0x1 - Plain text
0x2 - Text with expandable variables
0x3 - Binary data
0x4 - Numbers
0x7 - Multi text entries

You will need to include %reg%\ on the beginning of each registry write because this is a variable that will later be used to replace with the correct path to your loaded hive, nothing you need to worry about but very important for this command to work.





Deleting registry keys


There are cases where it might be necessary to delete keys and values from the registry.

On this situation one can use the reg_del command.

The syntax is the following:
CODE
Reg_Del,Section,Value


Using the previously mentioned example, if we now wanted to delete the newly created value we could use:
CODE
reg_del,"%reg%\Software\Microsoft\Windows\CurrentVersion\Explorer\Test,Temp



Very simple, isn't it? (IMG:../forums/style_emoticons/default/smile.gif)




In conclusion



I hope that after reading this tutorial you're ready to start writing your own registry keys, if you're still not very confident how they are used then you can always use other app scripts as example for your own codings.

Here is an example of a few scripts using reg keys:
http://livexp.boot-land.net/LiveXP/Apps/FT...leZilla3.script
http://livexp.boot-land.net/LiveXP/Apps/Vi...onverter.script
http://livexp.boot-land.net/LiveXP/Apps/In.../WackGet.script


Please post your doubts on this topic and you're also welcome to suggest what should be added or changed in the tutorial.

Thank you.

(IMG:../forums/style_emoticons/default/smile.gif)
Go to the top of the page
 
+Quote Post
The Following 1 Users Say Thank You to Nuno Brito For This Useful Post:
wimb
« Next Oldest · Tutorials · Next Newest »
 

Fast ReplyReply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 

Display Mode: Standard · Switch to: Linear+ · Switch to: Outline

Track this topic · Email this topic · Print this topic · Subscribe to this forum

RSS Lo-Fi Version Time is now: 12th October 2008 - 08:51 AM

W3C XHTML • © 2008 Boot Land • All rights reserved • W3C CSS