Very nice. Thanks for sharing !!
I'm going to show you how to read registry.
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.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.
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.
Let us try to find Modern Warfare 2 by using Control + F.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.
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.
It'll look like this: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
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:Try Catch Msgbox(errortostring) end try
This is pretty self-explaining.Code:Dim branch As Microsoft.Win32.RegistryKey = currhive.OpenSubKey("Software\Activision\Modern Warfare 2", False)
,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.
Very nice. Thanks for sharing !!
Great job!! I don't know WHY you'd want to read the registry though o.o
Looks Good, Added to Tuts
Yesh good job. And btw, i'm catching up to your level nextgen
Spam will do that
J/K
Hey not fair!! My activity's going down.
On-Topic: What's the point of reading registry?
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
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 :
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"Code:Modify the Registry and Create a DWORD value named "ForceActiveDesktopOn" value = "1"
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.
I am not going to get into all of them or into great detail , but it is more then useful.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")
A few examples:
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.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
Wow. Thats handy >.<
I'll just ask you next time