Agnel Kurian
Agnel Kurian

Reputation: 59456

Rewrite Registry File in Windows

I have been trying to find a way to "defragment" the registry on my Windows machine. Firstly, does this make sense? Any benefits in doing this? (Not much love on superuser.com) Secondly, I am looking for a way to rewrite the registry using C/C++ with Windows API. Is there a way to read the registry and write it to a new file getting rid of unused bytes along the way? (I might have to write the new file and then boot into another OS/disk before I can overwrite the original... but I am willing to take that risk.)

Upvotes: 4

Views: 992

Answers (3)

robertcollier4
robertcollier4

Reputation: 752

http://www.larshederer.homepage.t-online.de/erunt/ - NTREGOPT NT Registry Optimizer

Similar to Windows 9x/Me, the registry files in an NT-based system can become fragmented over time, occupying more space on your hard disk than necessary and decreasing overall performance. You should use the NTREGOPT utility regularly, but especially after installing or uninstalling a program, to minimize the size of the registry files and optimize registry access. The program works by recreating each registry hive "from scratch", thus removing any slack space that may be left from previously modified or deleted keys.

http://reboot.pro/index.php?showtopic=11212 - Offreg.dll MS WDK Offline Registry Library

The offline registry library (Offreg.dll) is used to modify a registry hive outside the active system registry. This library is intended for registry update scenarios such as servicing an operating system image. The library supports registry hive formats starting with Windows XP. Developer Audience

http://reboot.pro/topic/11312-offline-registry/ - Offline Registry MS WDK Command-Line Tool

A command line tool that will allow one to read and write to an offline registry hive.

Upvotes: 2

Alex K.
Alex K.

Reputation: 175748

Microsoft's PageDefrag does exactly this, as it states on its page "PageDefrag uses the standard file defragmentation APIs to defragment the files."

(A copy of the linked article is here because in typical MSDN style their link is dead.)

Upvotes: 2

Hans Olsson
Hans Olsson

Reputation: 54999

Reading the values should be possible.

But I've never seen any spec for how the registry files are written to disk, and unless you could find one you'd have to reverse engineer those files in your OS (might be differences between XP and 7 etc). Then you have to remember that the registry isn't just one file, it's multiple files and some of them belongs to certain users and I think they use SIDs rather than user names so even if you move them to a new computer, you have to be sure it's the same OS version with the same users with the same SIDs set up on it.

All this for little or no gain so I'd agree with the superuser users that it wouldn't make sense.

Upvotes: 0

Related Questions