代码:
reg.rootKey:=HKEY_CLASSES_ROOT;
if FlatCheckBox2.Checked=True then
begin
reg.OpenKey('lnkfile',true);
if reg.ValueExists('IsShortCut')=true then
reg.DeleteValue('IsShortCut');
end
else
reg.OpenKey('lnkfile',true);
reg.WriteString('IsShortCut','');
end;
reg.CloseKey;
reg.Free;
在上面代码中.键值可以新建但删不了.为什么呢?
reg.rootKey:=HKEY_CLASSES_ROOT;
if FlatCheckBox2.Checked=True then
begin
reg.OpenKey('lnkfile',true);
if reg.ValueExists('IsShortCut')=true then
reg.DeleteValue('IsShortCut');
end
else
reg.OpenKey('lnkfile',true);
reg.WriteString('IsShortCut','');
end;
reg.CloseKey;
reg.Free;
在上面代码中.键值可以新建但删不了.为什么呢?
reg.rootKey:=HKEY_CLASSES_ROOT;
if FlatCheckBox2.Checked=True then
begin
reg.OpenKey('lnkfile',false);
// if reg.ValueExists('IsShortCut')=true then
reg.DeleteValue('IsShortCut');
end
else
reg.OpenKey('lnkfile',true);
reg.WriteString('IsShortCut','');
end;
reg.CloseKey;
reg.Free;
if FlatCheckBox2.Checked=True then
begin
reg.OpenKey('lnkfile',true);
if reg.ValueExists('IsShortCut')=true then
reg.DeleteValue('IsShortCut');
end
else
begin //这里用复合语句把, 只有FlatCheckBox2.Checked=True 才写键进去
reg.OpenKey('lnkfile',true);
reg.WriteString('IsShortCut','');
end;
end;
reg.CloseKey;
reg.Free;