Skip to main content
gamedev.net
🔒 Locked

Registry Access Error

Started by soconne 3 replies 600+ views
Original Post
soconne
soconne
I''m trying to write to the registry using the TRegistry object in Borland C++ Builder 6, but for some reason I cannot access HKEY_LOCAL_MACHINE and write strings to it. For instance, here is my code TRegistry *Reg = new TRegistry(); Reg->RootKey = HKEY_LOCAL_MACHINE; Reg->CreateKey("SOFTWARE\\MySoftware"); Reg->OpenKey("SOFTARE\\MySoftware", false); Reg->WriteString("licence", "0"); Reg->CloseKey(); Reg->Free(); But when I execute this, I get an error saying "Failed to set data for ''licence''" I''m following the tutorial at the link below, but I cannot get it to work. If I set the RootKey to HKEY_CLASSES_ROOT then I can execute this code. But otherwise, no. http://www.onlineprogrammer.org/articles/Articlea2-5-3.html
Author Freeworld3Dhttp://www.freeworld3d.org
felisandria
felisandria
Are you certain you have local machine permissions? I''m not sure what the correct venue for setting permissions is in Borland, but I know that when I''m doing auto shutdowns on my stuff I have to set local machine permissions prior to attempting shutdown or it won''t listen to me.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
soconne
soconne
Well I am logged into my computer as Administrator in WinXP. How do you go about setting permissions? I''m sure I can convert it over to Borland.
Author Freeworld3Dhttp://www.freeworld3d.org
remi
remi
I had the same problem lately!.

Try the ModifyPrivilege function.

Maybe you'll have to adjust the code to work properly in Borland C++ Builder.

Hope it helps!

[edited by - remi on June 3, 2004 4:30:09 AM]
"...and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces."----------Scott Meyers, "Effective C++"
Endurion
Endurion
You notice the typo saying SOFTARE instead of SOFTWARE? OpenKey won''t allow you to open non-existant keys.
Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.