[Reference] RegEdit

Posts 1–12 of 12 · Page 1 of 1
[Reference] RegEdit
Hej has been asking me a series of questions regarding Dwords and related, Instead of just sending over the code (which was my initial intention)I have decided to create a "Article" / "Tut" as this can be usueful to developers for 100's of reasons.

Registry Keys Article/Tutorial





As always, Follow this article, read along, and open VB and start a new project and follow along.

Developers (Windows Developers) have been using the registry as a place to store application settings, and in some cases can be used to change settings of other applications, so the question becomes, how can we harnest this feature in VB.net

Definitions paraphrased by me (Original Source Wiki)

SubTree

  • HKEY_CURRENT_USER
    Configuration Settings of the user who logged on. (Currently)
  • HKEY_USERS
    Contains all user profiles Settings.
  • HKEY_LOCAL_MACHINE
    Contains Settings and configuration Information particular to the computer.
  • HKEY_CLASSES_ROOT
    Contains data that associates extensions wiith the program, and configuration data for COM objects.
  • HKEY_CURRENT_CONFIG
    Contains information about hardware used on system startup.



Subkeys and Values.

Paraphrased by me (original source WIKI)

  • REG_SZ
    A fixed-length text string.
  • REG_EXPAND_SZ
    A variable-length text string.
  • REG_DWORD
    A number that is 4 bytes (32 bits) long. (Data)
  • REG_MULTI_SZ
    Multiple text strings formatted as an array of null strings


Microsoft.Win32 Namespace

  • ClassesRoot
    Read base key HKEY_CLASSES_ROOT.
  • CurrentConfig
    Reads base key HKEY_CURRENT_CONFIG.
  • CurrentUser
    Reads base key HKEY_CURRENT_USER
  • LocalMachine
    Reads base key HKEY_LOCAL_MACHINE.
  • Users
    Reads base key HKEY_USERS.
  • Name
    Retrieves the name of key.
  • SubKeyCount
    Retrieves the count of subkeys.
  • ValueCount
    Retrieves the count of values.
  • Close
    Closes the key.
  • CreateSubKey
    Creates a subkey or opens one.
  • DeleteSubKey
    Deletes a subkey.
  • DeleteSubKeyTree
    Deletes a subkey and any child subkeys.
  • DeleteValue
    Deletes the specified value from this key.
  • GetSubKeyNames
    Retrieves an array of strings from all subkey names.
  • GetValue
    Retrieves the specified value.
  • GetValueNames
    Retrieves an array of strings from all names associated with the specified Key
  • OpenSubKey
    Retrieves a specified subkey (with write access)
  • SetValue
    Sets the specified value.


__________________________________________________ _______________


Example 1 (Create Subkey)

Code:
Dim rKey As RegistryKey
rKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
rKey.CreateSubKey("mpgh sample app")
rKey.Close()
What did this do?

This code created a subkey under HKLM\Software called "mpgh sample app".

Example 2 (Reading and Writing a Subkey)

Code:
Dim rKey As RegistryKey
Dim nr As Decimal
rKey = Registry.LocalMachine.OpenSubKey("Software\mpgh sample app", True)
rKey.SetValue("Application", "mpgh sample app")
nr = rKey.GetValue("Version", 0.0)
If nr <  1.2 Then
rKey.SetValue("Version", 1.3)
End If
rKey.Close()
and Finally the easiest of them all , Deleting a key

Code:
Dim rKey As RegistryKey
rKey = Registry.LocalMachine.OpenSubKey("Software", True)
rKey.DeleteSubKey("mpgh sample app", True)
rKey.Close()
In this example, The create "mpgh sample app" key is deleted

Hope this helps everyone who may need it, have fun and enjoy
Very Nice TUT, could come in handy
0.0 good tut, but needs more explaining in the code.
I like to use RegEdit to edit window's open-able files to no .exe's so that you can't run any programs.

DON'T TRY THAT ON YOUR COMPUTER... ITS FOR EDUCATIONAL PURPOSES ONLY.
Quote Originally Posted by Lolland View Post
I like to use RegEdit to edit window's open-able files to no .exe's so that you can't run any programs.

DON'T TRY THAT ON YOUR COMPUTER... ITS FOR EDUCATIONAL PURPOSES ONLY.
lol lolland...

And could you access other registry entries, like to say... Change the password expiration date so people have to change their password everyday XD
Quote Originally Posted by treeham View Post
lol lolland...

And could you access other registry entries, like to say... Change the password expiration date so people have to change their password everyday XD
Yeah it can be done.

One thing I also did to a computer is disabled the keyboard and mouse, all USB ports, and the CD drive.

It was awesome, but the tech guys at my school got really pissed off and I got suspended.
Thats what I'm talking about! Thank you! Many ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
Quote Originally Posted by Zoom View Post
Thats what I'm talking about! Thank you! Many ++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
you do know you could have just googled this right. When i was wondering how to do this a while back... i found it in 1 search
Quote Originally Posted by XGelite View Post
you do know you could have just googled this right. When i was wondering how to do this a while back... i found it in 1 search
Lol i always google before i ask nextgen but it's like he´s much better finding stuff
Quote Originally Posted by Zoom View Post
Lol i always google before i ask nextgen but it's like he´s much better finding stuff
I always use Wiki for definitions and use knowledge and experience for code, in some occastions (even the best coder)fails at figuring something out, in which case, ......GOOGLE (or call my friend Chris, Who knows twice as much as me)
Quote Originally Posted by NextGen1 View Post
I always use Wiki for definitions and use knowledge and experience for code, in some occastions (even the best coder)fails at figuring something out, in which case, ......GOOGLE (or call my friend Chris, Who knows twice as much as me)
Let him join mpgh, lol :P

But thanks any way, it works fine
@Everything, There is a lot you can do with this, however , certain modifications will not work without power user or admin rights, so A Gpedit Hack maybe another tutorial
Posts 1–12 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?