Why we want to write to registry. We can just build a table in database and track each user's info. But I saw a lot of program try to write to registry? Can anyone explain? Thanks
Printable View
Why we want to write to registry. We can just build a table in database and track each user's info. But I saw a lot of program try to write to registry? Can anyone explain? Thanks
Back in the olden days, program settings were stored in .ini files that were read in, either by a programmer-developed roputine, or API calls to read INI's.
Then came the registry...a giant store of information that can be shared and is located in a single place.
With databases, especially file based one's like Access, etc...,you have to worry about connectivity, speed, syntax, LOCATION. What if some ID 10 T decides he wants to delete/move some files and ends up deleting a crucial file. What are the odds that same ID 10 T is going to find an entry in the registry, much less have a reason for deleting it?
If we're talking really complex data, then yes, it probably should be in some sort of supporting file, but if we're talking simple data, then the eregistry is the way to go.
Thanks, so you mean if we use SQL database, it can easily accomplish same. The only advantage to use registry is simple.
Am I correct?
I'm sure that you will get more in depth and technical answers to why you should write to registry.
But on a practical level, an example would be:
When you write a program that requires a File Open dialog box, it is handy sometimes to have the default folder to be the last folder browsed, regardless wether the program has been shut down or not (something VB6 doesn't do itself, funily enough!). Writing this directory string to the registry means you can hold it there until your program is rerun and the FileOpen dialog box opened again.
Now, as it is only one string, it is not worth creating a database. You could use a text file. or ini file, but why have an extra file?
Registery is great because most of common user do not go check in registery so you can put some variable value there to save them. Of course, it's not a good place to put big text.
Well, yes is the answer. You may also be working in an environment where administers don't like developers messing with the registry, so SQLServer would do (but would be theoretically slower)Quote:
Originally posted by Mark_Meng
Thanks, so you mean if we use SQL database, it can easily accomplish same. The only advantage to use registry is simple.
Am I correct?
The registry should be used for configuration data, or simple data you just need to grab or save. Use a (relational) database for structured, organized data you wish to sort or search. Use XML files for something in between.
Gaffer is quite correct about the simple aspect, but some other main reasons for the using the registry:
You can store bits of information on a per-user basis You dont need to keep track of the user
It's fairly idiotproof
And as Gaffer mentioned, you can use SaveSetting & GetSetting in VB to this kind of thing. You don't necessarily have to use the Registry api calls, unless you need to get fancy.
It's fast, and doesn't require any external files, networks, servers.
It's hidden from most users
Disadvantage - it doesn't follow a user from machine to machine if he changes PC's during the day, and you're doing stuff on a per-user basis
I think I got it. Thanks very much, I really appreciate