Page 1 of 1

Opening the registry

Posted: Sat May 03, 2008 11:40 am
by codefire
I'm trying to write some code to read some values from the registry. Here's what I have so far - however, the code always fails to open the registry. Any ideas why?

Code: Select all

  
  hKey.l


  OpenConsole()
  Str.s = "Software\Microsoft\WindowsNT\CurrentVersion"
  RetCode.l = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, @Str, 0, #KEY_READ, @hKey)
  If RetCode = #ERROR_SUCCESS 
    PrintN("Opened OK")
  Else
    PrintN("Failed") 
  EndIf
  
  RegCloseKey_(hTestKey)

  Input()
  CloseConsole()
Many thanks,
Tony

Posted: Sat May 03, 2008 1:20 pm
by Sparkie
You need a space between Windows and NT. :wink:

Code: Select all

Str.s = "Software\Microsoft\Windows NT\CurrentVersion" 

Posted: Sat May 03, 2008 1:37 pm
by akj
"WindowsNT" needs an extra space, thus:

Code: Select all

"Software\Microsoft\Windows NT\CurrentVersion"

Posted: Sat May 03, 2008 1:46 pm
by Sparkie
Isn't that what I said. :?

Posted: Sat May 03, 2008 1:49 pm
by akj
Sorry Sparkie,
I didn't realise it was already answered when I posted my reply.

Posted: Sat May 03, 2008 1:54 pm
by Sparkie
np 8)

Posted: Sat May 03, 2008 6:39 pm
by codefire
God I'm dumb!

Now I remember why I always hated spaces in path names...

Thanks a lot guys! :)