Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Windows registry data types  (Read 3696 times)

0 Members and 1 Guest are viewing this topic.

EEVIAC

  • Guest
Windows registry data types
« on: February 12, 2010, 02:41:22 PM »
I'm not sure I understand why different data types are used in the registry.
I've read about the basic difference between them, but don't understand why one would be used over another..


Here is an example I picked out of the wind..

Say you want to disable the Administrative Shares in Winodws Vista..

Open regedit and go here:

HKLM\system\CurrentControlSet\Services\lanmanserver\parameters

add a dword key with value set to 0 and name it "AutoShareWks"  When you restart Windows the admin shares will not be shown........whatever

Why not add one of the other data types to accomplish this?  Why does "dword" have to be used?

Broni


    Mastermind
  • Kraków my love :)
  • Thanked: 614
    • Computer Help Forum
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 8
Re: Windows registry data types
« Reply #1 on: February 12, 2010, 07:29:55 PM »
Pretty decent  explanation in fairly plain English: http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=361

EEVIAC

  • Guest
Re: Windows registry data types
« Reply #2 on: February 12, 2010, 08:24:15 PM »
I think I've read that same tutorial a while back...  It gives an excellent basic description of the data types, but it doesn't say WHY each specific data type is applied, over another data type... 

Here is a quote from the tutorial:

"System policy settings, device drivers, and services use DWORD values the most."

Ok, so why to device drivers use dword data types and not reg_sz data types?

Going back to my own example....a dword data type was used to disable the Admin Shares.  Why dword?  There has to be a REASON that dword was used, and not another data type...

There are three primary data types, and there must be a reason that one would be used over another..







Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Windows registry data types
« Reply #3 on: February 12, 2010, 08:42:27 PM »
I'm not sure I understand why different data types are used in the registry.
I've read about the basic difference between them, but don't understand why one would be used over another..
......
Why not add one of the other data types to accomplish this?  Why does "dword" have to be used?
I don't understand your question. Or the value of the question.
They use a DWORD because it is a DWORD.
It is like asking why are laces in shores are  shoelaces.

Broni


    Mastermind
  • Kraków my love :)
  • Thanked: 614
    • Computer Help Forum
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 8
Re: Windows registry data types
« Reply #4 on: February 12, 2010, 08:53:19 PM »
It's not that easy to explain registry and I'm by far not any registry guru, but to extremely simplify things, it all depends what you need to enter as registry key value (data).
If you want to enter a path, CLSID number, etc, you'll use string, or multi string.
If the value needs to be, say "yes", or "no" you'll use dword either decimal or hex.
Binary type is more complicated to explain.

EEVIAC

  • Guest
Re: Windows registry data types
« Reply #5 on: February 12, 2010, 09:00:50 PM »
I understand binary math.. you can try to explain the binary data type if you want  ;D

Broni


    Mastermind
  • Kraków my love :)
  • Thanked: 614
    • Computer Help Forum
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 8
Re: Windows registry data types
« Reply #6 on: February 12, 2010, 09:11:03 PM »
Oh good for you  ;D
Again simplifying....
Binary data is used for describing some more complicated events. You can compare it to writing HTML, or Java code for web pages.
Since you're good with binary math, this example should be easy for you: http://vittoriop77.blogspot.com/2005/01/vbscript-write-registry-binary-value.html
It's not for me though  ;D  ???

EEVIAC

  • Guest
Re: Windows registry data types
« Reply #7 on: February 12, 2010, 09:19:37 PM »
It looks like programming code...  I don't understand a lick of programming, although I do understand binary math..

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Windows registry data types
« Reply #8 on: February 12, 2010, 09:20:54 PM »
http://msdn.microsoft.com/en-us/library/ms724884%28VS.85%29.aspx

To answer the question "Why" it's the same reason programming languages have different data types- for storing, you know, different types of data.

REG_SZ/RREG_EXPAND_SZ are used for storing Strings. one of the DWORD types are used for storing numbers.

a DWORD is 4 bytes. representing a DWORD as a string would take not only more then 4 bytes most of the time (anything over 999 would require more then 4 bytes) but also requires work to parse back into a DWORD in the program. This was a common issue with Windows INI files since they could only store strings; programs had to convert what they wanted to store into a string and be able to read those strings back. this caused issues when numbers were localized; say an INI file is written on a european install, which uses a comma for a decimal separator, and periods for thousands separators. reading that same value on another version of windows could yield a completely different result.
Of course you cannot really distribute a registry key as you could INI files, but the storage issue is still present, and as much as people like to claim otherwise the registry is a lot better organized then having thousands of INI files strewn all over the place. it's better to find the one or two keys that a program uses for it's settings then it is to try to trace the data file search path to try to discover which INI file is being loaded. (the one in C:\windows? the one in C:\windows\system32? the one in the application folder?)

Binary is stored for blobs of data. For example many programs store an entire blank file in the registry- in fact, that's one of the available options for the "New" shell key; most programs point it towards a file using a string, but it's also possible to simply embed the file structure right into the key. In that case the data type is also used to determine what to do with it; if you store a file path string as a Binary type it will not load the  file but will simply use that data. (this is btw the shell keys for adding items to the New-> submenu on a folders right-click menu).

