delphi xe 10 操作win10注册表不成功,谁知道原因?
procedure TFrmMain.FormCreate(Sender: TObject);
var
MyReg:TRegistry;
begin
MyReg := TRegistry.Create;
MyReg.RootKey := HKEY_LOCAL_MACHINE;
if MyReg.KeyExists('Software\MyDelphi') then
begin
if MyReg.CreateKey('Software\MyDelphi') then
begin
if MyReg.OpenKey('Software\MyDelphi',true ) then
begin
MyReg.WriteString('yjw','yuanjiwu');
end;
end;
end
else
if MyReg.OpenKey('Software\MyDelphi',true ) then
begin
MyReg.WriteString('yjw','yuanjiwu');
end;
MyReg.CloseKey;//关闭主键
MyReg.Destroy;//释放内存
end;