WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: DAG_P6 on January 25, 2014, 12:04:20 PM

Title: Return Type of RegQueryDWord
Post by: DAG_P6 on January 25, 2014, 12:04:20 PM
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?
Title: Re: Return Type of RegQueryDWord
Post by: td on January 27, 2014, 07:56:30 AM
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. 

Title: Re: Return Type of RegQueryDWord
Post by: 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.
Title: Re: Return Type of RegQueryDWord
Post by: DAG_P6 on January 27, 2014, 05:51:58 PM
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.
Title: Re: Return Type of RegQueryDWord
Post by: td on January 28, 2014, 06:39:09 AM
Its not any odder than regedit.exe.
Title: Re: Return Type of RegQueryDWord
Post by: DAG_P6 on January 28, 2014, 10:36:02 AM
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.
Title: Re: Return Type of RegQueryDWord
Post by: td on January 28, 2014, 11:30:21 AM
It's still text.
Title: Re: Return Type of RegQueryDWord
Post by: DAG_P6 on January 28, 2014, 10:28:12 PM
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?
Title: Re: Return Type of RegQueryDWord
Post by: 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.
Title: Re: Return Type of RegQueryDWord
Post by: DAG_P6 on January 29, 2014, 05:22:28 PM
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 (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.