a Binary data value actually has nothing to do with binary arithmetic. It's just a blob of data without a type at all; the program will need to know the format and what's inside it and how to interpret it; does it contain a persisted data structure? Perhaps it is, like in the case of the "new" sub-menu item, simply what would be file contents stored in a registry key? Only the program that wrote the value and/or it's documentation really can say.
I was trying to dereference Null Pointers before it was cool.

EEVIAC

  • Guest
Re: Windows registry data types
« Reply #9 on: February 12, 2010, 09:45:21 PM »

To answer the question "Why" it's the same reason programming languages have different data types- for storing, you know, different types of data.

So, the fact that Windows uses three primary data types is because Windows was written in a particular programming language?   

What data types do other languages use?


btw...thanks for the help everyone

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Windows registry data types
« Reply #10 on: February 12, 2010, 10:46:22 PM »
Understanding the data yeps.
You can do a search on Google or Yahoo or some other search engine on the subject "Data Types " and find numerous references. Many of these will be overpowering.
Think of far personal computers as being tools or appliances that have to be assembled from parts. Because of size, cost, the efficiency and other factors the parts can be of different size. Of coarse, the parts that are used in side the computer are not visible to the human vision. But there is a relationship of cost and efficiency, even though the size of these items is not apparent to the human eye.
The early personal computers that were made in the 1970s were either four bit or 8-bit computers. There also was the possibility of a six bit, but let's not talk about that. In an eight bit computer a processor can quickly load eight bits of data all that wants. It is possible to do both arithmetic operations and logic  operations on the bits in that one byte of memory.
Now to get to the point being made here. In these early computers there is no simple, easy and quick way to access one bit. Yes, you can access one bit, but at the same time you read seven other bits that you may not have been of interest. So if you wanted to change that one bit, you certainly could, but to write it back to memory unit have to write all it gets back to memory. The hardware did not really have a provision for just reading and writing one bit by itself without reading or writing the others.
Now it is true there are instructions or sequence of instructions that will allow you to test any bit in the eight bit memory location. Yet the hardware itself does not actually read just one bit, nor did it wrght one bit. In fact, it would take more effort to pick out just one bit by itself and perform operation on it than it would be to manipulate all eight bits at the same time. This was basically a hardware characteristic. The term BYTE came to be an expression or name used to identify the eight bits that would reside in a single memory location.
Now let's bring it up to modern date. The operating systems we use today are fundamentally 32-bit systems. In somewhat of an abstract sense they are designed for a computer that access is 32 bits at a time. Of course, our modern-day processors now Access 64-bitS.but the most popular system still in use are 32-bit systems. So the quick and efficient way of accessing data in memory is just to pull in 32 bits at a time operate on it and write it back out. There is no great advantage to trying to pick out individual bits among the 32 that are available. Unless you can imagine some advantage.
Now as to the registry, it is a database manager. We would like our database manager to be fairly efficient in speed and also memory usage. It would seem that specifying a byte value instead of a double word would be a better use of memory if only a small number is needed. A byte can represent a value from zero up to 255. Or, if you choose, of value that could range from -128 up to positive 127. However, the hardware does not really work any better trying to pick out just one bite than it is picking up the entire word or double word or quadruple word as the case may be. The CPU instruction set, of course, has specific introductions for doing BIT test, set and reset. You could use those heavy, they actually take more time than it is to operate on the entire set of bits all at once.

My apologies for my lack of making something like this more interesting or easier to understand. If it was something visible and you could see,  it wood be rather obvious. In the Windows operating system a design decision had been made some time ago to use the double word as the most common data type that would be used in the registry. This is not really a dependency on a specific programming language. It has to do with the underlying capabilities of the hardware. Remember, that MS DOS and Windows started out with a 16-bit computer that had an eight bit data path and some kind of strange 20 bit address path, the old 8088, later to be replaced by the 8086. With the advent of the 386, something which Microsoft and Intel did together, the idea of having a 32-bit processor instead of a 16-bit processor became a reality for desktop computers.
So basically, that is the best I can do to try to explain why they use double word, I am an old, old assembly language programmer and I used to work using an operating system that Intel had available long before DOS came on the scene. We did our work in assembly language and if we wanted speed we went access the memory on the byte level and not try to test individual bits. Of course, we could write a program to test individual bits. But as I said before, there is a speed disadvantage and you have to have actually more code in order to access just one bit.
To the moderator, edit or strike out any of the stuff you do not think is relevant. This is just the way I try to explain things to people that don't do this kind of low-level pedal to the metal work.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Windows registry data types
« Reply #11 on: February 12, 2010, 10:52:01 PM »
So, the fact that Windows uses three primary data types is because Windows was written in a particular programming language?   

No. I didn't even come close to saying that.

I was trying to dereference Null Pointers before it was cool.

EEVIAC

  • Guest
Re: Windows registry data types
« Reply #12 on: February 13, 2010, 07:04:27 AM »
No. I didn't even come close to saying that.

lol      I had a feeling that you would not like my interpretation...  Some of your terminology I just don't understand and occasionally I'll attempt to confirm whether I understand by summing up what you're saying.. If my sum is off, then it means I obviously don't get it...  :(

I did take another look at your explanation of binary data types and how each blob is specific to the program using it.. that helps  ;)   I understand now why a binary type could not be used in place of a string...

 



@ geek

That was a quite insightful explanation... helps a lot

Maybe you're not such a monster after all  ;D