Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert hex registry key to decimal

480 views
Skip to first unread message

lapa

unread,
Nov 13, 2003, 12:16:01 PM11/13/03
to
hello there,

the folling two lines represent an export from a registry
key.

[HKEY_LOCAL_MACHINE\SYSTEM\...\Ac97]
"MasterVolume"=hex:07,07

i would like to use the value in a script as a decimal
value. sadly i did not find any solution for this yet.

i would appreciate any help.

thank you,

lapa

Alex K. Angelopoulos [MVP]

unread,
Nov 13, 2003, 12:23:09 PM11/13/03
to
You can't use that as a decimal; it is a binary. You CAN write binary
values to the registry. Using WSH-hosted VBScript, for example:

Set WshShell = CreateObject("WScript.Shell")
WshShell.RegWrite "HKLM\SYSTEM\...\Ac97\MasterVolume", &H0707, "REG_BINARY"

anon...@discussions.microsoft.com

unread,
Nov 14, 2003, 1:15:06 AM11/14/03
to
is there any way to use the value for an 'if' decision? as
i have tried with RegRead, i got a type mismatch error.

it would be enough to know if its equal to sg. (i would
like to know if the current volume level equals one of 5
predefined values to fade the volume level from one to
another. the current value is the only thing i miss for
the code...

thanks again.

>.
>

Torgeir Bakken (MVP)

unread,
Nov 14, 2003, 7:26:10 AM11/14/03
to
lapa wrote:

> the folling two lines represent an export from a registry
> key.
>
> [HKEY_LOCAL_MACHINE\SYSTEM\...\Ac97]
> "MasterVolume"=hex:07,07
>
> i would like to use the value in a script as a decimal
> value. sadly i did not find any solution for this yet.

Hi

I think this should work:


Set oShell = CreateObject("WScript.Shell")

sRegValue = "HKLM\SYSTEM\.........\Ac97\MasterVolume"

aRegData = oShell.RegRead(sRegValue)

For i = 0 To UBound(aRegData)
vHexVal = vHexVal & Right("0" & Hex(aRegData(i)), 2)
Next

WScript.Echo CLng("&H" & vHexVal)

--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide: http://www.microsoft.com/technet/scriptcenter


0 new messages