Most games and application make changes to the systems registry or to other files in order to save settings or keep logs. The various steps in this tutorial will show you how to modify the registry in your DarkBASIC Professional application or game.
Part One - Writing to the Window's Registry
In DarkBASIC Professional you can write either strings or integers to the registry using to different commands. To write a string to the system registry use the "Write String to Registry" functions. If you would like to write a number to the registry instead, use the "Write to Registry" command.
Example for writing strings to the registry:
write string to registry "SOFTWARE\Microsoft\Windows\CurrentVersion\Run", APPNAME$, get dir$() + "\" + APPNAME$ + ".exe"
This sample will add your application to the computers start up, making it start every time the computer boots up.
Example for writing numbers to the registry:
write to registry "SOFTWARE\" + APPNAME$, "ResX", 1024
write to registry "SOFTWARE\" + APPNAME$, "ResY", 768
The code give above will write the current resolution to two keys in order for you to remember next time your game starts.
If the registry key does not exist, when you execute either of the methods above, it will be created automatically for you.
Part Two - Reading Strings and Integers from the System Registry
If you need to write to the system registry you will inevitably need to read from it as well. This is simpler then writing to the registry.
To read a string from the registry you will need to use the "get registry$" method as shown below.
Astring$ = get registry$ "SOFTWARE\" + APPNAME$ , "AString"
This code will store the specified registry key in the Astring$ string.
Reading an integer or number is quite similar. In order to read an integer from the registry simply make use the "get registry" command, like so:
Ainteger = get registry "SOFTWARE\" + APPNAME$ , "AInteger"
The above code reads an integer and stores it in the Ainteger integer.
Notice the usage of the "$" character. This character is used to distinguish when you want to use a string or not. Use "$" when you want to define or get a string.
End
Using the commands and methods given in this tutorial it will be quite easy and effective when trying to modify the Window's Registry when coding your DarkBASIC Professional game or application.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
Playing with Windows Registry - Part 3Windows registry is one of the most important parts of Microsoft Windows Operating System. It contains information and settings for the Windows itself. Since it contains your Wi...
A Political Do Not Call Registry, Will it Work?A service, patterned after the "National Do Not Call Registry" claims it can put an end to those annoying political phone calls that usually come when you are having dinner- Free Registry Fix Guide for WindowsHave you ever deleted a program but it still showed up? A registry fix would be the program to find all the pieces of that program and repair it or delete it.
- Should You Download Registry Mechanic?Registry Mechanic is one of the most searched for registry repair products on the market, but does it perform? This review will document the good and the negative aspects of using this software.
- Options in Cleaning a System RegistryCleaning the Windows registry can be a difficult task, and can result in the permanent eradication of one's computer. To clean a registry the right way, consumers usually only have one option.
- Photoshop Tutorial: Changing the Color Tone of Your Photos
- Photoshop Tutorial : How to Apply a Weather Effect to Your Text ?
- Tutorial: How to Sabotage Yourself
- Photoshop Tutorial: How to Digitally Create Beautiful White Teeth
- Anatomy of the Windows Registry
- Can't Access Your Registry Editor? Here's How to Fix It!
- Playing with Windows Registry - Part 1



