convert hex registry key to decimal

Discussion in 'Scripting' started by lapa, Nov 13, 2003.

  1. lapa

    lapa Guest

    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
     
    lapa, Nov 13, 2003
    #1
    1. Advertisements

  2. 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"
     
    Alex K. Angelopoulos [MVP], Nov 13, 2003
    #2
    1. Advertisements

  3. lapa

    Guest Guest

    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.

     
    Guest, Nov 14, 2003
    #3
  4. 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 Bakken (MVP), Nov 14, 2003
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.