Forum Discussion

sastowe's avatar
sastowe
Super Contributor
13 years ago

registry on win7 64 bit

So I have a bit of code that I am testing on one of my 64bit operating systems. It is looking in the registry to determine some values that are needed to be set dynamically.



  If Not ProjectSuite.Variables.VariableExists("AppVersion") then ProjectSuite.Variables.AddVariable "AppVersion", "String"

  Set objOsInfo = Sys.OSInfo

  bIs64 = objOsInfo.Windows64bit

  if bIs64 Then

      sKey = "SOFTWARE\Wow6432Node\Company Name\Application\"

      Set key = Storages.Registry(sKey, HKEY_LOCAL_MACHINE, AQRT_64_BIT)

  Else

      sKey = "Software\Company Name\Application\"

      Set key = Storages.Registry(sKey, HKEY_LOCAL_MACHINE, AQRT_32_BIT)

  end if

  

  sDir = key.GetOption("Directory", "c:\Application\")

  TestedApps.Items("My_Application").Path = sDir

  ' get first 2 digits of the minor version.

  sVer = key.GetOption("Version", "")



This returns the values for the keys correctly on one of my 32 bit xp VMs. I am testing on a win764 bit machine. The value for sVer comes back as gobbledeegook. So in debug mode I tested for key.OptionExists("Directory") and key.OptionExists("Version"). Both return false. I acn SEE them in the regedit. I thought I might have a typo. So in regedit I copied the key name and pasted into code editor to compare. No typo.



Note that before I began troubleshooting. this line



      Set key = Storages.Registry(sKey, HKEY_LOCAL_MACHINE, AQRT_64_BIT)



was outside of the conditional and just said



      Set key = Storages.Registry(sKey, HKEY_LOCAL_MACHINE)



No worky.



Thoughts anyone?



Thanks



S



1 Reply

  • Hello Stephanie,


    Try running the following code on your 64-bit machine:



    sKey = "SOFTWARE\Company Name\Application\"

    Set key = Storages.Registry(sKey, HKEY_LOCAL_MACHINE, AQRT_32_BIT)

    sDir = key.GetOption("Directory", "c:\Application\")

    TestedApps.Items("My_Application").Path = sDir

    sVer = key.GetOption("Version", "")



    It should return the values you need.