ASP MagicRegistry Component
The MagicRegistry object allows you to manipulate registry from an Active Server Page. You can
create registry keys and tree branches, read them and change values.
Purchasing MagicRegistry
Component
Evaluation of
MagicRegistry Component
Support
Installation
Working with MagicRegistry
Evaluation of
MagicRegistry Component
Click here to download a 30-days evaluation
copy of MagicRegistry Component.
Purchasing
MagicRegistry Component
You can order MagicRegistry on-line or by phone from The Registration Network.
Also, you may order by sending check to to: Dana Consulting Inc. (in the memo
field specify MagicRegistry)
Send it to:
Dana Consulting Inc.
14936 CreditView Drive
Savage, MN 55378
Please, print, fill out and enclose Order Form located in OrderForm.html file
Support
With any questions and/or suggestions email to support@dana-net.com.
Installation
- Stop the web server.
- To register MagicRegistry component move the MagicRegistry.dll into a subdirectory (like
\winnt\system32 for NT). To register the component on the system change to the directory
where you installed the DLL and type: regsvr32
MagicRegistry.dll
- Run Register.exe program, which comes with
a component. Leave the Key filed empty and make sure you have word Evaluation in
the name field and have the right component chosen under Component pull-down menu. Click
Register button. It will give you a message saying when your component expires.
- Restart the web server.
Working with
MagicRegistry
Calling
the MagicRegistry Object from an ASP page
To call the MagicRegistry Object from an Active Server
Page, you will need to create the object using the following code:
<%Set
MyObj=Server.CreateObject("MagicRegistry.Tricks")%>
Remember to enclose the code within <% %> brackets.
Creating a new key
The following example creates new keys (test1/test2) in the
registry under HKEY_LOCAL_MACHINE/Software
<%
- Set
MyObj=Server.CreateObject("MagicRegistry.Tricks")
if MyObj.CreateNewKey("HKEY_LOCAL_MACHINE/Software/test1/test2") then
response.write("HKEY_LOCAL_MACHINE/Software/test1/test2 created successfully")
else
response.write("error # " & MyObj.ErrorNum & " occured")
response.write("<br>")
response.write(MyObj.ErrorDesc)
end if
set MyObj=Nothing
%>

Setting
the value of keys in the registry
- The following example sets new key MyKey in the registry
under HKEY_LOCAL_MACHINE/Software/ test1/test2
<%
- Set
MyObj=Server.CreateObject("MagicRegistry.Tricks")
- if
MyObj.SetKeyValue("HKEY_LOCAL_MACHINE/Software/test1/test2", "MyKey",
"Hello") then
- response.write("HKEY_LOCAL_MACHINE/Software/test1/test2
Mykey set successfully")
- else
- response.write("error # " & MyObj.ErrorNum
& " occured")
- response.write("<br>")
- response.write(MyObj.ErrorDesc)
- end if
- set MyObj=Nothing
%>
For advanced Users:
You can set the type of the key by using function SetKeyValueType and
passing in one of the 10 parameters as string.
"REG_SZ"
"REG_BINARY"
"REG_DWORD_LITTLE_ENDIAN"
"REG_EXPAND_SZ"
"REG_LINK"
"REG_MULTI_SZ"
"REG_NONE"
"REG_RESOURCE_LIST"
"REG_DWORD"
For example the following code will set MyKey to the DWORD value 10.
<%
- Set
MyObj=Server.CreateObject("MagicRegistry.Tricks")
- if
MyObj.SetKeyValueType("HKEY_LOCAL_MACHINE/Software/test1/test2",
"MyKey", 10, "REG_DWORD") then
- response.write("HKEY_LOCAL_MACHINE/Software/test1/test2
Mykey set successfully")
- else
- response.write("error # " & MyObj.ErrorNum
& " occured")
- response.write("<br>")
- response.write(MyObj.ErrorDesc)
- end if
- set MyObj=Nothing
%>

Reading the
values in the registry
<%
- Set
MyObj=Server.CreateObject("MagicRegistry.Tricks")
- mystr=MyObj.QueryValue("HKEY_LOCAL_MACHINE/Software/test1/test2",
"MyKey")
- if mystr="-1" then
- response.write("error # " & MyObj.ErrorNum
& " occured")
- response.write("<br>")
- response.write(MyObj.ErrorDesc)
- else
- response.write mystr
- end if
- set MyObj=Nothing
%>