Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


1526 RegLoad-UnloadHive Access Denied

 Keywords: 1526 RegLoadHive RegUnloadHive Access Denied 

Question:

I am tring the execute the following code. Yet I keep getting the error 1526. I am able to manually load the (ntuser.dat) hive and create the subkey and unload the hive. So I don't think it's an access permissions issue. Why do you think I am getting an accessed denied error?
; the default User's Registry
LoadRes=RegLoadHive(@REGUSERS,"DefUser","c:\documents and settings\Default User\ntuser.dat")
reg=RegOpenKey(@REGUSERS,"DefUser")

; Make change to Registry (Can be anything)
res=regCreateKey(reg,"Software\CCRW")

; Unload and save the Defualt User Hive
UnLoadRes=RegUnloadHive(@REGUSERS,"DefUser")

Answer:

That error is a result of the subkey handle still being open. Make sure you are using RegCloseKey to close the handle before you attempt to unload the hive.
; the default User's Registry
LoadRes=RegLoadHive(@REGUSERS,"DefUser","c:\documents and settings\Default User\ntuser.dat")
reg=RegOpenKey(@REGUSERS,"DefUser")

; Make change to Registry (Can be anything)
res=regCreateKey(reg,"Software\CCRW")

;Free the handles
RegCloseKey(reg)
RegCloseKey(res)

; Unload and save the Defualt User Hive
UnLoadRes=RegUnloadHive(@REGUSERS,"DefUser")

Article ID:   W15140