djawahar
asked on
Create Registry keys under HKEY_LOCAL_MACHINE in vista/win7.
Hi,
I have a piece of VB6 code that writes string data under HKEY_LOCAL_MACHINE using RegCreateKeyEx API. this works well under XP but under vista/win7 it does not write. I tried "run as administrator" but even then it does not work. With UAC off it works, except in 2 of the 7 PCs that I tried in. I also tried the following code I found on microsoft site
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts :{imperson ationLevel =impersona te}!\\" & strComputer & "\root\default:StdRegProv" )
strKeyPath = "SOFTWARE\NewKey"
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyP ath
but this also does not work.
What would be a foolproof method of writing the data.
Thanks & regards,
DJ
I have a piece of VB6 code that writes string data under HKEY_LOCAL_MACHINE using RegCreateKeyEx API. this works well under XP but under vista/win7 it does not write. I tried "run as administrator" but even then it does not work. With UAC off it works, except in 2 of the 7 PCs that I tried in. I also tried the following code I found on microsoft site
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts
strKeyPath = "SOFTWARE\NewKey"
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyP
but this also does not work.
What would be a foolproof method of writing the data.
Thanks & regards,
DJ
ASKER
Hi graye,
I just checked again. the 2 machines where I have problem even when I use "Run as Administrator" are running 64 BIT versions of Win 7. I think this has something to do with 64BIT rather than UAC. What I dont understand is that RegCreateKeyEx exits without any error code. It makes it look as if the key has been created.
Thanks & regards,
DJ
I just checked again. the 2 machines where I have problem even when I use "Run as Administrator" are running 64 BIT versions of Win 7. I think this has something to do with 64BIT rather than UAC. What I dont understand is that RegCreateKeyEx exits without any error code. It makes it look as if the key has been created.
Thanks & regards,
DJ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The HKLM\Software key in WinV/Win7 requires administrator rights. Are you sure that running the application with "Run As Administrator" doesn't work?