Hi all. My question is about the registry. I've read many tutorials ,but I want to understand it more deeply, from "programmer point of view" How,why, and what exactly ends up in the registry? lets say I had developed a program in C++ (a text editor,with windows,menus etcc.. ) Now, I compile it and run it. Does this modifies the registry in some way? is there a section in registry for my program, and is it now possible to change my prog's settings from there? and which settings exactly is it possible to change from there? Or it's up to programmer to write in sorce-code some statements to explicitely tell which parts of my programs will be editable from the registry?

And second question:

When I look at some programs settings in registry ( windows explorer for example) I can edit only these settings that are already there? or I can put entirely new keys ? How big is exactly the power of the registry? Is it possible to modify the programs in any possible way from it? Please help,or at least tell me about some book or good tutorial?

Dani AI

Generated

Short answer for : a C++ program does not magically get a registry "section" just by being compiled or run. The registry changes only when code (your app, its installer, or Windows itself) explicitly writes keys/values. Many system integrations (file associations, COM classes, services) are created by installers or by explicit API calls; simple apps that save settings to files will leave the registry untouched.

A few concrete points that often confuse people:

  • Two common places for app settings are HKEY_CURRENT_USER (per-user) and HKEY_LOCAL_MACHINE (machine-wide). Write to HKCU when no admin rights are required; HKLM needs elevation. On 64-bit Windows watch Wow6432Node redirection for 32-bit processes.
  • Registry values have concrete types (REG_SZ, REG_DWORD, REG_BINARY, etc.). Use the right type for the data you want to store — see the Windows Registry overview and registry value types.
  • You can create new keys and values if you have permission. Changing a program via the registry works only if that program reads those keys. You cannot change compiled logic by editing the registry.

If you want to explore what a program actually touches, use a monitoring tool (Process Monitor is good) to see registry reads/writes in real time: ProcMon. As cautioned, be careful; as suggested, test safely — prefer a VM or snapshot rather than experimenting on a production machine.

Tiny C++ example (Win32 API) — open/create a key and write a string:

HKEY hKey;
if (RegCreateKeyExA(HKEY_CURRENT_USER,
    "Software\\MyCompany\\MyApp", 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) == ERROR_SUCCESS) {
    const char *v = "value";
    RegSetValueExA(hKey, "Setting", 0, REG_SZ, (const BYTE*)v, (DWORD)strlen(v)+1);
    RegCloseKey(hKey);
}

Recommended practice: keep user settings in HKCU or in files under %APPDATA%, reserve HKLM for global/installed configuration, and always test changes in an isolated environment.

Recommended Answers

All 2 Replies

hi, don't mess up with the registry if you don't want to be in trouble.. anyway check out this one for enlightment ..lol

http://www.kellys-korner-xp.com/xp_tweaks.htm

if your hands are so itchy to touch the registry..then prepare to back-up and reformat hard drive..heheheh

The registry is a very large area. It basically is a number of files that store information about the whole of the resouces and requests for hardware and software in the computer.

As far as changing things goes there are a lot of books etc but if you really wnat to try the way i walked was
1: Fix a restore point!
2: choose a fairly safe area of the registry to try your experiments (and google will help here)
3: using the menus of regedit EXPORT the correct working key that you are going to play with
4: make some changes within the KEY or DATA.
Close down and probably restart machine and see if the effects are what you expect / Want.

5: If it does not work and you have used a fairly safe area then you can IMPORT hte KEY that you changed and that will rectify the mistake.
If that fails go back to the restore point;
This sounds boring but it builds on expereince as well as building yours.
You can make serious mistakes and mess up the machine but doing this route it is less likely and fairly safe!
M

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.