WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Registry
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

RegOpenKeyEx Notes

Keywords:   RegOpenKeyEx Notes

The following is a little object lesson in registry access modes. I was stuck for hours on this.

You have to apply the mode at the layer where the restriction is set, not simply to the final destination.

In the following example, the Runonce key is apparantly write-only!


;put the value in place, then try to read it
      regsetvalue(@REGCURRENT,"\Software\Microsoft\Windows\CurrentVersion\Runonce[COLORS]", "xyzzy")

;method 1 (fails)
      ;x = regquerystr(@REGCURRENT,"\Software\Microsoft\Windows\CurrentVersion\Runonce[COLORS]")

;method 2 (fails)
      ;w = regopenkeyEx(@REGCURRENT,"\Software\Microsoft\Windows\CurrentVersion\Runonce",1|8,"","")
      ;x = regqueryvalue(w,"[COLORS]")
      ;RegCloseKey(w)

;method 3 (works)
      wa = regopenkey(@REGCURRENT,"Software\Microsoft\Windows\CurrentVersion")
      wb = regopenkeyEx(wa,"Runonce", 1, "","")
      x = regqueryvalue(wb,"[COLORS]")
      RegCloseKey(wb)
      RegCloseKey(wa)

      message("x=",x)
      exit

Article ID:   W15681
File Created: 2003:05:13:11:29:30
Last Updated: 2003:05:13:11:29:30