How do I write to an alternative registry file other than the Windows Registry?
|
|
Thread rating:  |
Number Eleven - GPEMC! - 08 Sep 2008 09:34 GMT How do I create, write to, and read from; a registry file other than the Windows Registry, using VB6 and/or the API as accessed by VB6 ?
Thanks in Advance...
 Signature Timothy Casey GPEMC! Conditions apply. See www.fieldcraft.biz/GPEMC Essays: http://timothycasey.info; http://speed-reading-comprehension.com Software: http://fieldcraft.biz; Scientific IQ Test, Web Menus, Security. Science & Technical: http://geologist-1011.com; http://web-design-1011.com
PeterD - 08 Sep 2008 13:41 GMT >How do I create, write to, and read from; >a registry file other than the Windows Registry, >using VB6 and/or the API as accessed by VB6 ? > >Thanks in Advance... "what" other registry (files)? Can you be more explicit?
mayayana - 08 Sep 2008 14:06 GMT You can use INI files, which the Registry is modeled after. If you look up all the API functions that include "PrivateProfile" in the function name you'll find that you have the INI file equivalent of the Registry functions.
(Note, though, that the terms have been jumbled around. The Registry's key, value, data in INIs become section, key, value.)
> How do I create, write to, and read from; > a registry file other than the Windows Registry, [quoted text clipped - 7 lines] > Software: http://fieldcraft.biz; Scientific IQ Test, Web Menus, Security. > Science & Technical: http://geologist-1011.com; http://web-design-1011.com Number Eleven - GPEMC! - 09 Sep 2008 23:08 GMT > You can use INI files, which the Registry > is modeled after. If you look up all the API [quoted text clipped - 5 lines] > jumbled around. The Registry's key, value, data > in INIs become section, key, value.) This sounds promising. I'll take a peek. Thank you.
 Signature Timothy Casey GPEMC! Conditions apply. See www.fieldcraft.biz/GPEMC Essays: http://timothycasey.info; http://speed-reading-comprehension.com Software: http://fieldcraft.biz; Scientific IQ Test, Web Menus, Security. Science & Technical: http://geologist-1011.com; http://web-design-1011.com
Wolfgang Enzinger - 10 Sep 2008 17:13 GMT >> You can use INI files, which the Registry >> is modeled after. If you look up all the API [quoted text clipped - 7 lines] > >This sounds promising. I'll take a peek. Thank you. As much as I like the INI file format, too, one must say that it is primarily a "flat" structure. To be precise, it features only two levels of hierarchy: section and key.
[Section A] KeyA=X KeyB=Y
[Section B] KeyA=Z KeyB=A
You can, however, simulate more levels:
[Section B] SubSections=S1 S2 SubSections.S1.KeyA=Z SubSections.S1.KeyB=A SubSections.S2.KeyA=1 SubSections.S2.KeyB=2
But that means that you got to parse (split) the value retrieved from the Subsections key.
Generally, this is a very slow approach if you have more than just a few data to be managed. INI files are plain text files, and the GetPrivateProfile* functions have to do a lot of parsing.
So I think it's worth to reconsider what I wrote in MID 72jac4pkiochgmg9ms4jpdq0nkvs2s1vc8@4ax.com. If you use a file database such as Access or SQLite for storing the table, use indexes where appropriate and optimize the queries (e.g. use the DAO .Seek method for Access or prepared statements for SQLite), then the whole thing is pretty fast and easily maintainable. If fragmentation comes into play, the respective database systems offer simple methods for defragmentation.
Wolfgang
Phill W. - 09 Sep 2008 12:44 GMT > How do I create, write to, and read from; > a registry file other than the Windows Registry, > using VB6 and/or the API as accessed by VB6 ? A "registry file"? Do you mean a .reg file? Your favourite text-writing method (Print #, for example) should do the job nicely.
Or do you mean reading and writing in the Windows Registry somewhere /other than/ "HKEY_CURRENT_USER\VB and VBA Program Settings"? For that you'll need to use the Windows API but Google around; there are plenty of classes out there that wrap this up for you.
Personally, though, I wouldn't bother.
I'm rapidly "going off" the Registry and moving back to using good, "old-fashioned" text files out in the file system where you can see them and, more importantly, where they can get backed up (and even /more/ importantly, *restored*) by any half-sensible backup system.
That and 64-bit versions of Windows won't let a 32-bit [i.e. VB "Proper"] application "see" the whole [64-bit] Registry anyway, silently redirecting the process into its own little "kindergarten" corner of the Registry ...
HTH, Phill W.
Number Eleven - GPEMC! - 09 Sep 2008 23:12 GMT > > How do I create, write to, and read from; > > a registry file other than the Windows Registry, [quoted text clipped - 20 lines] > redirecting the process into its own little "kindergarten" corner of the > Registry ... Precisely! I want to store registry compatible data, just not in the registry. The issue is that I don't want to lose the speed of access that the registry system has when dealing with very large quantities of hierarchical data...
 Signature Timothy Casey GPEMC! Conditions apply. See www.fieldcraft.biz/GPEMC Essays: http://timothycasey.info; http://speed-reading-comprehension.com Software: http://fieldcraft.biz; Scientific IQ Test, Web Menus, Security. Science & Technical: http://geologist-1011.com; http://web-design-1011.com
expvb - 09 Sep 2008 23:41 GMT > Precisely! I want to store registry compatible data, just not in the > registry. The issue is that I don't want to lose the speed of access that > the registry system has when dealing with very large quantities of > hierarchical data... If you have large amount of configuration data, then you need to know that INI files are limited to 64KB. You can use XML or MDB files if you need more than that, with MDB being faster.
If you know VC++, here is alternative that makes INI Unicode files that can be larger than 64KB. It's an EXE with source, but can't be used from VB6 unless you convert it to a DLL:
http://www.codeguru.com/cpp/data/data-misc/inifiles/article.php/c4579/
Maybe there is a VB6 version out there. Try searching for "vb -dotnet INI 64KB".
|
|
|