• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

Modifying the (Default) value in a registrykey.

var
reg:=tregistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CURRENT_USER;
Reg.createKey('Software\Microsoft\Windows\CurrentVersion\Policies\System');
Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\System', true);
Reg.WriteString('(Default)','1');
end;

upon running the command, the value for '(Default)' remains at 'value not set'. i do not have a problem setting the values for other stuff except for the prime (Default) value for every key.

please help
0
tyfing
Asked:
tyfing
  • 3
  • 2
1 Solution
 
gemartiCommented:
I'm sure you have to rename the '(default)' value before you can assign data to it.

RenameValue(const OldName, NewName: String);
0
 
MadshiCommented:
Reg.WriteString('', '1');

Regards, Madshi.
0
 
tyfingAuthor Commented:
RenameValue(const OldName, NewName: String);

what do u mean ? i tried b4 but i am not sure of the method
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
gemartiCommented:
MadShi had the correct solution. I didn't test, I just posted what works for other portions of the key.

var
reg:tregistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CURRENT_USER;
Reg.createKey('Software\Microsoft\Windows\CurrentVersion\Policies\System');
Reg.OpenKey('Software\Microsoft\Windows\CurrentVersion\Policies\System', true);
Reg.RenameValue('(Default)','Default');
Reg.WriteString('Default','1');
end;

creates a new value name

Default Reg_Sz 1

but you still have

(Default) REG_SZ (value not set)


0
 
tyfingAuthor Commented:
i want to change the value of (Default) from 'value not set' to '1'.
0
 
gemartiCommented:
Yes. Madshi's method works.
reg.WriteString('',1);
Did you test?
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now