How to Save and Reload Hive Files in Windows 95
Keywords: RegLoadHive
Question:
I'm not sure how create a hive file to disk with the Windows 95 registry. Do you have any suggestions?Answer:
There's an option in NT's Registry Editor to save a hive to a file, but not in Windows 95 Regedit.exe, so to save a hive to a file in Win95 using Winbatch, it involves a DllCall.Here is how to unload registry information to a hive, and then reloading it with the RegLoadHive. Hives are different from exported *.REG branches of the registry in that they are not permanently written to the Registry when loaded. They are sort of virtual in that way (somewhat like mapped drives)---they go away when you reboot your machine or unloaded them.
This is different than doing an export of a branch to a *.REG text file. A hive file is a binary file, that when loaded, does not get permanently written to the Registry.
A lot of people have problems implementing a "hive-save" in Windows 95. Here's how to do it with a DllCall from WinBatch. The Hive-files can be loaded with RegLoadHive.
The most simple way to perform this task is this one:
hkey=RegOpenKey(@regcurrent, "Software\Netscape") ret = DllCall ("C:\WINDOWS\SYSTEM\ADVAPI32.DLL",long:"RegSaveKeyA",long:hkey,lpstr:"C:\TEMP\HIVEFILE.BIN", lpnull) RegCloseKey(hkey) Message("DllCall returns:", ret)where:This works. You can import the hive file with RegLoadHive.
- hkey is the handle from RegOpen key (should be an open handle to a registry key, e.g. RegOpenKey (@REGMACHINE, "Software");
- C:\WIN95\SYSTEM\ADVAPI32.DLL is the registry-DLL;
- "RegSaveKeyA" is the entry point function call for "save" hive file;
- D:\TEMP\HIVEFILE is the filename of the hive-file which will be created by the DllCall.
It is not the easiest way, nor the most transparent or safe.
Article ID: W13720Filename: How to Save Hive Files in Windows 95.txt