Return Type of RegQueryDWord

Started by DAG_P6, January 25, 2014, 12:04:20 PM

Previous topic - Next topic

DAG_P6

While debugging a script, I noticed something unusual when the following statement executed.

Code (winbatch) Select
iFlags = RegQueryDWord ( aParm_P6C [ APARM_MY_HKLM_KEY_P6C ] , '[ProgramInitFlags]' )

The watch window shows the expected value for iFlags, but the type indicated in the debug window is String_Unicode.

Shouldn't a REG_DWORD be cast to Integer?
David A. Gray
You are more important than any technology.

td

WIL is negatively typed so the underlying representation is automagically converted as necessary in most cases, when dealing with basic WIL types. In other words, it doesn't matter all that much most of the time. 

Also, the registry value type of REG_DWORD should not be assumed to be synonymous with the win32 API DWORD type define in C and C++ header files. This is evidenced by the fact that the WIL function returns and the regedit.exe application displays the REG_DWORD value in either decimal or hexadecimal form. 

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Noticed that there is a documentation error in the help file for the RegQueryDword function's return value.  The documentation indicates (i) as the function's return type but it should be (s).  Perhaps this rather than something philosophical is the  source of the question in the original post.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

Quote from: td on January 27, 2014, 09:21:18 AM
Noticed that there is a documentation error in the help file for the RegQueryDword function's return value.  The documentation indicates (i) as the function's return type but it should be (s).  Perhaps this rather than something philosophical is the  source of the question in the original post.

No. I hadn't consulted the documentation. Rather, it struck me as odd that a query for a DWORD should return a string, as if it were a REG_SZ, when I anticipated an int.
David A. Gray
You are more important than any technology.

td

Its not any odder than regedit.exe.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

Quote from: td on January 28, 2014, 06:39:09 AM
Its not any odder than regedit.exe.
How so? For a REG_DWORD, you get a text box and two linked radio buttons for telling it whether the text in the box is base 10 or 16.

The export generated for a REG_DWORD looks like so.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Sysinternals\PsLoglist]
"EulaAccepted"=dword:00000001



Neither of the above strikes me as odd.

Please enlighten me.
David A. Gray
You are more important than any technology.

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

Quote from: td on January 28, 2014, 11:30:21 AM
It's still text.
How is a DWORD "still text?" Would you say the same for REG_BINARY?
David A. Gray
You are more important than any technology.

td

When viewed via regedit or WIL it is.  Its also an arrangement of metallic dust and/or transistor states.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DAG_P6

Tony,

Quote from: td on January 29, 2014, 07:49:10 AM
When viewed via regedit or WIL it is.  Its also an arrangement of metallic dust and/or transistor states.

OK, I give.

BTW, your reply prompted me to review the RegQueryValueEx function, documented at http://msdn.microsoft.com/en-us/library/windows/desktop/ms724911(v=vs.85).aspx, and confirmed my general recollection that, strictly speaking, it returns a status code, and fills a buffer with data, whose kind and volume depend on the type of data stored in the queried value.
David A. Gray
You are more important than any technology.