Results 1 to 10 of 10
  1. #1
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108

    [TUT] Reading Registry

    I'm going to show you how to read registry.

    The Windows Registry is a hierarchical database that stores configuration settings and options on Microsoft Windows operating systems. It contains settings for low-level operating system components as well as the applications running on the platform: the kernel, device drivers, services, SAM, user interface and third party applications all make use of the Registry. The registry also provides a means to access counters for profiling system performance.
    For instance, we are making a program for a game. We don't want the user to set his install directory, we want to get it with vb.net. Let's take a specific example. I want to do a modern warfare 2 trainer and I'm trying to get the install path.

    Microsoft.Win32 has a built in feature to read registry.

    First off all, to go into the registry, do the following:

    Start > Run > "RegEdit"



    Hit ok.

    Welcome to the Registry

    It looks like this:



    We are going to work with "HKEY_LOCAL_Machine" because installed program paths and other information are stored here.

    Abbreviated HKLM, HKEY_LOCAL_MACHINE stores settings that are specific to the local computer. On NT-based versions of Windows, HKLM contains four subkeys, SAM, SECURITY, SOFTWARE and SYSTEM, that are found within their respective files located in the %SystemRoot%\System32\config folder. A fifth subkey, HARDWARE, is volatile and is created dynamically, and as such is not stored in a file. Information about system hardware drivers and services are located under the SYSTEM subkey, while the SOFTWARE subkey contains software and Windows settings.
    Let us try to find Modern Warfare 2 by using Control + F.



    Yay we've successfully found it =D



    Now you actually see something called "InstallPath" as value it has the install directory, for instance: "C:\Program Files\Steam\SteamApps\common\call of duty modern warfare 2".

    Let's go into VB.

    Start a new project.



    Hit ok.

    Drag a button on the form.



    Doubleclick on the button.

    Now, to read the registry you have to use the following path.

    Code:
    Try
                Dim currhive As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine
    
                Dim branch As Microsoft.Win32.RegistryKey = currhive.OpenSubKey("Software\Activision\Modern Warfare 2", False)
                Dim value As String = CType(branch.GetValue("InstallPath"), String)
                branch.Close()
                MsgBox(value)
            Catch
                MsgBox(ErrorToString)
            End Try
    It'll look like this:



    Code:
    Try
    
    Catch
    Msgbox(errortostring)
    end try
    This is used for error-catching. If an error appears, it will catch it and use a message box to visualize it. Else, if an error appears, the program will just close.

    Code:
    Dim branch As Microsoft.Win32.RegistryKey = currhive.OpenSubKey("Software\Activision\Modern Warfare 2", False)
    This is pretty self-explaining.

    ,False = writeable

    If you are into changing the value, set it to True.

    Code:
    Dim value As String = CType(branch.GetValue("InstallPath"), String)


    To test it simply debug it by hitting "F5".

    I do hope you did understand everything.

    This tutorial is NOT leeched, just written it a second ago

    Enjoy!
    Last edited by Blubb1337; 04-22-2010 at 05:43 AM.



  2. #2
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful

    Thumbs up

    Very nice. Thanks for sharing !!

  3. #3
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Great job!! I don't know WHY you'd want to read the registry though o.o

  4. #4
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Looks Good, Added to Tuts

  5. #5
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Yesh good job. And btw, i'm catching up to your level nextgen

  6. #6
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Spam will do that

    J/K

  7. #7
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Hey not fair!! My activity's going down.
    On-Topic: What's the point of reading registry?

  8. #8
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    Well you can find out stuff like install directorys, serial keys, language, version AND SO ON. You can do very much in the registry. I did not work with the registry yet, just discovered this today and thought it might come in handy. As it is for my cod6 trainer.

    Nextgen might tell you more about it =D



  9. #9
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    I wrote a article / tutorial about it a while back, there are tons of reasons to have the ability to edit/modify registry information,

    Some values in registry can determine if a product is activated or not, So in your own application you can offer a Similar feature.

    Also if you are creating a Activation Crack for older software, you can use registry hacks or modifications for that as well.

    You can use the Registry to modify windows;

    Force The Use Of Active Desktop :

    Code:
    Modify the Registry and Create a  DWORD value named "ForceActiveDesktopOn"  value = "1"
    So if an application requires active desktop, you now force the user to turn on active desktop to use it, when the application closes you can set "ForceActiveDesktopOn" to "0" and it will no longer be "forced"

    In creating a trouble shooting application you can use a high verbose message (anyone familiar with a cmd linux will understand the term better) But the following modification to the registry will allow you to receive verbose startup, shutdown, logon, and logoff status messages.

    Code:
    Find or create the  DWORD  , call it "verbosestatus" and set it to "1"( if it exists set it to "1")
    
    Create a New DWORD , call it"DisableStatusMessages" (forces status messages to be disabled) set to "0". (if it exists , set it to "0")
    I am not going to get into all of them or into great detail , but it is more then useful.

    A few examples:

    Code:
    Change the Default Mail Client .
    Clear Download Accelerator History 
    Disable the Splash Screen on Adaptec DirectCD () 
    Change the Maximum Number of AOL Buddies
    Disable ICQ Auto Update
    Disable the Norton Utilities Splash Screen
    Configure Symantec Live Update to Use Passive FTP 
    Disable the Norton AntiVirus Splash Screen 
    Control Active Server Pages Browser Buffering 
    Change the ICQ Email Tagline 
    Change the Default Name and Company Information
    Display Network Error Statistics 
    Manage Network Bridge Feature
    Manage the QoS Packet Queuing 
    Enable the Network Adapter Onboard Processor
    Load Balance Network Adapter
    Disable Mapped Drive Reconnect Warning 
    Manage the Reserved QoS Bandwidth
    Specify the Schedule for Alerter Service
    Specify Users to Receive Administrative Alerts
    Remove the Hand Icon for Shared Resources
    Change the IRP Stack Size 
    Enable Random Adapter Responses
    Manage the Domain Controller Cannot Be Reached Message 
    Removing or Adding Items to Your Persistent Connections List
    Define the Slow Link Time-Out 
    Automatically Detect Slow Network Connections
    Specifying a Preferred Netware Server
    Increase Network Performance and Throughput
    Control Network Browser Elections
    The list is Huge, and even just one of these can be useful, infact a perfect example can be found in one of of the recent threads, The question was asked "How can i disable click sounds with web Browser", I answered with a Registry modification, Problem solved.

  10. The Following 3 Users Say Thank You to NextGen1 For This Useful Post:

    Blubb1337 (04-22-2010),Invidus (04-23-2010),ppl2pass (04-22-2010)

  11. #10
    Invidus's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    2,167
    Reputation
    23
    Thanks
    650
    My Mood
    Bored
    Wow. Thats handy >.<
    I'll just ask you next time

Similar Threads

  1. [TUT] Reading lines from a web document.
    By Jason in forum Visual Basic Programming
    Replies: 10
    Last Post: 06-08-2010, 01:42 AM
  2. TuT] How to Change File Attributes from Read only to Normal [TuT
    By XGelite in forum Visual Basic Programming
    Replies: 1
    Last Post: 11-19-2009, 01:08 PM
  3. [TuT] How to delete read only files.
    By XGelite in forum Visual Basic Programming
    Replies: 0
    Last Post: 10-13-2009, 09:59 AM
  4. reading any ea games key from registry..
    By popsot in forum C++/C Programming
    Replies: 0
    Last Post: 09-04-2009, 12:59 PM
  5. My Ultimate Anti-Scam technique (TUT (free, read this))
    By bambell in forum Trade Accounts/Keys/Items
    Replies: 2
    Last Post: 09-03-2007, 12:27 AM