Opening the registry

Windows specific forum
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Opening the registry

Post 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
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

You need a space between Windows and NT. :wink:

Code: Select all

Str.s = "Software\Microsoft\Windows NT\CurrentVersion" 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

"WindowsNT" needs an extra space, thus:

Code: Select all

"Software\Microsoft\Windows NT\CurrentVersion"
Anthony Jordan
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Isn't that what I said. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post by akj »

Sorry Sparkie,
I didn't realise it was already answered when I posted my reply.
Anthony Jordan
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

np 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
codefire
User
User
Posts: 38
Joined: Thu Mar 15, 2007 4:32 pm
Location: UK

Post by codefire »

God I'm dumb!

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

Thanks a lot guys! :)
Post Reply